operator==, !=, <, <=, >, >= (std::experimental::optional)
From cppreference.net
<
cpp
|
experimental
|
optional
|
헤더 파일에 정의됨
<experimental/optional>
|
||
|
두 개의
optional
객체 비교
|
||
|
template
<
class
T
>
constexpr bool operator == ( const optional < T > & lhs, const optional < T > & rhs ) ; |
(1) | (라이브러리 fundamentals TS) |
|
template
<
class
T
>
constexpr bool operator ! = ( const optional < T > & lhs, const optional < T > & rhs ) ; |
(2) | (라이브러리 fundamentals TS) |
|
template
<
class
T
>
constexpr bool operator < ( const optional < T > & lhs, const optional < T > & rhs ) ; |
(3) | (라이브러리 펀더멘털 TS) |
|
template
<
class
T
>
constexpr bool operator <= ( const optional < T > & lhs, const optional < T > & rhs ) ; |
(4) | (라이브러리 펀더멘털 TS) |
|
template
<
class
T
>
constexpr bool operator > ( const optional < T > & lhs, const optional < T > & rhs ) ; |
(5) | (라이브러리 펀더멘털 TS) |
|
template
<
class
T
>
constexpr bool operator >= ( const optional < T > & lhs, const optional < T > & rhs ) ; |
(6) | (라이브러리 펀더멘털 TS) |
optional
객체와
nullopt
를 비교합니다
|
||
|
template
<
class
T
>
constexpr bool operator == ( const optional < T > & opt, std:: nullopt_t ) noexcept ; |
(7) | (라이브러리 fundamentals TS) |
|
template
<
class
T
>
constexpr bool operator == ( std:: nullopt_t , const optional < T > & opt ) noexcept ; |
(8) | (라이브러리 펀더멘털 TS) |
|
template
<
class
T
>
constexpr bool operator ! = ( const optional < T > & opt, std:: nullopt_t ) noexcept ; |
(9) | (라이브러리 펀더멘털 TS) |
|
template
<
class
T
>
constexpr bool operator ! = ( std:: nullopt_t , const optional < T > & opt ) noexcept ; |
(10) | (라이브러리 펀더멘털 TS) |
|
template
<
class
T
>
constexpr bool operator < ( const optional < T > & opt, std:: nullopt_t ) noexcept ; |
(11) | (라이브러리 펀더멘털 TS) |
|
template
<
class
T
>
constexpr bool operator < ( std:: nullopt_t , const optional < T > & opt ) noexcept ; |
(12) | (라이브러리 펀더멘털 TS) |
|
template
<
class
T
>
constexpr bool operator <= ( const optional < T > & opt, std:: nullopt_t ) noexcept ; |
(13) | (라이브러리 펀더멘털 TS) |
|
template
<
class
T
>
constexpr bool operator <= ( std:: nullopt_t , const optional < T > & opt ) noexcept ; |
(14) | (라이브러리 펀더멘털 TS) |
|
template
<
class
T
>
constexpr bool operator > ( const optional < T > & opt, std:: nullopt_t ) noexcept ; |
(15) | (라이브러리 펀더멘털 TS) |
|
template
<
class
T
>
constexpr bool operator > ( std:: nullopt_t , const optional < T > & opt ) noexcept ; |
(16) | (라이브러리 펀더멘털 TS) |
|
template
<
class
T
>
constexpr bool operator >= ( const optional < T > & opt, std:: nullopt_t ) noexcept ; |
(17) | (라이브러리 펀더멘털 TS) |
|
template
<
class
T
>
constexpr bool operator >= ( std:: nullopt_t , const optional < T > & opt ) noexcept ; |
(18) | (라이브러리 펀더멘털 TS) |
optional
객체와
T
를 비교합니다
|
||
|
template
<
class
T
>
constexpr bool operator == ( const optional < T > & opt, const T & value ) ; |
(19) | (라이브러리 펀더멘털 TS) |
|
template
<
class
T
>
constexpr bool operator == ( const T & value, const optional < T > & opt ) ; |
(20) | (라이브러리 펀더멘털 TS) |
|
template
<
class
T
>
constexpr bool operator ! = ( const optional < T > & opt, const T & value ) ; |
(21) | (라이브러리 펀더멘털 TS) |
|
template
<
class
T
>
constexpr bool operator ! = ( const T & value, const optional < T > & opt ) ; |
(22) | (라이브러리 펀더멘털 TS) |
|
template
<
class
T
>
constexpr bool operator < ( const optional < T > & opt, const T & value ) ; |
(23) | (라이브러리 fundamentals TS) |
|
template
<
class
T
>
constexpr bool operator < ( const T & value, const optional < T > & opt ) ; |
(24) | (라이브러리 펀더멘털 TS) |
|
template
<
class
T
>
constexpr bool operator <= ( const optional < T > & opt, const T & value ) ; |
(25) | (라이브러리 fundamentals TS) |
|
template
<
class
T
>
constexpr bool operator <= ( const T & value, const optional < T > & opt ) ; |
(26) | (라이브러리 fundamentals TS) |
|
template
<
class
T
>
constexpr bool operator > ( const optional < T > & opt, const T & value ) ; |
(27) | (라이브러리 fundamentals TS) |
|
template
<
class
T
>
constexpr bool operator > ( const T & value, const optional < T > & opt ) ; |
(28) | (라이브러리 fundamentals TS) |
|
template
<
class
T
>
constexpr bool operator >= ( const optional < T > & opt, const T & value ) ; |
(29) | (라이브러리 fundamentals TS) |
|
template
<
class
T
>
constexpr bool operator >= ( const T & value, const optional < T > & opt ) ; |
(30) | (라이브러리 펀더멘털 TS) |
optional
객체에 대한 비교 연산을 수행합니다.
1-6)
두 개의
optional
객체,
lhs
와
rhs
를 비교합니다. 포함된 값은 (
(1,2)
의 경우
operator
==
를 사용하고,
(3-6)
의 경우
operator
<
를 사용하여) 오직
lhs
와
rhs
모두 값이 포함되어 있을 때만 비교됩니다. 그렇지 않은 경우,
-
-
- lhs 는 다음 조건에서만 같음 으로 간주됩니다: lhs 와 rhs 모두 값이 없는 경우입니다.
- lhs 는 다음 조건에서만 더 작음 으로 간주됩니다: rhs 가 값을 포함하고 lhs 는 값을 포함하지 않는 경우입니다.
-
7-18)
opt
를
nullopt
와 비교합니다. 값을 포함하지 않는
optional
과 비교할 때 (1-6)과 동등합니다.
19-30)
opt
를
value
와 비교합니다. 값 비교는
opt
가 값을 포함하는 경우에만 수행됩니다
(19-22)
에서는
operator
==
를,
(23-30)
에서는
operator
<
를 사용합니다). 그렇지 않은 경우,
opt
는
value
보다
작은
것으로 간주됩니다.
매개변수
| lhs, rhs, opt | - |
비교할
optional
객체
|
| value | - | 포함된 값과 비교할 값 |
| 타입 요구사항 | ||
-
T
는 (1,2) 오버로드를 사용하기 위해
EqualityComparable
요구사항을 충족해야 합니다.
|
||
반환값
1)
만약
bool
(
lhs
)
!
=
bool
(
rhs
)
라면,
false
를 반환합니다.
그렇지 않고 만약
bool
(
lhs
)
==
false
라면(따라서
bool
(
rhs
)
==
false
도 마찬가지),
true
를 반환합니다.
그렇지 않으면,
*
lhs
==
*
rhs
를 반환합니다.
2)
반환값
!
(
lhs
==
rhs
)
.
3)
만약
bool
(
rhs
)
==
false
가 반환되면
false
를 반환합니다.
그렇지 않고
bool
(
lhs
)
==
false
인 경우,
true
를 반환합니다.
그렇지 않으면
*
x
<
*
y
를 반환합니다.
4)
반환값
!
(
rhs
<
lhs
)
.
5)
반환값
rhs
<
lhs
.
6)
반환값
!
(
lhs
<
rhs
)
.
7,8)
반환값
!
opt
.
9,10)
반환값
bool
(
opt
)
.
11)
반환값
false
.
12)
반환값
bool
(
opt
)
.
13)
반환값
!
opt
.
14)
반환값
true
.
15)
반환값
bool
(
opt
)
.
16)
반환값
false
.
17)
반환값
true
.
18)
반환값
!
opt
.
19)
반환값
bool
(
opt
)
?
*
opt
==
value
:
false
.
20)
반환값
bool
(
opt
)
?
value
==
*
opt
:
false
.
21)
반환값
bool
(
opt
)
?
!
(
*
opt
==
value
)
:
true
.
22)
반환값
bool
(
opt
)
?
!
(
value
==
*
opt
)
:
true
.
23)
반환값
bool
(
opt
)
?
*
opt
<
value
:
true
.
24)
bool
(
opt
)
?
value
<
*
opt
:
false
를 반환합니다.
25)
반환값
!
(
opt
>
value
)
.
26)
반환값
!
(
value
>
opt
)
.
27)
반환값
bool
(
opt
)
?
value
<
*
opt
:
false
.
28)
반환값
bool
(
opt
)
?
*
opt
<
value
:
true
.
29)
반환값
!
(
opt
<
value
)
.
30)
반환값
!
(
value
<
opt
)
.
예외
1-6)
(없음)
19-30)
(없음)