| ||||||||||||||||||||||
| Range primitives | |||||||
| |||||||
| Range concepts | |||||||||||||||||||
| |||||||||||||||||||
| Range factories | |||||||||
| |||||||||
| Range adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Helper items | |||||||||||||||||
| |||||||||||||||||
constexprauto end() requires(!/*simple-view*/<V>); | (1) | (since C++20) |
constexprauto end()const requiresranges::range<const V>; | (2) | (since C++20) |
common_view, that is:base_)+ranges::distance(base_), if bothranges::random_access_range<V> andranges::sized_range<V> are satisfied,base_)) otherwise.V is const-qualified.Contents |
An iterator representing the end of the underlying view.
#include <iostream>#include <numeric>#include <ranges> int main(){constexprint n{4}; constexprauto v1= std::views::iota(1)| std::views::take(n)| std::views::common;constexprauto v2= std::views::iota(2)| std::views::take(n);constint product=std::inner_product(v1.begin(), v1.end(), v2.begin(),0);std::cout<< product<<'\n';}
Output:
40
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 4012 | C++20 | non-const overload missed simple-view check | added |
| returns an iterator to the beginning (public member function)[edit] | |
(C++20) | returns an iterator to the beginning of a range (customization point object)[edit] |
(C++20) | returns a sentinel indicating the end of a range (customization point object)[edit] |