operator==,!=,<,<=,>,>=,<=> (std::sub_match)
|
定义于头文件
<regex>
|
||
|
直接比较
|
||
|
template
<
class
BidirIt
>
bool
operator
==
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(1) | (自 C++11 起) |
|
template
<
class
BidirIt
>
bool
operator
!
=
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(2) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
<
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(3) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
<=
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(4) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
>
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(5) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
>=
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(6) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
auto
operator
<=>
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(7) | (C++20 起) |
|
与
std::basic_string
进行比较
|
||
|
template
<
class
BidirIt,
class
Traits,
class
Alloc
>
bool
operator
==
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(8) | (自 C++11 起) |
|
template
<
class
BidirIt,
class
Traits,
class
Alloc
>
bool
operator
!
=
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(9) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt,
class
Traits,
class
Alloc
>
bool
operator
<
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(10) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt,
class
Traits,
class
Alloc
>
bool
operator
<=
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(11) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt,
class
Traits,
class
Alloc
>
bool
operator
>
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(12) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt,
class
Traits,
class
Alloc
>
bool
operator
>=
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(13) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt,
class
Traits,
class
Alloc
>
auto
operator
<=>
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(14) | (自 C++20 起) |
|
template
<
class
BidirIt,
class
Traits,
class
Alloc
>
bool
operator
==
(
const
std::
basic_string
<
/*value-type-of*/
<
BidirIt
>
,
|
(15) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt,
class
Traits,
class
Alloc
>
bool
operator
!
=
(
const
std::
basic_string
<
/*value-type-of*/
<
BidirIt
>
,
|
(16) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt,
class
Traits,
class
Alloc
>
bool
operator
<
(
const
std::
basic_string
<
/*value-type-of*/
<
BidirIt
>
,
|
(17) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt,
class
Traits,
class
Alloc
>
bool
operator
<=
(
const
std::
basic_string
<
/*value-type-of*/
<
BidirIt
>
,
|
(18) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt,
class
Traits,
class
Alloc
>
bool
operator
>
(
const
std::
basic_string
<
/*值类型*/
<
BidirIt
>
,
|
(19) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt,
class
Traits,
class
Alloc
>
bool
operator
>=
(
const
std::
basic_string
<
/*value-type-of*/
<
BidirIt
>
,
|
(20) |
(自 C++11 起)
(直至 C++20) |
|
与C风格字符串比较
|
||
|
template
<
class
BidirIt
>
bool
operator
==
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(21) | (自 C++11 起) |
|
template
<
class
BidirIt
>
bool
operator
!
=
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(22) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
<
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(23) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
<=
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(24) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
>
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(25) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
>=
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(26) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
auto
operator
<=>
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(27) | (自 C++20 起) |
|
template
<
class
BidirIt
>
bool
operator
==
(
const
/*value-type-of*/
<
BidirIt
>
*
s,
|
(28) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
!
=
(
const
/*value-type-of*/
<
BidirIt
>
*
s,
|
(29) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
<
(
const
/*value-type-of*/
<
BidirIt
>
*
s,
|
(30) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
<=
(
const
/*value-type-of*/
<
BidirIt
>
*
s,
|
(31) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
>
(
const
/*值类型为*/
<
BidirIt
>
*
s,
|
(32) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
>=
(
const
/*值类型为*/
<
BidirIt
>
*
s,
|
(33) |
(自 C++11 起)
(直至 C++20) |
|
与单个字符比较
|
||
|
template
<
class
BidirIt
>
bool
operator
==
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(34) | (自 C++11 起) |
|
template
<
class
BidirIt
>
bool
operator
!
=
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(35) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
<
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(36) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
<=
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(37) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
>
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(38) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
>=
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(39) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
auto
operator
<=>
(
const
std::
sub_match
<
BidirIt
>
&
lhs,
|
(40) | (自 C++20 起) |
|
template
<
class
BidirIt
>
bool
operator
==
(
const
/*值类型为*/
<
BidirIt
>
&
ch,
|
(41) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
!
=
(
const
/*值类型*/
<
BidirIt
>
&
ch,
|
(42) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
<
(
const
/*值类型*/
<
BidirIt
>
&
ch,
|
(43) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
<=
(
const
/*value-type-of*/
<
BidirIt
>
&
ch,
|
(44) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
>
(
const
/*值类型*/
<
BidirIt
>
&
ch,
|
(45) |
(自 C++11 起)
(直至 C++20) |
|
template
<
class
BidirIt
>
bool
operator
>=
(
const
/*值类型*/
<
BidirIt
>
&
ch,
|
(46) |
(自 C++11 起)
(直至 C++20) |
|
辅助类型别名
|
||
|
template
<
class
BidirIt
>
using
/*value-type-of*/
=
|
(47) | ( 仅用于说明* ) |
|
template
<
class
BidirIt
>
using
/*cat-type-of*/
=
|
(48) |
(始于 C++20)
( 仅用于说明* ) |
将一个
sub_match
与另一个
sub_match
、
std::string
、C风格字符串或单个字符进行比较。
sub_match
。
sub_match
与C风格字符串进行比较。
sub_match
与单个字符。
|
|
(C++20 起) |
目录 |
参数
| lhs, rhs | - |
待比较的
sub_match
对象
|
| str | - | 待比较的 std::basic_string 字符串 |
| s | - | 待比较的C风格字符串指针 |
| ch | - | 待比较的字符 |
返回值
令 target 为以下值:
返回值定义如下:
| 运算符 | 返回值 | |
|---|---|---|
|
重载版本
(1-14,21-27,34-40)
(包含 lhs 参数的重载) |
重载版本
(15-20,28-33,41-46)
(不包含 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
<
类别类型
<
BidirIt
>>
(
lhs.
compare
(
target
)
<=>
0
)
|
不适用 |
注释
operator
<=>
的返回类型保证是比较类别类型。若
value-type-of
<
BidirIt
>
为
char
、
wchar_t
、
char8_t
、
char16_t
或
char32_t
,则
operator<=>
的返回类型为
std::strong_ordering
。
示例
|
本节内容不完整
原因:缺少示例 |
缺陷报告
以下行为变更缺陷报告被追溯应用于先前发布的C++标准。
| DR | 适用版本 | 发布行为 | 正确行为 |
|---|---|---|---|
| LWG 2217 | C++11 |
与
std::string
比较时,
compare()
的参数为
str.
c_str
(
)
|
参数应为
string_type ( str. data ( ) , str. size ( ) ) ) |
另请参阅
|
比较匹配的子序列(如果存在)
(公开成员函数) |