operator==,!=,<,<=,>,>=,<=>(std::basic_string)
| ヘッダ <string>
|
||
| で定義
2 つの basic_string オブジェクトを比較する |
||
template< class CharT, class Traits, class Alloc >
bool operator==( const std::basic_string<CharT,Traits,Alloc>& lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(1) | (C++11 から noexcept) (C++20 から constexpr) |
template< class CharT, class Traits, class Alloc >
bool operator!=( const std::basic_string<CharT,Traits,Alloc>& lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(2) | (C++20 まで) (C++11 から noexcept) |
template< class CharT, class Traits, class Alloc >
bool operator<( const std::basic_string<CharT,Traits,Alloc>& lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(3) | (C++20 まで) (C++11 から noexcept) |
template< class CharT, class Traits, class Alloc >
bool operator<=( const std::basic_string<CharT,Traits,Alloc>& lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(4) | (C++20 まで) (C++11 から noexcept) |
template< class CharT, class Traits, class Alloc >
bool operator>( const std::basic_string<CharT,Traits,Alloc>& lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(5) | (C++20 まで) (C++11 から noexcept) |
template< class CharT, class Traits, class Alloc >
bool operator>=( const std::basic_string<CharT,Traits,Alloc>& lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(6) | (C++20 まで) (C++11 から noexcept) |
template< class CharT, class Traits, class Alloc >
constexpr /*comp-cat*/
operator<=>( const std::basic_string<CharT,Traits,Alloc>& lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs ) noexcept;
|
(7) | (C++20 から) |
basic_string オブジェクトと T |
||
template< class CharT, class Traits, class Alloc >
bool operator==( const std::basic_string<CharT,Traits,Alloc>& lhs,
const CharT* rhs );
|
のヌル終端配列を比較する | (8) |
template< class CharT, class Traits, class Alloc >
bool operator==( const CharT* lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(C++20 から constexpr) | (9) |
template< class CharT, class Traits, class Alloc >
bool operator!=( const std::basic_string<CharT,Traits,Alloc>& lhs,
const CharT* rhs );
|
(C++20 まで) | (10) |
template< class CharT, class Traits, class Alloc >
bool operator!=( const CharT* lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(C++20 まで) | (11) |
template< class CharT, class Traits, class Alloc >
bool operator<( const std::basic_string<CharT,Traits,Alloc>& lhs,
const CharT* rhs );
|
(C++20 まで) | (12) |
template< class CharT, class Traits, class Alloc >
bool operator<( const CharT* lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(C++20 まで) | (13) |
template< class CharT, class Traits, class Alloc >
bool operator<=( const std::basic_string<CharT,Traits,Alloc>& lhs,
const CharT* rhs );
|
(C++20 まで) | (14) |
template< class CharT, class Traits, class Alloc >
bool operator<=( const CharT* lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(C++20 まで) | (15) |
template< class CharT, class Traits, class Alloc >
bool operator>( const std::basic_string<CharT,Traits,Alloc>& lhs,
const CharT* rhs );
|
(C++20 まで) | (16) |
template< class CharT, class Traits, class Alloc >
bool operator>( const CharT* lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(C++20 まで) | (17) |
template< class CharT, class Traits, class Alloc >
bool operator>=( const std::basic_string<CharT,Traits,Alloc>& lhs,
const CharT* rhs );
|
(C++20 まで) | (18) |
template< class CharT, class Traits, class Alloc >
bool operator>=( const CharT* lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(C++20 まで) | (19) |
template< class CharT, class Traits, class Alloc >
constexpr /*comp-cat*/
operator<=>( const std::basic_string<CharT,Traits,Alloc>& lhs,
const CharT* rhs );
|
(C++20 まで) | (20) |
(C++20 から)CharT文字列の内容を、別の文字列または
のヌル終端配列と比較します。
すべての比較は compare()Traits::compare() メンバ関数(それ自体が
- に基づいて定義されます)を介して行われます。
lhs2 つの文字列は、rhsとlhsのサイズが等しく、rhs内の各文字が同じ位置に
- 内の同等の文字を持つ場合に等しくなります。 順序比較は辞書順に行われます–。比較は std::lexicographical_compare または std::lexicographical_compare_three_way(C++20 から) と同等の関数によって実行されます。
basic_string オブジェクトを比較します。
basic_string オブジェクトと CharT のヌル終端配列を比較します。
|
三方比較演算子 (
|
(C++20 から) |
パラメータ
| lhs, rhs | - | 内容を比較する文字列 |
戻り値
計算量
文字列のサイズに対して線形。
注記
|
少なくとも1つのパラメータが型
std::string
,
std::wstring
,
std::u8string
,
std::u16string
, または
std::u32string
である場合、
|
(C++20以降) |
例
|
このセクションは不完全です
理由: 例がありません |
不具合報告
以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。
| DR | 適用対象 | 公開時の動作 | 正しい動作 |
|---|---|---|---|
| LWG 2064 | C++11 |
2つのbasic_stringを取るオーバーロードがnoexceptかどうかが一貫していなかった;
CharT*を取るオーバーロードはnoexceptだが未定義動作を引き起こす可能性があった
|
一貫性を持たせた;
noexceptを削除 |
| LWG 3432 | C++20 |
operator<=>の戻り値型が比較カテゴリ型であることが要求されていなかった
|
要求するように変更 |