operator<= (in <string>)
Dize işleci sol tarafta nesnesinin sınamaları küçük veya eşit string nesnesi için sağ tarafında olur.
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
);
Parametreler
_Left
c stilinde dize veya bir nesne türü basic_string Karşılaştırılacak._Right
c stilinde dize veya bir nesne türü basic_string Karşılaştırılacak.
Dönüş Değeri
gerçek string nesnesi işlecinin sol tarafındaki lexicographically ise sağ tarafındaki; string nesnesi küçük veya eşit Aksi halde yanlış.
Notlar
Dizeler arasında lexicographical bir karşılaştırma bunları karakter kadar karşılaştırılmaktadır:
İki karşılık gelen karakterlerle eşit olmayan bulur ve bunların karşılaştırma sonucu dizeler arasında karşılaştırma sonucu olarak alınır.
Hiçbir inequalities bulur ancak bir dize uzun dize'den küçük diğeri ve daha kısa bir dize olarak kabul edilir'den daha fazla karakter vardır.
Bulduğu yok inequalities ve dizeleri eşit şekilde dizeleri aynı sayıda karakter olan bulur.
Örnek
// string_op_le.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 = "strict";
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 less than or equal to "
<< "the string s2." << endl;
else
cout << "The string s1 is greater 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 ( s1 <= s3 )
cout << "The string s1 is less than or equal to "
<< "the string s3." << endl;
else
cout << "The string s1 is greater than "
<< "the string s3." << 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 less than or equal to "
<< "the string s3." << endl;
else
cout << "The string s2 is greater than "
<< "the string s3." << endl;
}
Gereksinimler
Başlık: <string>
Namespace: std