The Wayback Machine - https://web.archive.org/web/20180509091642/http://ja.cppreference.com:80/w/cpp/string/basic_string/operator_cmp
名前空間
変種
操作

operator==,!=,<,<=,>,>=(std::basic_string)

提供: cppreference.com
< cpp‎ | string‎ | basic string
 
 
 
std::basic_string
非メンバ関数
operator==operator!=operator<operator>operator<=operator>=
(C++11)(C++11)(C++11)
(C++11)(C++11)
(C++11)(C++11)(C++11)
(C++11)
(C++11)
ヘルパークラス
推定ガイド(C++17)
 
2つの basic_string オブジェクトの比較
template<class CharT, class Traits, class Alloc >

bool operator==(const basic_string<CharT,Traits,Alloc>& lhs,

                 const basic_string<CharT,Traits,Alloc>& rhs );
(1)
template<class CharT, class Traits, class Alloc >

bool operator!=(const basic_string<CharT,Traits,Alloc>& lhs,

                 const basic_string<CharT,Traits,Alloc>& rhs );
(2)
template<class CharT, class Traits, class Alloc >

bool operator<(const basic_string<CharT,Traits,Alloc>& lhs,

                const basic_string<CharT,Traits,Alloc>& rhs );
(3)
template<class CharT, class Traits, class Alloc >

bool operator<=(const basic_string<CharT,Traits,Alloc>& lhs,

                 const basic_string<CharT,Traits,Alloc>& rhs );
(4)
template<class CharT, class Traits, class Alloc >

bool operator>(const basic_string<CharT,Traits,Alloc>& lhs,

                const basic_string<CharT,Traits,Alloc>& rhs );
(5)
template<class CharT, class Traits, class Alloc >

bool operator>=(const basic_string<CharT,Traits,Alloc>& lhs,

                 const basic_string<CharT,Traits,Alloc>& rhs );
(6)
basic_string オブジェクトと T のNULL終端配列の比較
template<class CharT, class Traits, class Alloc >
bool operator==(const CharT* lhs, const basic_string<CharT,Traits,Alloc>& rhs );
(7)
template<class CharT, class Traits, class Alloc >
bool operator==(const basic_string<CharT,Traits,Alloc>& lhs, const CharT* rhs );
(7)
template<class CharT, class Traits, class Alloc >
bool operator!=(const CharT* lhs, const basic_string<CharT,Traits,Alloc>& rhs );
(8)
template<class CharT, class Traits, class Alloc >
bool operator!=(const basic_string<CharT,Traits,Alloc>& lhs, const CharT* rhs );
(8)
template<class CharT, class Traits, class Alloc >
bool operator<(const CharT* lhs, const basic_string<CharT,Traits,Alloc>& rhs );
(9)
template<class CharT, class Traits, class Alloc >
bool operator<(const basic_string<CharT,Traits,Alloc>& lhs,  const CharT* rhs );
(9)
template<class CharT, class Traits, class Alloc >
bool operator<=(const CharT* lhs, const basic_string<CharT,Traits,Alloc>& rhs );
(10)
template<class CharT, class Traits, class Alloc >
bool operator<=(const basic_string<CharT,Traits,Alloc>& lhs, const CharT* rhs );
(10)
template<class CharT, class Traits, class Alloc >
bool operator>(const CharT* lhs, const basic_string<CharT,Traits,Alloc>& rhs );
(11)
template<class CharT, class Traits, class Alloc >
bool operator>(const basic_string<CharT,Traits,Alloc>& lhs, const CharT* rhs );
(11)
template<class CharT, class Traits, class Alloc >
bool operator>=(const CharT* lhs, const basic_string<CharT,Traits,Alloc>& rhs );
(12)
template<class CharT, class Traits, class Alloc >
bool operator>=(const basic_string<CharT,Traits,Alloc>& lhs, const CharT* rhs );
(12)

文字列の内容を別の文字列または CharT のNULL終端配列と比較します。

すべての比較は compare() メンバ関数を通して行われます (compare() 自身は Traits::compare() によって定義されます)。

  • lhsrhs のサイズが等しく、 lhs 内のそれぞれの文字が rhs 内の同じ位置の文字と等しければ、2つの文字列は等しくなります。
1-6) 2つの basic_string オブジェクトを比較します。
7-12)basic_string オブジェクトと CharT のNULL終端配列を比較します。

目次

[編集]引数

lhs, rhs - 内容を比較する文字列

[編集]戻り値

対応する比較が成立すれば true、そうでなければ false

[編集]例外

1-6)
(なし)(C++14以前)
noexcept 指定:  
noexcept
  
(C++14およびそれ以降)
7-12) (なし)

[編集]計算量

文字列のサイズに比例。

close