std::ranges::common_view<V>::end
constexpr auto end(); |
(1) | (since C++20) |
constexpr auto end() const requires ranges::range<const V>; |
(2) | (since C++20) |
common_view
, that is:
-
ranges::begin(base_) + ranges::size(base_)
, if bothranges::random_access_range<V>
andranges::sized_range<V>
are satisfied, -
std::common_iterator<ranges::iterator_t<V>, ranges::sentinel_t<V>>(ranges::end(base_))
otherwise.
base_
(the name is for exposition only purposes) is the underlying view.
2) Same as
(1), but
V
is const-qualified.
Parameters
(none).
Return value
An iterator representing the end of the underlying view.
Example
#include <iostream> #include <numeric> #include <ranges> int main() { constexpr int n{4}; constexpr auto cv1 = std::views::iota(1) | std::views::take(n) | std::views::common ; constexpr auto cv2 = std::views::iota(2) | std::views::take(n) ; const int product = std::inner_product(cv1.begin(), cv1.end(), cv2.begin(), 0); std::cout << product << '\n'; }
Output:
40
See also
(C++20)
|
returns an iterator to the beginning (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/end