operator>= (<string>)

演算子の左側の文字列オブジェクトが右側の文字列オブジェクトの値以上でテスト。

template<class CharType, class Traits, class Allocator>
   bool operator>=(
      const basic_string<CharType, Traits, Allocator>& _Left,
      const basic_string<CharType, Traits, Allocator>& _Right
   );
template<class CharType, class Traits, class Allocator>
   bool operator>=(
      const basic_string<CharType, Traits, Allocator>& _Left,
      const CharType *_Right
   );
template<class CharType, class Traits, class Allocator>
   bool operator>=(
      const CharType *_Left,
      const basic_string<CharType, Traits, Allocator>& _Right
   );

パラメーター

  • _Left
    basic_string における. の式の文字列を比較するオブジェクト。

  • _Right
    basic_string における. の式の文字列を比較するオブジェクト。

戻り値

演算子の左側の文字列オブジェクトが右側の文字列オブジェクトに辞書式に値以上でtrue ; それ false

解説

文字列間の辞書式の比較は文字でその文字までと比較しています:

  • これは等しくない対応する 2 文字を検索し、比較の結果は、文字列間で比較の結果取得されます。

  • これは非等値を検索しませんが、1 文字列を他よりも多くの文字があり、短い文字列に長い文字列未満であると見なされます。

  • これは非等値が見つからないため、文字列を持つ文字の数、および検索して、文字列は同等です。

使用例

// string_op_ge.cpp
// compile with: /EHsc
#include <string>
#include <iostream>

int main( ) 
{
   using namespace std;

   // Declaring an objects of type basic_string<char>
   string s1 ( "strict" );
   string s2 ( "strum" );
   cout << "The basic_string s1 = " << s1 << "." << endl;
   cout << "The basic_string s2 = " << s2 << "." << endl;

   // Declaring a C-style string
   char *s3 = "stricture";
   cout << "The C-style string s3 = " << s3 << "." << endl;

   // First member function: comparison between left-side object
   // of type basic_string & right-side object of type basic_string
   if ( s1 >= s2 )
      cout << "The string s1 is greater than or equal to "
           << "the string s2." << endl;
   else
      cout << "The string s1 is less than "
           << "the string s2." << endl;

   // Second member function: comparison between left-side object
   // of type basic_string & right-side object of C-syle string type
   if ( s3 >= s1 )
      cout << "The string s3 is greater than or equal to "
           << "the string s1." << endl;
   else
      cout << "The string s3 is less than "
           << "the string s1." << endl;

   // Third member function: comparison between left-side object
   // of C-syle string type & right-side object of type basic_string
   if ( s2 >= s3 )
      cout << "The string s2 is greater than or equal to "
           << "the string s3." << endl;
   else
      cout << "The string s2 is less than "
           << "the string s3." << endl;
}
  
  
  
  
  
  

必要条件

ヘッダー: <string>

名前空間: std

参照

関連項目

string::operator>=