Namespaces
Variants

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

From cppreference.net
Regular expressions library
Classes
(C++11)
Algorithms
Iterators
Exceptions
Traits
Constants
(C++11)
Regex Grammar
std::sub_match
Member functions
Non-member functions
operator== operator!= operator<< operator<= operator> operator>= operator<=>
(until C++20) (until C++20) (until C++20) (until C++20) (until C++20) (C++20)
Défini dans l'en-tête <regex>
Comparaison directe
template < class BidirIt >

bool operator == ( const std:: sub_match < BidirIt > & lhs,

const std:: sub_match < BidirIt > & rhs ) ;
(1) (depuis C++11)
template < class BidirIt >

bool operator ! = ( const std:: sub_match < BidirIt > & lhs,

const std:: sub_match < BidirIt > & rhs ) ;
(2) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator < ( const std:: sub_match < BidirIt > & lhs,

const std:: sub_match < BidirIt > & rhs ) ;
(3) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator <= ( const std:: sub_match < BidirIt > & lhs,

const std:: sub_match < BidirIt > & rhs ) ;
(4) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator > ( const std:: sub_match < BidirIt > & lhs,

const std:: sub_match < BidirIt > & rhs ) ;
(5) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator >= ( const std:: sub_match < BidirIt > & lhs,

const std:: sub_match < BidirIt > & rhs ) ;
(6) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

auto operator <=> ( const std:: sub_match < BidirIt > & lhs,

const std:: sub_match < BidirIt > & rhs ) ;
(7) (depuis C++20)
Comparaison avec un std::basic_string
template < class BidirIt, class Traits, class Alloc >

bool operator == ( const std:: sub_match < BidirIt > & lhs,
const std:: basic_string < /*type-de-valeur-de*/ < BidirIt > ,

Traits, Alloc > & str ) ;
(8) (depuis C++11)
template < class BidirIt, class Traits, class Alloc >

bool operator ! = ( const std:: sub_match < BidirIt > & lhs,
const std:: basic_string < /*type-de-valeur-de*/ < BidirIt > ,

Traits, Alloc > & str ) ;
(9) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt, class Traits, class Alloc >

bool operator < ( const std:: sub_match < BidirIt > & lhs,
const std:: basic_string < /*type-de-valeur-de*/ < BidirIt > ,

Traits, Alloc > & str ) ;
(10) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt, class Traits, class Alloc >

bool operator <= ( const std:: sub_match < BidirIt > & lhs,
const std:: basic_string < /*type-de-valeur-de*/ < BidirIt > ,

Traits, Alloc > & str ) ;
(11) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt, class Traits, class Alloc >

bool operator > ( const std:: sub_match < BidirIt > & lhs,
const std:: basic_string < /*value-type-of*/ < BidirIt > ,

Traits, Alloc > & str ) ;
(12) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt, class Traits, class Alloc >

bool operator >= ( const std:: sub_match < BidirIt > & lhs,
const std:: basic_string < /*type-de-valeur-de*/ < BidirIt > ,

Traits, Alloc > & str ) ;
(13) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt, class Traits, class Alloc >

auto operator <=> ( const std:: sub_match < BidirIt > & lhs,
const std:: basic_string < /*type-de-valeur-de*/ < BidirIt > ,

Traits, Alloc > & str ) ;
(14) (depuis C++20)
template < class BidirIt, class Traits, class Alloc >

bool operator == ( const std:: basic_string < /*type-de-valeur-de*/ < BidirIt > ,
Traits, Alloc > & str,

const std:: sub_match < BidirIt > & rhs ) ;
(15) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt, class Traits, class Alloc >

bool operator ! = ( const std:: basic_string < /*type-de-valeur-de*/ < BidirIt > ,
Traits, Alloc > & str,

const std:: sub_match < BidirIt > & rhs ) ;
(16) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt, class Traits, class Alloc >

bool operator < ( const std:: basic_string < /*type-de-valeur-de*/ < BidirIt > ,
Traits, Alloc > & str,

const std:: sub_match < BidirIt > & rhs ) ;
(17) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt, class Traits, class Alloc >

bool operator <= ( const std:: basic_string < /*type-de-valeur-de*/ < BidirIt > ,
Traits, Alloc > & str,

const std:: sub_match < BidirIt > & rhs ) ;
(18) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt, class Traits, class Alloc >

bool operator > ( const std:: basic_string < /*type-de-valeur-de*/ < BidirIt > ,
Traits, Alloc > & str,

const std:: sub_match < BidirIt > & rhs ) ;
(19) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt, class Traits, class Alloc >

bool operator >= ( const std:: basic_string < /*type-de-valeur-de*/ < BidirIt > ,
Traits, Alloc > & str,

const std:: sub_match < BidirIt > & rhs ) ;
(20) (depuis C++11)
(jusqu'à C++20)
Comparaison avec une chaîne de style C
template < class BidirIt >

bool operator == ( const std:: sub_match < BidirIt > & lhs,

const /*type-de-valeur-de*/ < BidirIt > * s ) ;
(21) (depuis C++11)
template < class BidirIt >

bool operator ! = ( const std:: sub_match < BidirIt > & lhs,

const /*type-de-valeur-de*/ < BidirIt > * s ) ;
(22) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator < ( const std:: sub_match < BidirIt > & lhs,

const /*type-de-valeur-de*/ < BidirIt > * s ) ;
(23) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator <= ( const std:: sub_match < BidirIt > & lhs,

const /*type-de-valeur-de*/ < BidirIt > * s ) ;
(24) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator > ( const std:: sub_match < BidirIt > & lhs,

const /*type-de-valeur-de*/ < BidirIt > * s ) ;
(25) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator >= ( const std:: sub_match < BidirIt > & lhs,

const /*type-de-valeur-de*/ < BidirIt > * s ) ;
(26) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

auto operator <=> ( const std:: sub_match < BidirIt > & lhs,

const /*type-de-valeur-de*/ < BidirIt > * s ) ;
(27) (depuis C++20)
template < class BidirIt >

bool operator == ( const /*value-type-of*/ < BidirIt > * s,

const std:: sub_match < BidirIt > & rhs ) ;
(28) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator ! = ( const /*type-de-valeur-de*/ < BidirIt > * s,

const std:: sub_match < BidirIt > & rhs ) ;
(29) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator < ( const /*value-type-of*/ < BidirIt > * s,

const std:: sub_match < BidirIt > & rhs ) ;
(30) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator <= ( const /*type-de-valeur-de*/ < BidirIt > * s,

const std:: sub_match < BidirIt > & rhs ) ;
(31) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator > ( const /*type-de-valeur-de*/ < BidirIt > * s,

const std:: sub_match < BidirIt > & rhs ) ;
(32) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator >= ( const /*type-de-valeur-de*/ < BidirIt > * s,

const std:: sub_match < BidirIt > & rhs ) ;
(33) (depuis C++11)
(jusqu'à C++20)
Comparaison avec un seul caractère
template < class BidirIt >

bool operator == ( const std:: sub_match < BidirIt > & lhs,

const /*type-de-valeur-de*/ < BidirIt > & ch ) ;
(34) (depuis C++11)
template < class BidirIt >

bool operator ! = ( const std:: sub_match < BidirIt > & lhs,

const /*type-de-valeur-de*/ < BidirIt > & ch ) ;
(35) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator < ( const std:: sub_match < BidirIt > & lhs,

const /*type-de-valeur-de*/ < BidirIt > & ch ) ;
(36) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator <= ( const std:: sub_match < BidirIt > & lhs,

const /*type-de-valeur-de*/ < BidirIt > & ch ) ;
(37) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator > ( const std:: sub_match < BidirIt > & lhs,

const /*type-de-valeur-de*/ < BidirIt > & ch ) ;
(38) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator >= ( const std:: sub_match < BidirIt > & lhs,

const /*type-de-valeur-de*/ < BidirIt > & ch ) ;
(39) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

auto operator <=> ( const std:: sub_match < BidirIt > & lhs,

const /*type-de-valeur-de*/ < BidirIt > & ch ) ;
(40) (depuis C++20)
template < class BidirIt >

bool operator == ( const /*value-type-of*/ < BidirIt > & ch,

const std:: sub_match < BidirIt > & rhs ) ;
(41) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator ! = ( const /*type-de-valeur-de*/ < BidirIt > & ch,

const std:: sub_match < BidirIt > & rhs ) ;
(42) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator < ( const /*type-de-valeur-de*/ < BidirIt > & ch,

const std:: sub_match < BidirIt > & rhs ) ;
(43) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator <= ( const /*type-de-valeur-de*/ < BidirIt > & ch,

const std:: sub_match < BidirIt > & rhs ) ;
(44) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator > ( const /*type-de-valeur-de*/ < BidirIt > & ch,

const std:: sub_match < BidirIt > & rhs ) ;
(45) (depuis C++11)
(jusqu'à C++20)
template < class BidirIt >

bool operator >= ( const /*type-de-valeur-de*/ < BidirIt > & ch,

const std:: sub_match < BidirIt > & rhs ) ;
(46) (depuis C++11)
(jusqu'à C++20)
Alias de types d'assistance
template < class BidirIt >

using /*type-de-valeur-de*/ =

typename std:: iterator_traits < BidirIt > :: value_type ;
(47) ( exposition uniquement* )
template < class BidirIt >

using /*cat-type-of*/ =
std:: compare_three_way_result_t

< std:: basic_string < /*value-type-of*/ < BidirIt >>> ;
(48) (depuis C++20)
( exposition uniquement* )

Compare un sub_match à un autre sub_match , à une std::string , à une chaîne de style C ou à un caractère unique.

1-7) Compare directement deux sub_match .
8-20) Compare un sub_match avec une std::basic_string .
21-33) Compare un sub_match avec une chaîne de caractères de style C.
34-46) Compare un sub_match avec un caractère unique.

Les opérateurs < , <= , > , >= , et != sont synthétisés à partir de operator <=> et operator == respectivement.

(depuis C++20)
47) value-type-of  < BidirIt > est le type de valeur de BidirIt .
48) cat-type-of  < BidirIt > est le type résultant de la comparaison à trois voies de std:: sub_match < BidirIt > .

Table des matières

Paramètres

lhs, rhs - un sub_match à comparer
str - une std::basic_string à comparer
s - un pointeur vers une chaîne de style C à comparer
ch - un caractère à comparer

Valeur de retour

Soit target les valeurs suivantes :

1-7) rhs
8-20) typename std:: sub_match < BidirIt > :: string_type ( str. data ( ) , str. size ( ) )
21-33) s
34-46) typename std:: sub_match < BidirIt > :: string_type ( 1 , ch )

Les valeurs de retour sont définies comme suit :

Opérateur Valeur de retour
Surcharges (1-14,21-27,34-40)
(surcharges avec paramètre lhs )
Surcharges (15-20,28-33,41-46)
(surcharges sans paramètre lhs )
== lhs. compare ( target ) == 0 rhs. compare ( target ) == 0
!= lhs. compare ( target ) ! = 0 rhs. compare ( target ) ! = 0
< lhs. compare ( target ) < 0 rhs. compare ( target ) > 0
<= lhs. compare ( target ) <= 0 rhs. compare ( target ) >= 0
> lhs. compare ( target ) > 0 rhs. compare ( target ) < 0
>= lhs. compare ( target ) >= 0 rhs. compare ( target ) <= 0
<=> static_cast < cat-type-of  < BidirIt >>
( lhs. compare ( target ) <=> 0 )
N/A

Notes

Le type de retour de operator <=> est garanti d'être un type de catégorie de comparaison. Si value-type-of  < BidirIt > est char , wchar_t , char8_t , char16_t , ou char32_t , le type de retour de operator<=> est std::strong_ordering .

Exemple

Rapports de défauts

Les rapports de défauts modifiant le comportement suivants ont été appliqués rétroactivement aux normes C++ précédemment publiées.

DR Applicable à Comportement publié Comportement corrigé
LWG 2217 C++11 pour les comparaisons avec std::string , l'argument de
compare() était str. c_str ( )
l'argument est
string_type ( str. data ( ) , str. size ( ) ) )

Voir aussi

compare la sous-séquence correspondante (si elle existe)
(fonction membre publique)