constexpr iterator end() noexcept; // (1)
constexpr const_iterator end() const noexcept; // (2)
概要
optionalをrangeとした時の末尾要素の次を指すイテレータを取得する。
効果
begin() + has_value() を返す。
例
#include <iostream>
#include <iterator>
#include <optional>
int main()
{
std::optional<int> p = 1;
std::cout << std::distance(p.begin(), p.end()) << std::endl;
p = std::null_opt;
std::cout << std::distance(p.begin(), p.end()) << std::endl;
}
出力
1
0
バージョン
言語
- C++26
処理系
- Clang: ??
- GCC: ??
- ICC: ??
- Visual C++: ??