operator==,!= (std::complex)
From cppreference.net
|
헤더 파일에 정의됨
<complex>
|
||
| (1) | ||
|
template
<
class
T
>
bool operator == ( const complex < T > & lhs, const complex < T > & rhs ) ; |
(C++14 이전) | |
|
template
<
class
T
>
constexpr bool operator == ( const complex < T > & lhs, const complex < T > & rhs ) ; |
(C++14 이후) | |
| (2) | ||
|
template
<
class
T
>
bool operator == ( const complex < T > & lhs, const T & rhs ) ; |
(C++14 이전) | |
|
template
<
class
T
>
constexpr bool operator == ( const complex < T > & lhs, const T & rhs ) ; |
(C++14 이후) | |
| (3) | ||
|
template
<
class
T
>
bool operator == ( const T & lhs, const complex < T > & rhs ) ; |
(C++14 이전) | |
|
template
<
class
T
>
constexpr bool operator == ( const T & lhs, const complex < T > & rhs ) ; |
(C++14 이후)
(C++20 이전) |
|
| (4) | ||
|
template
<
class
T
>
bool operator ! = ( const complex < T > & lhs, const complex < T > & rhs ) ; |
(C++14 이전) | |
|
template
<
class
T
>
constexpr bool operator ! = ( const complex < T > & lhs, const complex < T > & rhs ) ; |
(C++14 이후)
(C++20 이전) |
|
| (5) | ||
|
template
<
class
T
>
bool operator ! = ( const complex < T > & lhs, const T & rhs ) ; |
(C++14 이전) | |
|
template
<
class
T
>
constexpr bool operator ! = ( const complex < T > & lhs, const T & rhs ) ; |
(C++14 이후)
(C++20 이전) |
|
| (6) | ||
|
template
<
class
T
>
bool operator ! = ( const T & lhs, const complex < T > & rhs ) ; |
(C++14까지) | |
|
template
<
class
T
>
constexpr bool operator ! = ( const T & lhs, const complex < T > & rhs ) ; |
(C++14부터)
(C++20까지) |
|
두 복소수를 비교합니다. 스칼라 인수는 실수 부분이 인수와 같고 허수 부분이 0으로 설정된 복소수로 처리됩니다.
1-3)
lhs
와
rhs
의 동등성을 비교합니다.
4-6)
lhs
와
rhs
가 서로 다른지 비교합니다.
|
|
(C++20 이후) |
매개변수
| lhs, rhs | - | 비교할 인자들: 두 개의 복소수이거나 일치하는 타입의 스칼라와 하나의 복소수 ( float , double , long double ) |
반환값
1-3)
true
만약
lhs
의 해당 부분들이
rhs
와 같으면,
false
그렇지 않으면.
4-6)
!
(
lhs
==
rhs
)
예제
이 코드 실행
#include <complex> int main() { using std::operator""i; // 또는: using namespace std::complex_literals; static_assert(1.0i == 1.0i); static_assert(2.0i != 1.0i); constexpr std::complex z(1.0, 0.0); static_assert(z == 1.0); static_assert(1.0 == z); static_assert(2.0 != z); static_assert(z != 2.0); }