operator==,!=,<,<=,>,>=,<=>(std::sub_match)
<regex>
bool operator== ( const std::sub_match <BidirIt>& lhs,
bool operator!= ( const std::sub_match <BidirIt>& lhs,
(until C++20)
bool operator< ( const std::sub_match <BidirIt>& lhs,
(until C++20)
bool operator<= ( const std::sub_match <BidirIt>& lhs,
(until C++20)
bool operator> ( const std::sub_match <BidirIt>& lhs,
(until C++20)
bool operator>= ( const std::sub_match <BidirIt>& lhs,
(until C++20)
auto operator<=>( const std::sub_match <BidirIt>& lhs,
bool operator== ( const std::sub_match <BidirIt>& lhs,
const std::basic_string </*value-type-of*/<BidirIt>,
bool operator!= ( const std::sub_match <BidirIt>& lhs,
const std::basic_string </*value-type-of*/<BidirIt>,
(until C++20)
bool operator< ( const std::sub_match <BidirIt>& lhs,
const std::basic_string </*value-type-of*/<BidirIt>,
(until C++20)
bool operator<= ( const std::sub_match <BidirIt>& lhs,
const std::basic_string </*value-type-of*/<BidirIt>,
(until C++20)
bool operator> ( const std::sub_match <BidirIt>& lhs,
const std::basic_string </*value-type-of*/<BidirIt>,
(until C++20)
bool operator>= ( const std::sub_match <BidirIt>& lhs,
const std::basic_string </*value-type-of*/<BidirIt>,
(until C++20)
auto operator<=>( const std::sub_match <BidirIt>& lhs,
const std::basic_string </*value-type-of*/<BidirIt>,
bool operator== ( const std::basic_string </*value-type-of*/<BidirIt>,
Traits, Alloc>& str,
(until C++20)
bool operator!= ( const std::basic_string </*value-type-of*/<BidirIt>,
Traits, Alloc>& str,
(until C++20)
bool operator< ( const std::basic_string </*value-type-of*/<BidirIt>,
Traits, Alloc>& str,
(until C++20)
bool operator<= ( const std::basic_string </*value-type-of*/<BidirIt>,
Traits, Alloc>& str,
(until C++20)
bool operator> ( const std::basic_string </*value-type-of*/<BidirIt>,
Traits, Alloc>& str,
(until C++20)
bool operator>= ( const std::basic_string </*value-type-of*/<BidirIt>,
Traits, Alloc>& str,
(until C++20)
bool operator== ( const std::sub_match <BidirIt>& lhs,
bool operator!= ( const std::sub_match <BidirIt>& lhs,
(until C++20)
bool operator< ( const std::sub_match <BidirIt>& lhs,
(until C++20)
bool operator<= ( const std::sub_match <BidirIt>& lhs,
(until C++20)
bool operator> ( const std::sub_match <BidirIt>& lhs,
(until C++20)
bool operator>= ( const std::sub_match <BidirIt>& lhs,
(until C++20)
auto operator<=>( const std::sub_match <BidirIt>& lhs,
bool operator== ( const /*value-type-of*/<BidirIt>* s,
(until C++20)
bool operator!= ( const /*value-type-of*/<BidirIt>* s,
(until C++20)
bool operator< ( const /*value-type-of*/<BidirIt>* s,
(until C++20)
bool operator<= ( const /*value-type-of*/<BidirIt>* s,
(until C++20)
bool operator> ( const /*value-type-of*/<BidirIt>* s,
(until C++20)
bool operator>= ( const /*value-type-of*/<BidirIt>* s,
(until C++20)
bool operator== ( const std::sub_match <BidirIt>& lhs,
bool operator!= ( const std::sub_match <BidirIt>& lhs,
(until C++20)
bool operator< ( const std::sub_match <BidirIt>& lhs,
(until C++20)
bool operator<= ( const std::sub_match <BidirIt>& lhs,
(until C++20)
bool operator> ( const std::sub_match <BidirIt>& lhs,
(until C++20)
bool operator>= ( const std::sub_match <BidirIt>& lhs,
(until C++20)
auto operator<=>( const std::sub_match <BidirIt>& lhs,
bool operator== ( const /*value-type-of*/<BidirIt>& ch,
(until C++20)
bool operator!= ( const /*value-type-of*/<BidirIt>& ch,
(until C++20)
bool operator< ( const /*value-type-of*/<BidirIt>& ch,
(until C++20)
bool operator<= ( const /*value-type-of*/<BidirIt>& ch,
(until C++20)
bool operator> ( const /*value-type-of*/<BidirIt>& ch,
(until C++20)
bool operator>= ( const /*value-type-of*/<BidirIt>& ch,
(until C++20)
using /*value-type-of*/ =
using /*cat-type-of*/ =
std::compare_three_way_result_t
(exposition only*)
Compares a sub_match
to another sub_match
, a std::string , a C-style string or a single character.
sub_match
directly.sub_match
with a C-style string.sub_match
with a single character.The <
, <=
, >
, >=
, and !=
operators are synthesized from operator<=> and operator== respectively.
[edit] Parameters
sub_match
to compare
[edit] Return value
Let target be the following values:
The return values are defined as follows:
Operator | Return value | |
---|---|---|
Overloads (1-14,21-27,34-40) (overloads with parameter lhs) |
Overloads (15-20,28-33,41-46) (overloads without parameter 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 |
[edit] Notes
The return type of operator<=> is guaranteed to be a comparison category type. If value-type-of
<BidirIt> is char, wchar_t, char8_t, char16_t, or char32_t, the return type of operator<=>
is std::strong_ordering.
[edit] Example
Reason: no example
[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 2217 | C++11 | for comparisons with std::string , the argument of compare() was str.c_str()
|
the argument is string_type(str.data(), str.size())) |