Compare two basic_string objects
template<classCharT,classTraits,classAlloc>booloperator==(conststd::basic_string<CharT,Traits,Alloc>&lhs,conststd::basic_string<CharT,Traits,Alloc>&rhs); (1) (noexcept since C++11)
(constexpr since C++20)template<classCharT,classTraits,classAlloc>booloperator!=(conststd::basic_string<CharT,Traits,Alloc>&lhs,conststd::basic_string<CharT,Traits,Alloc>&rhs); (2) (until C++20)
(noexcept since C++11)template<classCharT,classTraits,classAlloc>booloperator<(conststd::basic_string<CharT,Traits,Alloc>&lhs,conststd::basic_string<CharT,Traits,Alloc>&rhs); (3) (until C++20)
(noexcept since C++11)template<classCharT,classTraits,classAlloc>booloperator<=(conststd::basic_string<CharT,Traits,Alloc>&lhs,conststd::basic_string<CharT,Traits,Alloc>&rhs); (4) (until C++20)
(noexcept since C++11)template<classCharT,classTraits,classAlloc>booloperator>(conststd::basic_string<CharT,Traits,Alloc>&lhs,conststd::basic_string<CharT,Traits,Alloc>&rhs); (5) (until C++20)
(noexcept since C++11)template<classCharT,classTraits,classAlloc>booloperator>=(conststd::basic_string<CharT,Traits,Alloc>&lhs,conststd::basic_string<CharT,Traits,Alloc>&rhs); (6) (until C++20)
(noexcept since C++11)template<classCharT,classTraits,classAlloc>constexpr/*comp-cat*/operator<=>(conststd::basic_string<CharT,Traits,Alloc>&lhs,conststd::basic_string<CharT,Traits,Alloc>&rhs)noexcept; (7) (since C++20)Compare a basic_string object and null-terminated array of T
template<classCharT,classTraits,classAlloc>booloperator==(conststd::basic_string<CharT,Traits,Alloc>&lhs,constCharT*rhs); (8) (constexpr since C++20)template<classCharT,classTraits,classAlloc>booloperator==(constCharT*lhs,conststd::basic_string<CharT,Traits,Alloc>&rhs); (9) (until C++20)template<classCharT,classTraits,classAlloc>booloperator!=(conststd::basic_string<CharT,Traits,Alloc>&lhs,constCharT*rhs); (10) (until C++20)template<classCharT,classTraits,classAlloc>booloperator!=(constCharT*lhs,conststd::basic_string<CharT,Traits,Alloc>&rhs); (11) (until C++20)template<classCharT,classTraits,classAlloc>booloperator<(conststd::basic_string<CharT,Traits,Alloc>&lhs,constCharT*rhs); (12) (until C++20)template<classCharT,classTraits,classAlloc>booloperator<(constCharT*lhs,conststd::basic_string<CharT,Traits,Alloc>&rhs); (13) (until C++20)template<classCharT,classTraits,classAlloc>booloperator<=(conststd::basic_string<CharT,Traits,Alloc>&lhs,constCharT*rhs); (14) (until C++20)template<classCharT,classTraits,classAlloc>booloperator<=(constCharT*lhs,conststd::basic_string<CharT,Traits,Alloc>&rhs); (15) (until C++20)template<classCharT,classTraits,classAlloc>booloperator>(conststd::basic_string<CharT,Traits,Alloc>&lhs,constCharT*rhs); (16) (until C++20)template<classCharT,classTraits,classAlloc>booloperator>(constCharT*lhs,conststd::basic_string<CharT,Traits,Alloc>&rhs); (17) (until C++20)template<classCharT,classTraits,classAlloc>booloperator>=(conststd::basic_string<CharT,Traits,Alloc>&lhs,constCharT*rhs); (18) (until C++20)template<classCharT,classTraits,classAlloc>booloperator>=(constCharT*lhs,conststd::basic_string<CharT,Traits,Alloc>&rhs); (19) (until C++20)template<classCharT,classTraits,classAlloc>constexpr/*comp-cat*/operator<=>(conststd::basic_string<CharT,Traits,Alloc>&lhs,constCharT*rhs); (20) (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
member function (which itself is defined in terms of Traits::compare()):
1-7) Compares two basic_string objects.
8-20) Compares a basic_string object and a null-terminated array of CharT.
1-6,8-19)true if the corresponding comparison holds, false otherwise.
7,20)static_cast</*comp-cat*/>(lhs.compare(rhs)<=>0).
Linear in the size of the strings.
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.