operator==,!=,<,<=,>,>=,<=> (std::deque)
|
헤더에 정의됨
<deque>
|
||
|
template
<
class
T,
class
Alloc
>
bool
operator
==
(
const
std::
deque
<
T, Alloc
>
&
lhs,
|
(1) | (C++26부터 constexpr) |
|
template
<
class
T,
class
Alloc
>
bool
operator
!
=
(
const
std::
deque
<
T, Alloc
>
&
lhs,
|
(2) | (C++20까지) |
|
template
<
class
T,
class
Alloc
>
bool
operator
<
(
const
std::
deque
<
T, Alloc
>
&
lhs,
|
(3) | (C++20까지) |
|
template
<
class
T,
class
Alloc
>
bool
operator
<=
(
const
std::
deque
<
T, Alloc
>
&
lhs,
|
(4) | (C++20까지) |
|
template
<
class
T,
class
Alloc
>
bool
operator
>
(
const
std::
deque
<
T, Alloc
>
&
lhs,
|
(5) | (C++20 이전) |
|
template
<
class
T,
class
Alloc
>
bool
operator
>=
(
const
std::
deque
<
T, Alloc
>
&
lhs,
|
(6) | (C++20까지) |
|
template
<
class
T,
class
Alloc
>
/* 아래 참조 */
|
(7) |
(C++20부터)
(C++26부터 constexpr) |
두
deque
의 내용을 비교합니다.
deque
의 값 타입(즉,
typename
deque
::
value_type
)을
value_type
으로 정의합니다:
|
return
std::
distance
(
lhs.
begin
(
)
, lhs.
end
(
)
)
|
(C++14 이전) |
|
return std:: equal ( lhs. begin ( ) , lhs. end ( ) , rhs. begin ( ) , rhs. end ( ) ) ; |
(C++14 이후) |
rhs. begin ( ) , rhs. end ( ) ) ; .
-
value_type가 LessThanComparable 가 아닌 경우. - operator < 가 total order 를 설정하지 않는 경우.
rhs.
begin
(
)
, rhs.
end
(
)
,
synth-three-way
)
.
-
T가three_way_comparable를 모델하지 않는 경우. -
operator
<
가 (const 한정이 가능한)
value_type타입의 값에 대해 정의되지 않은 경우. - operator < 가 total order 를 설정하지 않는 경우.
|
|
(C++20부터) |
목차 |
매개변수
| lhs, rhs | - |
deque
비교할 내용을 가진
|
반환값
| 연산자 |
lhs
와
rhs
가 동일함 |
lhs
가
사전순으로 더 큼 |
rhs
가
사전순으로 더 큼 |
|---|---|---|---|
| operator == | true | false | |
| operator ! = | false | true | |
| operator < | false | false | true |
| operator <= | true | ||
| operator > | false | true | false |
| operator >= | true | ||
| operator <=> | 0 과 동일한 값 | 0 보다 큰 값 | 0 보다 작은 값 |
복잡도
deque
의 크기에 선형 시간.
deque
의 크기에 선형적으로 비례합니다.
참고 사항
|
관계 연산자는
|
(C++20 이전) |
|
관계 연산자는 정의되지 않습니다. 재작성된 후보 operator <=> 이 오버로드 해결에 의해 선택됩니다.
operator
<=>
은 가능한 경우
|
(C++20 이후) |
예제
#include <cassert> #include <compare> #include <deque> int main() { const std::deque a{1, 2, 3}, b{1, 2, 3}, c{7, 8, 9, 10}; assert ("" "동일한 컨테이너 비교:" && (a != b) == false && (a == b) == true && (a < b) == false && (a <= b) == true && (a > b) == false && (a >= b) == true && (a <=> b) != std::weak_ordering::less && (a <=> b) != std::weak_ordering::greater && (a <=> b) == std::weak_ordering::equivalent && (a <=> b) >= 0 && (a <=> b) <= 0 && (a <=> b) == 0 && "다른 컨테이너 비교:" && (a != c) == true && (a == c) == false && (a < c) == true && (a <= c) == true && (a > c) == false && (a >= c) == false && (a <=> c) == std::weak_ordering::less && (a <=> c) != std::weak_ordering::equivalent && (a <=> c) != std::weak_ordering::greater && (a <=> c) < 0 && (a <=> c) != 0 && (a <=> c) <= 0 && ""); }
결함 보고서
다음의 동작 변경 결함 보고서들은 이전에 발표된 C++ 표준에 소급 적용되었습니다.
| DR | 적용 대상 | 게시된 동작 | 올바른 동작 |
|---|---|---|---|
| LWG 3431 | C++20 |
operator
<=>
가
T
가
three_way_comparable
를 모델링할 것을 요구하지 않음
|
요구함 |