operator==,!=,<,<=,>,>=(std::basic_string) (3) - Linux Manuals

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

NAME

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

Synopsis


Compare two basic_string objects
template< class CharT, class Traits, class Alloc >
bool operator==( const basic_string<CharT,Traits,Alloc>& lhs, (1)
const basic_string<CharT,Traits,Alloc>& rhs );
template< class CharT, class Traits, class Alloc >
bool operator!=( const basic_string<CharT,Traits,Alloc>& lhs, (2)
const basic_string<CharT,Traits,Alloc>& rhs );
template< class CharT, class Traits, class Alloc >
bool operator<( const basic_string<CharT,Traits,Alloc>& lhs, (3)
const basic_string<CharT,Traits,Alloc>& rhs );
template< class CharT, class Traits, class Alloc >
bool operator<=( const basic_string<CharT,Traits,Alloc>& lhs, (4)
const basic_string<CharT,Traits,Alloc>& rhs );
template< class CharT, class Traits, class Alloc >
bool operator>( const basic_string<CharT,Traits,Alloc>& lhs, (5)
const basic_string<CharT,Traits,Alloc>& rhs );
template< class CharT, class Traits, class Alloc >
bool operator>=( const basic_string<CharT,Traits,Alloc>& lhs, (6)
const basic_string<CharT,Traits,Alloc>& rhs );
Compare a basic_string object and null-terminated array of T
template< class CharT, class Traits, class Alloc > (7)
bool operator==( const CharT* lhs, const basic_string<CharT,Traits,Alloc>& rhs );
template< class CharT, class Traits, class Alloc > (7)
bool operator==( const basic_string<CharT,Traits,Alloc>& lhs, const CharT* rhs );
template< class CharT, class Traits, class Alloc > (8)
bool operator!=( const CharT* lhs, const basic_string<CharT,Traits,Alloc>& rhs );
template< class CharT, class Traits, class Alloc > (8)
bool operator!=( const basic_string<CharT,Traits,Alloc>& lhs, const CharT* rhs );
template< class CharT, class Traits, class Alloc > (9)
bool operator<( const CharT* lhs, const basic_string<CharT,Traits,Alloc>& rhs );
template< class CharT, class Traits, class Alloc > (9)
bool operator<( const basic_string<CharT,Traits,Alloc>& lhs, const CharT* rhs );
template< class CharT, class Traits, class Alloc > (10)
bool operator<=( const CharT* lhs, const basic_string<CharT,Traits,Alloc>& rhs );
template< class CharT, class Traits, class Alloc > (10)
bool operator<=( const basic_string<CharT,Traits,Alloc>& lhs, const CharT* rhs );
template< class CharT, class Traits, class Alloc > (11)
bool operator>( const CharT* lhs, const basic_string<CharT,Traits,Alloc>& rhs );
template< class CharT, class Traits, class Alloc > (11)
bool operator>( const basic_string<CharT,Traits,Alloc>& lhs, const CharT* rhs );
template< class CharT, class Traits, class Alloc > (12)
bool operator>=( const CharT* lhs, const basic_string<CharT,Traits,Alloc>& rhs );
template< class CharT, class Traits, class Alloc > (12)
bool operator>=( const basic_string<CharT,Traits,Alloc>& lhs, const CharT* rhs );


Compares the contents of a string with another string or a null-terminated array of CharT.
All comparisons are done via the compare() member function (which itself is defined in terms of Traits::compare()):


* Two strings are equal if both the size of lhs and rhs are equal and each character in lhs has equivalent character in rhs at the same position.


* The ordering comparisons are done lexicographically -- the comparison is performed by a function equivalent to std::lexicographical_compare.


1-6) Compares two basic_string objects.
7-12) Compares a basic_string object and a null-terminated array of CharT.

Parameters


lhs, rhs - strings whose contents to compare

Return value


true if the corresponding comparison holds, false otherwise.

Exceptions


1-6)


(none) (until C++14)
noexcept specification: (since C++14)
noexcept


7-12) (none)

Complexity


Linear in the size of the strings.