constexpr auto end()
requires (!simple-view<V>); // (1) C++26
constexpr auto end() const
requires range<const V>; // (2) C++26
概要
番兵を取得する。
効果
以下と等価:
return ranges::end(base_);
備考
to_input_view
はcommon_range
コンセプトを満たさないため、イテレータ型と番兵型は異なる型となる
例
#include <ranges>
#include <vector>
#include <iostream>
int main() {
std::vector<int> v = {1, 2, 3, 4, 5};
std::ranges::to_input_view view{v};
auto it = view.begin();
auto sentinel = view.end();
static_assert(!std::same_as<decltype(it), decltype(sentinel)>);
int count = 0;
for (; it != sentinel; ++it) {
++count;
}
std::cout << "size: " << count << std::endl;
}
出力
size: 5
バージョン
言語
- C++26
処理系
- Clang: 21 ✅
- GCC: 15.1 ✅
- Visual C++: 2022 Update 14 ❌