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まで) |
|
2つの複素数を比較します。スカラー引数は、実部が引数に等しく虚部がゼロに設定された複素数として扱われます。
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); }