operator==,!=,<,<=,>,>=,<=>(std::sub_match)
Defined in header <regex>
|
||
Direct comparison |
||
template
<
class BidirIt >
bool operator==
(
const
std::sub_match
<BidirIt>
& lhs, |
(1) | (since C++11) |
template
<
class BidirIt >
bool operator!
=
(
const
std::sub_match
<BidirIt>
& lhs, |
(2) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator<
(
const
std::sub_match
<BidirIt>
& lhs, |
(3) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator<=
(
const
std::sub_match
<BidirIt>
& lhs, |
(4) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator>
(
const
std::sub_match
<BidirIt>
& lhs, |
(5) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator>=
(
const
std::sub_match
<BidirIt>
& lhs, |
(6) | (since C++11) (until C++20) |
template
<
class BidirIt >
auto operator<=>
(
const
std::sub_match
<BidirIt>
& lhs, |
(7) | (since C++20) |
Comparing with a std::basic_string |
||
template
<
class BidirIt, class Traits, class Alloc >
bool operator==
(
const
std::sub_match
<BidirIt>
& lhs, |
(8) | (since C++11) |
template
<
class BidirIt, class Traits, class Alloc >
bool operator!
=
(
const
std::sub_match
<BidirIt>
& lhs, |
(9) | (since C++11) (until C++20) |
template
<
class BidirIt, class Traits, class Alloc >
bool operator<
(
const
std::sub_match
<BidirIt>
& lhs, |
(10) | (since C++11) (until C++20) |
template
<
class BidirIt, class Traits, class Alloc >
bool operator<=
(
const
std::sub_match
<BidirIt>
& lhs, |
(11) | (since C++11) (until C++20) |
template
<
class BidirIt, class Traits, class Alloc >
bool operator>
(
const
std::sub_match
<BidirIt>
& lhs, |
(12) | (since C++11) (until C++20) |
template
<
class BidirIt, class Traits, class Alloc >
bool operator>=
(
const
std::sub_match
<BidirIt>
& lhs, |
(13) | (since C++11) (until C++20) |
template
<
class BidirIt, class Traits, class Alloc >
auto operator<=>
(
const
std::sub_match
<BidirIt>
& lhs, |
(14) | (since C++20) |
template
<
class BidirIt, class Traits, class Alloc >
bool operator==
(
const
std::basic_string
<
/*value-type-of*/
<BidirIt>, |
(15) | (since C++11) (until C++20) |
template
<
class BidirIt, class Traits, class Alloc >
bool operator!
=
(
const
std::basic_string
<
/*value-type-of*/
<BidirIt>, |
(16) | (since C++11) (until C++20) |
template
<
class BidirIt, class Traits, class Alloc >
bool operator<
(
const
std::basic_string
<
/*value-type-of*/
<BidirIt>, |
(17) | (since C++11) (until C++20) |
template
<
class BidirIt, class Traits, class Alloc >
bool operator<=
(
const
std::basic_string
<
/*value-type-of*/
<BidirIt>, |
(18) | (since C++11) (until C++20) |
template
<
class BidirIt, class Traits, class Alloc >
bool operator>
(
const
std::basic_string
<
/*value-type-of*/
<BidirIt>, |
(19) | (since C++11) (until C++20) |
template
<
class BidirIt, class Traits, class Alloc >
bool operator>=
(
const
std::basic_string
<
/*value-type-of*/
<BidirIt>, |
(20) | (since C++11) (until C++20) |
Comparing with a C-style string |
||
template
<
class BidirIt >
bool operator==
(
const
std::sub_match
<BidirIt>
& lhs, |
(21) | (since C++11) |
template
<
class BidirIt >
bool operator!
=
(
const
std::sub_match
<BidirIt>
& lhs, |
(22) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator<
(
const
std::sub_match
<BidirIt>
& lhs, |
(23) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator<=
(
const
std::sub_match
<BidirIt>
& lhs, |
(24) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator>
(
const
std::sub_match
<BidirIt>
& lhs, |
(25) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator>=
(
const
std::sub_match
<BidirIt>
& lhs, |
(26) | (since C++11) (until C++20) |
template
<
class BidirIt >
auto operator<=>
(
const
std::sub_match
<BidirIt>
& lhs, |
(27) | (since C++20) |
template
<
class BidirIt >
bool operator==
(
const
/*value-type-of*/
<BidirIt>
* s, |
(28) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator!
=
(
const
/*value-type-of*/
<BidirIt>
* s, |
(29) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator<
(
const
/*value-type-of*/
<BidirIt>
* s, |
(30) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator<=
(
const
/*value-type-of*/
<BidirIt>
* s, |
(31) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator>
(
const
/*value-type-of*/
<BidirIt>
* s, |
(32) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator>=
(
const
/*value-type-of*/
<BidirIt>
* s, |
(33) | (since C++11) (until C++20) |
Comparing with a single character |
||
template
<
class BidirIt >
bool operator==
(
const
std::sub_match
<BidirIt>
& lhs, |
(34) | (since C++11) |
template
<
class BidirIt >
bool operator!
=
(
const
std::sub_match
<BidirIt>
& lhs, |
(35) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator<
(
const
std::sub_match
<BidirIt>
& lhs, |
(36) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator<=
(
const
std::sub_match
<BidirIt>
& lhs, |
(37) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator>
(
const
std::sub_match
<BidirIt>
& lhs, |
(38) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator>=
(
const
std::sub_match
<BidirIt>
& lhs, |
(39) | (since C++11) (until C++20) |
template
<
class BidirIt >
auto operator<=>
(
const
std::sub_match
<BidirIt>
& lhs, |
(40) | (since C++20) |
template
<
class BidirIt >
bool operator==
(
const
/*value-type-of*/
<BidirIt>
& ch, |
(41) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator!
=
(
const
/*value-type-of*/
<BidirIt>
& ch, |
(42) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator<
(
const
/*value-type-of*/
<BidirIt>
& ch, |
(43) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator<=
(
const
/*value-type-of*/
<BidirIt>
& ch, |
(44) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator>
(
const
/*value-type-of*/
<BidirIt>
& ch, |
(45) | (since C++11) (until C++20) |
template
<
class BidirIt >
bool operator>=
(
const
/*value-type-of*/
<BidirIt>
& ch, |
(46) | (since C++11) (until C++20) |
Helper type aliases |
||
template
<
class BidirIt >
using /*value-type-of*/ = |
(47) | (exposition only*) |
template
<
class BidirIt >
using
/*cat-type-of*/
=
|
(48) |
(since C++20)
(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 |
(since C++20) |
Parameters
lhs, rhs | - | a sub_match to compare
|
str | - | a std::basic_string to compare |
s | - | a pointer to a C-style string to compare |
ch | - | a character to compare |
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 |
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
Example
This section is incomplete Reason: no example |
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 ( ) ) ) |
See also
compares matched subsequence (if any) (public member function) |