operator==,!=,<,<=,>,>=,<=>(std::basic_string)
| Definiert in Header <string>
|
||
| Vergleiche zwei basic_string Objekte |
||
template< class CharT, class Traits, class Alloc >
bool operator==( const std::basic_string<CharT,Traits,Alloc>& lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(1) | (noexcept seit C++11) (constexpr seit C++20) |
template< class CharT, class Traits, class Alloc >
bool operator!=( const std::basic_string<CharT,Traits,Alloc>& lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(2) | (bis C++20) (noexcept seit C++11) |
template< class CharT, class Traits, class Alloc >
bool operator<( const std::basic_string<CharT,Traits,Alloc>& lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(3) | (bis C++20) (noexcept seit C++11) |
template< class CharT, class Traits, class Alloc >
bool operator<=( const std::basic_string<CharT,Traits,Alloc>& lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(4) | (bis C++20) (noexcept seit C++11) |
template< class CharT, class Traits, class Alloc >
bool operator>( const std::basic_string<CharT,Traits,Alloc>& lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(5) | (bis C++20) (noexcept seit C++11) |
template< class CharT, class Traits, class Alloc >
bool operator>=( const std::basic_string<CharT,Traits,Alloc>& lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(6) | (bis C++20) (noexcept seit C++11) |
template< class CharT, class Traits, class Alloc >
constexpr /*comp-cat*/
operator<=>( const std::basic_string<CharT,Traits,Alloc>& lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs ) noexcept;
|
(7) | (seit C++20) |
| Vergleiche ein basic_string Objekt und ein nullterminiertes Array von T |
||
template< class CharT, class Traits, class Alloc >
bool operator==( const std::basic_string<CharT,Traits,Alloc>& lhs,
const CharT* rhs );
|
(8) | (constexpr seit C++20) |
template< class CharT, class Traits, class Alloc >
bool operator==( const CharT* lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(9) | (bis C++20) |
template< class CharT, class Traits, class Alloc >
bool operator!=( const std::basic_string<CharT,Traits,Alloc>& lhs,
const CharT* rhs );
|
(10) | (bis C++20) |
template< class CharT, class Traits, class Alloc >
bool operator!=( const CharT* lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(11) | (bis C++20) |
template< class CharT, class Traits, class Alloc >
bool operator<( const std::basic_string<CharT,Traits,Alloc>& lhs,
const CharT* rhs );
|
(12) | (bis C++20) |
template< class CharT, class Traits, class Alloc >
bool operator<( const CharT* lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(13) | (bis C++20) |
template< class CharT, class Traits, class Alloc >
bool operator<=( const std::basic_string<CharT,Traits,Alloc>& lhs,
const CharT* rhs );
|
(14) | (bis C++20) |
template< class CharT, class Traits, class Alloc >
bool operator<=( const CharT* lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(15) | (bis C++20) |
template< class CharT, class Traits, class Alloc >
bool operator>( const std::basic_string<CharT,Traits,Alloc>& lhs,
const CharT* rhs );
|
(16) | (bis C++20) |
template< class CharT, class Traits, class Alloc >
bool operator>( const CharT* lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(17) | (bis C++20) |
template< class CharT, class Traits, class Alloc >
bool operator>=( const std::basic_string<CharT,Traits,Alloc>& lhs,
const CharT* rhs );
|
(18) | (bis C++20) |
template< class CharT, class Traits, class Alloc >
bool operator>=( const CharT* lhs,
const std::basic_string<CharT,Traits,Alloc>& rhs );
|
(19) | (bis C++20) |
template< class CharT, class Traits, class Alloc >
constexpr /*comp-cat*/
operator<=>( const std::basic_string<CharT,Traits,Alloc>& lhs,
const CharT* rhs );
|
(20) | (seit C++20) |
Vergleicht den Inhalt einer Zeichenkette mit einer anderen Zeichenkette oder einem nullterminierten Array von CharT.
Alle Vergleiche werden über die compare()-Mitgliedsfunktion durchgeführt (die selbst mittels Traits::compare() definiert ist):
- Zwei Zeichenketten sind gleich, wenn sowohl die Größe von
lhsals auchrhsgleich sind und jedes Zeichen inlhsein entsprechendes Zeichen inrhsan derselben Position hat.
- Die Ordnungsvergleiche werden lexikografisch durchgeführt – Der Vergleich wird durch eine Funktion durchgeführt, die äquivalent zu std::lexicographical_compareoder std::lexicographical_compare_three_way(seit C++20) ist.
basic_string Objekte.basic_string Objekt und ein nullterminiertes Array von CharT.|
Der Rückgabetyp des Dreivei-Vergleichsoperators ( Die Operatoren |
(seit C++20) |
Parameter
| lhs, rhs | - | Zeichenketten, deren Inhalte verglichen werden sollen |
Rückgabewert
Komplexität
Linear in der Größe der Strings.
Hinweise
|
Wenn mindestens ein Parameter vom Typ
std::string
,
std::wstring
,
std::u8string
,
std::u16string
oder
std::u32string
ist, ist der Rückgabetyp von
|
(since C++20) |
Beispiel
|
Dieser Abschnitt ist unvollständig
Grund: Kein Beispiel |
Fehlerberichte
Die folgenden verhaltensändernden Fehlerberichte wurden rückwirkend auf zuvor veröffentlichte C++-Standards angewendet.
| DR | Angewendet auf | Verhalten wie veröffentlicht | Korrigiertes Verhalten |
|---|---|---|---|
| LWG 2064 | C++11 |
ob Überladungen mit zwei
basic_string
s noexcept sind, war inkonsistent;
Überladungen mit einem
CharT*
waren noexcept, konnten aber UB auslösen
|
konsistent gemacht;
noexcept entfernt |
| LWG 3432 | C++20 |
der Rückgabetyp von
operator<=>
musste kein Vergleichskategorietyp sein
|
erforderlich gemacht |