Namespaces
Variants
Views
Actions

std::ranges::common_view<V>::end

From cppreference.com
< cpp‎ | ranges‎ | common view
 
 
Ranges library
Range access
Range conversions
(C++23)
Range primitives



Dangling iterator handling
Range concepts
Views

Factories




Adaptors
Range adaptor objects
Range adaptor closure objects
Helper items
 
 
constexpr auto end();
(1) (since C++20)
constexpr auto end() const requires ranges::range<const V>;
(2) (since C++20)
1) Returns an iterator representing the end of the common_view, that is: Here base_ (the name is for exposition only purposes) is the underlying view.
2) Same as (1), but V is const-qualified.

Contents

[edit] Parameters

(none)

[edit] Return value

An iterator representing the end of the underlying view.

[edit] 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

[edit] See also

(C++20)
returns an iterator to the beginning
(public member function) [edit]
returns an iterator to the beginning of a range
(customization point object) [edit]
returns a sentinel indicating the end of a range
(customization point object) [edit]