| Iterator concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator primitives | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Algorithm concepts and utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Indirect callable concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Common algorithm requirements | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator adaptors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Non-member functions | ||||
operator==operator<=> (C++20)(C++20) | ||||
(C++20) | ||||
(C++20) | ||||
(C++20) | ||||
(C++20) | ||||
| Helper classes | ||||
template<std::common_with<I> I2> friendconstexprbool operator==( | (1) | (since C++20) |
template<std::common_with<I> I2> friendconstexpr strong_ordering operator<=>( | (2) | (since C++20) |
Compares the underlying lengths (i.e. distances to the end).
<=>.The behavior is undefined ifx andy do not point to elements of the same sequence. That is, there must exist somen such thatstd::next(x.base(), x.count()+ n) andstd::next(y.base(), y.count()+ n) refer to the same element.
The<,<=,>,>=, and!= operators aresynthesized fromoperator<=> andoperator== respectively.
This function template is not visible to ordinaryunqualified orqualified lookup, and can only be found byargument-dependent lookup when std::counted_iterator<I> is an associated class of the arguments.
Contents |
| x, y | - | iterator adaptors |
Since thelength counts down, not up, the order of the arguments ofoperator<=> in the underlying comparison expression is reversed, i.e.y islhs,x isrhs.
#include <initializer_list>#include <iterator> int main(){staticconstexprauto v={1,2,3,4,5,6};constexprstd::counted_iterator<std::initializer_list<int>::iterator> it1{v.begin(),5}, it2{v.begin(),5}, it3{v.begin()+1,4}, it4{v.begin(),0}; static_assert(it1== it2); static_assert(it2!= it3); static_assert(it2< it3); static_assert(it1<= it2); static_assert(it3!=std::default_sentinel); static_assert(it4==std::default_sentinel); // it2 == std::counted_iterator{v.begin(), 4}; // UB: operands do not refer to// elements of the same sequence}
checks if the distance to the end is equal to0(function template)[edit] | |
(C++20) | advances the iterator (function template)[edit] |
(C++20) | computes the distance between two iterator adaptors (function template)[edit] |