constexpr auto begin(); | (1) | (since C++20) |
constexpr auto begin() const requires range<const V>; | (2) | (since C++20) |
common_view
, that is: ranges::begin(base_)
, if both ranges::random_access_range<V>
and ranges::sized_range<V>
are satisfied, std::common_iterator<ranges::iterator_t<V>, ranges::sentinel_t<V>>(ranges::begin(base_))
otherwise. base_
(the name is for exposition only purposes) is the underlying view. V
is const-qualified.(none).
An iterator to the beginning of the underlying view.
#include <iostream> #include <numeric> #include <ranges> #include <string_view> int main() { constexpr auto common = std::views::iota(1) | std::views::take(3) | std::views::common ; for (int i{}; int e : common) { std::cout << (i++ ? " + " : "") << e; } std::cout << " = " << std::accumulate(common.begin(), common.end(), 0) << '\n'; }
Output:
1 + 2 + 3 = 6
(C++20) | returns an iterator to the end (public member function) |
(C++20) | returns an iterator to the beginning of a range (customization point object) |
(C++20) | returns a sentinel indicating the end of a range (customization point object) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/ranges/common_view/begin