Operatori <regex>
operator!=
operator>
operator>=
operator<
operator<<
operator<=
operator==
operator!=
Confronto non uguale tra vari oggetti.
template <class BidIt>
bool operator!=(const sub_match<BidIt>& left,
const sub_match<BidIt>& right);
template <class BidIt, class IOtraits, class Alloc>
bool operator!=(
const basic_string<typename iterator_traits<BidIt>::value_type, IOtraits, Alloc>& left,
const sub_match<BidIt>& right);
template <class BidIt, class IOtraits, class Alloc>
bool operator!=(const sub_match<BidIt>& left,
const basic_string<typename iterator_traits<BidIt>::value_type, IOtraits, Alloc>& right);
template <class BidIt>
bool operator!=(const typename iterator_traits<BidIt>::value_type *left,
const sub_match<BidIt>& right);
template <class BidIt>
bool operator!=(const sub_match<BidIt>& left,
const typename iterator_traits<BidIt>::value_type *right);
template <class BidIt>
bool operator!=(const typename iterator_traits<BidIt>::value_type& left,
const sub_match<BidIt>& right);
template <class BidIt>
bool operator!=(const sub_match<BidIt>& left,
const typename iterator_traits<BidIt>::value_type& right);
template <class BidIt, class Alloc>
bool operator!=(const match_results<BidIt, Alloc>& left,
const match_results<BidIt, Alloc>& right);
Parametri
BidIt
Tipo di iteratore.
IOtraits
Classe traits della stringa.
Alloc
Classe Allocator.
left
Oggetto a sinistra da confrontare.
right
Oggetto a destra da confrontare.
Osservazioni:
Ciascun operatore modello restituisce !(left == right)
.
Esempio
// std__regex__operator_ne.cpp
// compile with: /EHsc
#include <regex>
#include <iostream>
typedef std::cmatch::string_type Mystr;
int main()
{
std::regex rx("c(a*)|(b)");
std::cmatch mr;
std::regex_search("xcaaay", mr, rx);
std::csub_match sub = mr[1];
std::cout << "match == " << mr.str() << std::endl;
std::cout << "sub == " << sub << std::endl;
std::cout << std::endl;
std::cout << "match != match == " << std::boolalpha
<< (mr != mr) << std::endl;
std::cout << "sub != sub == " << std::boolalpha
<< (sub != sub) << std::endl;
std::cout << "string(\"aab\") != sub == " << std::boolalpha
<< (Mystr("aab") != sub) << std::endl;
std::cout << "sub != string(\"aab\") == " << std::boolalpha
<< (sub != Mystr("aab")) << std::endl;
std::cout << "\"aab\" != sub == " << std::boolalpha
<< ("aab" != sub) << std::endl;
std::cout << "sub != \"aab\" == " << std::boolalpha
<< (sub != "aab") << std::endl;
std::cout << "'a' != sub == " << std::boolalpha
<< ('a' != sub) << std::endl;
std::cout << "sub != 'a' == " << std::boolalpha
<< (sub != 'a') << std::endl;
return (0);
}
match == caaa
sub == aaa
match != match == false
sub != sub == false
string("aab") != sub == true
sub != string("aab") == true
"aab" != sub == true
sub != "aab" == true
'a' != sub == true
sub != 'a' == true
operator<
Confronto minore di tra vari oggetti.
template <class BidIt>
bool operator<(const sub_match<BidIt>& left,
const sub_match<BidIt>& right);
template <class BidIt, class IOtraits, class Alloc>
bool operator<(
const basic_string<typename iterator_traits<BidIt>::value_type, IOtraits, Alloc>& left,
const sub_match<BidIt>& right);
template <class BidIt, class IOtraits, class Alloc>
bool operator<(const sub_match<BidIt>& left,
const basic_string<typename iterator_traits<BidIt>::value_type, IOtraits, Alloc>& right);
template <class BidIt>
bool operator<(const typename iterator_traits<BidIt>::value_type *left,
const sub_match<BidIt>& right);
template <class BidIt>
bool operator<(const sub_match<BidIt>& left,
const typename iterator_traits<BidIt>::value_type *right);
template <class BidIt>
bool operator<(const typename iterator_traits<BidIt>::value_type& left,
const sub_match<BidIt>& right);
template <class BidIt>
bool operator<(const sub_match<BidIt>& left,
const typename iterator_traits<BidIt>::value_type& right);
Parametri
BidIt
Tipo di iteratore.
IOtraits
Classe traits della stringa.
Alloc
Classe Allocator.
left
Oggetto a sinistra da confrontare.
right
Oggetto a destra da confrontare.
Osservazioni:
Ogni operatore modello converte gli argomenti in un tipo stringa e restituisce true solo se il valore convertito di sinistra confronta meno del valore convertito di destra.
Esempio
// std__regex__operator_lt.cpp
// compile with: /EHsc
#include <regex>
#include <iostream>
typedef std::cmatch::string_type Mystr;
int main()
{
std::regex rx("c(a*)|(b)");
std::cmatch mr;
std::regex_search("xcaaay", mr, rx);
std::csub_match sub = mr[1];
std::cout << "sub == " << sub << std::endl;
std::cout << std::endl;
std::cout << "sub < sub == " << std::boolalpha
<< (sub < sub) << std::endl;
std::cout << "string(\"aab\") < sub == " << std::boolalpha
<< (Mystr("aab") < sub) << std::endl;
std::cout << "sub < string(\"aab\") == " << std::boolalpha
<< (sub < Mystr("aab")) << std::endl;
std::cout << "\"aab\" < sub == " << std::boolalpha
<< ("aab" < sub) << std::endl;
std::cout << "sub < \"aab\" == " << std::boolalpha
<< (sub < "aab") << std::endl;
std::cout << "'a' < sub == " << std::boolalpha
<< ('a' < sub) << std::endl;
std::cout << "sub < 'a' == " << std::boolalpha
<< (sub < 'a') << std::endl;
return (0);
}
sub == aaa
sub < sub == false
string("aab") < sub == false
sub < string("aab") == true
"aab" < sub == false
sub < "aab" == true
'a' < sub == true
sub < 'a' == false
operator<<
Inserisce un oggetto sub_match in un flusso.
template <class Elem, class IOtraits, class Alloc, class BidIt>
basic_ostream<Elem, IOtraits>& operator<<(basic_ostream<Elem, IOtraits>& os,
const sub_match<BidIt>& right);
Parametri
Elem
Tipo dell'elemento.
IOtraits
Classe traits della stringa.
Alloc
Classe Allocator.
BidIt
Tipo di iteratore.
sistema operativo
Flusso di output.
right
Oggetto da inserire.
Osservazioni:
L'operatore modello restituisce os << right.str()
.
Esempio
// std__regex__operator_ins.cpp
// compile with: /EHsc
#include <regex>
#include <iostream>
int main()
{
std::regex rx("c(a*)|(b)");
std::cmatch mr;
std::regex_search("xcaaay", mr, rx);
std::csub_match sub = mr[0];
std::cout << "whole match: " << sub << std::endl;
return (0);
}
whole match: caaa
operator<=
Confronto minore di o uguale tra vari oggetti.
template <class BidIt>
bool operator<=(const sub_match<BidIt>& left,
const sub_match<BidIt>& right);
template <class BidIt, class IOtraits, class Alloc>
bool operator<=(
const basic_string<typename iterator_traits<BidIt>::value_type, IOtraits, Alloc>& left,
const sub_match<BidIt>& right);
template <class BidIt, class IOtraits, class Alloc>
bool operator<=(const sub_match<BidIt>& left,
const basic_string<typename iterator_traits<BidIt>::value_type, IOtraits, Alloc>& right);
template <class BidIt>
bool operator<=(const typename iterator_traits<BidIt>::value_type *left,
const sub_match<BidIt>& right);
template <class BidIt>
bool operator<=(const sub_match<BidIt>& left,
const typename iterator_traits<BidIt>::value_type *right);
template <class BidIt>
bool operator<=(const typename iterator_traits<BidIt>::value_type& left,
const sub_match<BidIt>& right);
template <class BidIt>
bool operator<=(const sub_match<BidIt>& left,
const typename iterator_traits<BidIt>::value_type& right);
Parametri
BidIt
Tipo di iteratore.
IOtraits
Classe traits della stringa.
Alloc
Classe Allocator.
left
Oggetto a sinistra da confrontare.
right
Oggetto a destra da confrontare.
Osservazioni:
Ciascun operatore modello restituisce !(right < left)
.
Esempio
// std__regex__operator_le.cpp
// compile with: /EHsc
#include <regex>
#include <iostream>
typedef std::cmatch::string_type Mystr;
int main()
{
std::regex rx("c(a*)|(b)");
std::cmatch mr;
std::regex_search("xcaaay", mr, rx);
std::csub_match sub = mr[1];
std::cout << "sub == " << sub << std::endl;
std::cout << std::endl;
std::cout << "sub <= sub == " << std::boolalpha
<< (sub <= sub) << std::endl;
std::cout << "string(\"aab\") <= sub == " << std::boolalpha
<< (Mystr("aab") <= sub) << std::endl;
std::cout << "sub <= string(\"aab\") == " << std::boolalpha
<< (sub <= Mystr("aab")) << std::endl;
std::cout << "\"aab\" <= sub == " << std::boolalpha
<< ("aab" <= sub) << std::endl;
std::cout << "sub <= \"aab\" == " << std::boolalpha
<< (sub <= "aab") << std::endl;
std::cout << "'a' <= sub == " << std::boolalpha
<< ('a' <= sub) << std::endl;
std::cout << "sub <= 'a' == " << std::boolalpha
<< (sub <= 'a') << std::endl;
return (0);
}
sub == aaa
sub <= sub == true
string("aab") <= sub == false
sub <= string("aab") == true
"aab" <= sub == false
sub <= "aab" == true
'a' <= sub == true
sub <= 'a' == false
operator==
Confronto uguale tra vari oggetti.
template <class BidIt>
bool operator==(const sub_match<BidIt>& left,
const sub_match<BidIt>& right);
template <class BidIt, class IOtraits, class Alloc>
bool operator==(
const basic_string<typename iterator_traits<BidIt>::value_type, IOtraits, Alloc>& left,
const sub_match<BidIt>& right);
template <class BidIt, class IOtraits, class Alloc>
bool operator==(const sub_match<BidIt>& left,
const basic_string<typename iterator_traits<BidIt>::value_type, IOtraits, Alloc>& right);
template <class BidIt>
bool operator==(const typename iterator_traits<BidIt>::value_type* left,
const sub_match<BidIt>& right);
template <class BidIt>
bool operator==(const sub_match<BidIt>& left,
const typename iterator_traits<BidIt>::value_type* right);
template <class BidIt>
bool operator==(const typename iterator_traits<BidIt>::value_type& left,
const sub_match<BidIt>& right);
template <class BidIt>
bool operator==(const sub_match<BidIt>& left,
const typename iterator_traits<BidIt>::value_type& right);
template <class BidIt, class Alloc>
bool operator==(const match_results<BidIt, Alloc>& left,
const match_results<BidIt, Alloc>& right);
Parametri
BidIt
Tipo di iteratore.
IOtraits
Classe traits della stringa.
Alloc
Classe Allocator.
left
Oggetto a sinistra da confrontare.
right
Oggetto a destra da confrontare.
Osservazioni:
Ciascun operatore modello converte ciascun argomento in un tipo stringa e restituisce il risultato del confronto tra gli oggetti convertiti per verificarne l'uguaglianza.
Quando un operatore modello converte gli argomenti in un tipo stringa, usa la prima trasformazione applicabile tra quelle seguenti:
argomenti i cui tipi sono una specializzazione del modello match_results
di classe o sub_match
vengono convertiti chiamando la str
funzione membro;
argomenti i cui tipi sono una specializzazione del modello basic_string
di classe sono invariati;
tutti gli altri tipi di argomento vengono convertiti passando il valore dell'argomento al costruttore per una specializzazione appropriata del modello basic_string
di classe .
Esempio
// std__regex__operator_eq.cpp
// compile with: /EHsc
#include <regex>
#include <iostream>
typedef std::cmatch::string_type Mystr;
int main()
{
std::regex rx("c(a*)|(b)");
std::cmatch mr;
std::regex_search("xcaaay", mr, rx);
std::csub_match sub = mr[1];
std::cout << "match == " << mr.str() << std::endl;
std::cout << "sub == " << sub << std::endl;
std::cout << std::endl;
std::cout << "match == match == " << std::boolalpha
<< (mr == mr) << std::endl;
std::cout << "sub == sub == " << std::boolalpha
<< (sub == sub) << std::endl;
std::cout << "string(\"aab\") == sub == " << std::boolalpha
<< (Mystr("aab") == sub) << std::endl;
std::cout << "sub == string(\"aab\") == " << std::boolalpha
<< (sub == Mystr("aab")) << std::endl;
std::cout << "\"aab\" == sub == " << std::boolalpha
<< ("aab" == sub) << std::endl;
std::cout << "sub == \"aab\" == " << std::boolalpha
<< (sub == "aab") << std::endl;
std::cout << "'a' == sub == " << std::boolalpha
<< ('a' == sub) << std::endl;
std::cout << "sub == 'a' == " << std::boolalpha
<< (sub == 'a') << std::endl;
return (0);
}
match == caaa
sub == aaa
match == match == true
sub == sub == true
string("aab") == sub == false
sub == string("aab") == false
"aab" == sub == false
sub == "aab" == false
'a' == sub == false
sub == 'a' == false
operator>
Confronto maggiore di tra vari oggetti.
template <class BidIt>
bool operator>(const sub_match<BidIt>& left,
const sub_match<BidIt>& right);
template <class BidIt, class IOtraits, class Alloc>
bool operator>(
const basic_string<typename iterator_traits<BidIt>::value_type, IOtraits, Alloc>& left,
const sub_match<BidIt>& right);
template <class BidIt, class IOtraits, class Alloc>
bool operator>(const sub_match<BidIt>& left,
const basic_string<typename iterator_traits<BidIt>::value_type, IOtraits, Alloc>& right);
template <class BidIt>
bool operator>(const typename iterator_traits<BidIt>::value_type *left,
const sub_match<BidIt>& right);
template <class BidIt>
bool operator>(const sub_match<BidIt>& left,
const typename iterator_traits<BidIt>::value_type *right);
template <class BidIt>
bool operator>(const typename iterator_traits<BidIt>::value_type& left,
const sub_match<BidIt>& right);
template <class BidIt>
bool operator>(const sub_match<BidIt>& left,
const typename iterator_traits<BidIt>::value_type& right);
Parametri
BidIt
Tipo di iteratore.
IOtraits
Classe traits della stringa.
Alloc
Classe Allocator.
left
Oggetto a sinistra da confrontare.
right
Oggetto a destra da confrontare.
Osservazioni:
Ciascun operatore modello restituisce right < left
.
Esempio
// std__regex__operator_gt.cpp
// compile with: /EHsc
#include <regex>
#include <iostream>
typedef std::cmatch::string_type Mystr;
int main()
{
std::regex rx("c(a*)|(b)");
std::cmatch mr;
std::regex_search("xcaaay", mr, rx);
std::csub_match sub = mr[1];
std::cout << "sub == " << sub << std::endl;
std::cout << std::endl;
std::cout << "sub > sub == " << std::boolalpha
<< (sub > sub) << std::endl;
std::cout << "string(\"aab\") > sub == " << std::boolalpha
<< (Mystr("aab") > sub) << std::endl;
std::cout << "sub > string(\"aab\") == " << std::boolalpha
<< (sub > Mystr("aab")) << std::endl;
std::cout << "\"aab\" > sub == " << std::boolalpha
<< ("aab" > sub) << std::endl;
std::cout << "sub > \"aab\" == " << std::boolalpha
<< (sub > "aab") << std::endl;
std::cout << "'a' > sub == " << std::boolalpha
<< ('a' > sub) << std::endl;
std::cout << "sub > 'a' == " << std::boolalpha
<< (sub > 'a') << std::endl;
return (0);
}
sub == aaa
sub > sub == false
string("aab") > sub == true
sub > string("aab") == false
"aab" > sub == true
sub > "aab" == false
'a' > sub == false
sub > 'a' == true
operator>=
Confronto maggiore di o uguale tra vari oggetti.
template <class BidIt>
bool operator>=(const sub_match<BidIt>& left,
const sub_match<BidIt>& right);
template <class BidIt, class IOtraits, class Alloc>
bool operator>=(
const basic_string<typename iterator_traits<BidIt>::value_type, IOtraits, Alloc>& left,
const sub_match<BidIt>& right);
template <class BidIt, class IOtraits, class Alloc>
bool operator>=(const sub_match<BidIt>& left,
const basic_string<typename iterator_traits<BidIt>::value_type, IOtraits, Alloc>& right);
template <class BidIt>
bool operator>=(const typename iterator_traits<BidIt>::value_type *left,
const sub_match<BidIt>& right);
template <class BidIt>
bool operator>=(const sub_match<BidIt>& left,
const typename iterator_traits<BidIt>::value_type *right);
template <class BidIt>
bool operator>=(const typename iterator_traits<BidIt>::value_type& left,
const sub_match<BidIt>& right);
template <class BidIt>
bool operator>=(const sub_match<BidIt>& left,
const typename iterator_traits<BidIt>::value_type& right);
Parametri
BidIt
Tipo di iteratore.
IOtraits
Classe traits della stringa.
Alloc
Classe Allocator.
left
Oggetto a sinistra da confrontare.
right
Oggetto a destra da confrontare.
Osservazioni:
Ciascun operatore modello restituisce !(left < right)
.
Esempio
// std__regex__operator_ge.cpp
// compile with: /EHsc
#include <regex>
#include <iostream>
typedef std::cmatch::string_type Mystr;
int main()
{
std::regex rx("c(a*)|(b)");
std::cmatch mr;
std::regex_search("xcaaay", mr, rx);
std::csub_match sub = mr[1];
std::cout << "sub == " << sub << std::endl;
std::cout << std::endl;
std::cout << "sub >= sub == " << std::boolalpha
<< (sub >= sub) << std::endl;
std::cout << "string(\"aab\") >= sub == " << std::boolalpha
<< (Mystr("aab") >= sub) << std::endl;
std::cout << "sub >= string(\"aab\") == " << std::boolalpha
<< (sub >= Mystr("aab")) << std::endl;
std::cout << "\"aab\" >= sub == " << std::boolalpha
<< ("aab" >= sub) << std::endl;
std::cout << "sub >= \"aab\" == " << std::boolalpha
<< (sub >= "aab") << std::endl;
std::cout << "'a' >= sub == " << std::boolalpha
<< ('a' >= sub) << std::endl;
std::cout << "sub >= 'a' == " << std::boolalpha
<< (sub >= 'a') << std::endl;
return (0);
}
sub == aaa
sub >= sub == true
string("aab") >= sub == true
sub >= string("aab") == false
"aab" >= sub == true
sub >= "aab" == false
'a' >= sub == false
sub >= 'a' == true
Vedi anche
<regex>
Classe regex_constants
Classe regex_error
<funzioni regex>
Classe regex_iterator
Classe regex_token_iterator
Classe regex_traits
<typedef regex>