operator==,<=> (std::counted_iterator)
| 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)
|
||||
|
(C++20)
|
||||
|
(C++20)
|
||||
| Helper classes | ||||
|
template
<
std::
common_with
<
I
>
I2
>
friend
constexpr
bool
operator
==
(
|
(1) | (C++20 이후) |
|
template
<
std::
common_with
<
I
>
I2
>
friend
constexpr
strong_ordering operator
<=>
(
|
(2) | (C++20 이후) |
기본 길이(즉, 끝까지의 거리)를 비교합니다.
<=>
연산자로 비교합니다.
x 와 y 가 동일한 시퀀스의 요소를 가리키지 않을 경우 동작은 정의되지 않습니다. 즉, 어떤 n 이 존재하여 std:: next ( x. base ( ) , x. count ( ) + n ) 와 std:: next ( y. base ( ) , y. count ( ) + n ) 가 동일한 요소를 참조해야 합니다.
<
,
<=
,
>
,
>=
, 그리고
!=
연산자들은 각각
합성됩니다
operator
<=>
와
operator
==
로부터.
이 함수 템플릿은 일반적인 unqualified 또는 qualified lookup 으로는 보이지 않으며, std::counted_iterator<I>가 인자들의 연관 클래스일 때에만 argument-dependent lookup 을 통해서만 찾을 수 있습니다.
목차 |
매개변수
| x, y | - | iterator adaptors |
반환값
참고 사항
length 가 증가하지 않고 감소하기 때문에, 기본 비교 표현식에서 operator <=> 인자의 순서가 반전됩니다. 즉, y 가 lhs 가 되고, x 가 rhs 가 됩니다.
예제
#include <initializer_list> #include <iterator> int main() { static constexpr auto v = {1, 2, 3, 4, 5, 6}; constexpr std::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: 피연산자들이 동일한 시퀀스의 // 요소들을 참조하지 않음 }
참고 항목
끝까지의 거리가
0
인지 확인합니다
(함수 템플릿) |
|
|
(C++20)
|
반복자를 전진시킵니다
(함수 템플릿) |
|
(C++20)
|
두 반복자 어댑터 사이의 거리를 계산합니다
(함수 템플릿) |