- ranges[meta header]
- std::ranges[meta namespace]
- to_input_view[meta class]
- function[meta id-type]
- cpp26[meta cpp]
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 [mark verified]
- GCC: 15.1 [mark verified]
- Visual C++: 2022 Update 14 [mark noimpl]