operator==,!=,<,<=,>,>=,<=>(std::basic_string)
| Defined in header <string>
|
||
| Compare two basic_string objects |
||
| (1) | ||
| template< class CharT, class Traits, class Alloc > bool operator==( const std::basic_string<CharT,Traits,Alloc>& lhs, |
(until C++14) | |
| template< class CharT, class Traits, class Alloc > bool operator==( const std::basic_string<CharT,Traits,Alloc>& lhs, |
(since C++14) (until C++20) |
|
| template< class CharT, class Traits, class Alloc > constexpr bool |
(since C++20) | |
| (2) | ||
| template< class CharT, class Traits, class Alloc > bool operator!=( const std::basic_string<CharT,Traits,Alloc>& lhs, |
(until C++14) | |
| template< class CharT, class Traits, class Alloc > bool operator!=( const std::basic_string<CharT,Traits,Alloc>& lhs, |
(since C++14) (until C++20) |
|
| (3) | ||
| template< class CharT, class Traits, class Alloc > bool operator<( const std::basic_string<CharT,Traits,Alloc>& lhs, |
(until C++14) | |
| template< class CharT, class Traits, class Alloc > bool operator<( const std::basic_string<CharT,Traits,Alloc>& lhs, |
(since C++14) (until C++20) |
|
| (4) | ||
| template< class CharT, class Traits, class Alloc > bool operator>=( const std::basic_string<CharT,Traits,Alloc>& lhs, |
(until C++14) | |
| template< class CharT, class Traits, class Alloc > bool operator>=( const std::basic_string<CharT,Traits,Alloc>& lhs, |
(since C++14) (until C++20) |
|
| (5) | ||
| template< class CharT, class Traits, class Alloc > bool operator>( const std::basic_string<CharT,Traits,Alloc>& lhs, |
(until C++14) | |
| template< class CharT, class Traits, class Alloc > bool operator>( const std::basic_string<CharT,Traits,Alloc>& lhs, |
(since C++14) (until C++20) |
|
| (6) | ||
| template< class CharT, class Traits, class Alloc > bool operator>=( const std::basic_string<CharT,Traits,Alloc>& lhs, |
(until C++14) | |
| template< class CharT, class Traits, class Alloc > bool operator>=( const std::basic_string<CharT,Traits,Alloc>& lhs, |
(since C++14) (until C++20) |
|
| template< class CharT, class Traits, class Alloc > constexpr /*comp-cat*/ |
(7) | (since C++20) |
| Compare a basic_string object and null-terminated array of T |
||
| (8) | ||
| template< class CharT, class Traits, class Alloc > bool operator==( const std::basic_string<CharT,Traits,Alloc>& lhs, |
(until C++20) | |
| template< class CharT, class Traits, class Alloc > constexpr bool operator==( const std::basic_string<CharT,Traits,Alloc>& lhs, |
(since C++20) | |
| template< class CharT, class Traits, class Alloc > bool operator==( const CharT* lhs, |
(until C++20) | |
| (9) | ||
| template< class CharT, class Traits, class Alloc > bool operator!=( const std::basic_string<CharT,Traits,Alloc>& lhs, |
(until C++20) | |
| template< class CharT, class Traits, class Alloc > bool operator!=( const CharT* lhs, |
(until C++20) | |
| (10) | ||
| template< class CharT, class Traits, class Alloc > bool operator<( const std::basic_string<CharT,Traits,Alloc>& lhs, |
(until C++20) | |
| template< class CharT, class Traits, class Alloc > bool operator<( const CharT* lhs, |
(until C++20) | |
| (11) | ||
| template< class CharT, class Traits, class Alloc > bool operator<=( const std::basic_string<CharT,Traits,Alloc>& lhs, |
(until C++20) | |
| template< class CharT, class Traits, class Alloc > bool operator<=( const CharT* lhs, |
(until C++20) | |
| (12) | ||
| template< class CharT, class Traits, class Alloc > bool operator>( const std::basic_string<CharT,Traits,Alloc>& lhs, |
(until C++20) | |
| template< class CharT, class Traits, class Alloc > bool operator>( const CharT* lhs, |
(until C++20) | |
| (13) | ||
| template< class CharT, class Traits, class Alloc > bool operator>=( const std::basic_string<CharT,Traits,Alloc>& lhs, |
(until C++20) | |
| template< class CharT, class Traits, class Alloc > bool operator>=( const CharT* lhs, |
(until C++20) | |
| template< class CharT, class Traits, class Alloc > constexpr /*comp-cat*/ |
(14) | (since C++20) |
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
lhsandrhsare equal and each character inlhshas equivalent character inrhsat the same position.
- The ordering comparisons are done lexicographically -- the comparison is performed by a function equivalent to std::lexicographical_compare or std::lexicographical_compare_three_way (since C++20).
|
The return type of three-way comparison operators (/*comp-cat*/) is Traits::comparison_category if it exists, std::weak_ordering otherwise. |
(since C++20) |
basic_string objects.basic_string object and a null-terminated array of CharT.Parameters
| lhs, rhs | - | strings whose contents to compare |
Return value
Complexity
Linear in the size of the strings.
Notes
|
If at least one parameter is of type std::string, std::wstring, std::u8string, std::u16string, or std::u32string, the return type of |
(since C++20) |