- ranges[meta header]
- std::ranges[meta namespace]
- take_while_view[meta class]
- function[meta id-type]
- cpp20[meta cpp]
constexpr auto begin()
requires (!simple-view<V>); // (1) C++20
constexpr auto begin() const
requires range<const V> &&
indirect_unary_predicate<
const Pred,
iterator_t<const V>
>; // (2) C++20viewの先頭要素を指すイテレータを取得する。
- (1), (2) : 以下と等価:
return ranges::begin(base_);
ただし、base_は元のviewを表すメンバ変数。
#include <ranges>
#include <vector>
#include <iostream>
int main() {
std::vector<int> vec = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
std::ranges::take_while_view r{vec, [](int x) { return x < 6; }};
auto it = r.begin();
int x = *it;
std::cout << x << '\n';
}- begin[color ff0000]
1
- C++20
- Clang: 13.0.0 [mark verified]
- GCC: 10.1.0 [mark verified]
- ICC: ?
- Visual C++: 2019 Update 10 [mark verified]