命名空间
变体
操作

operator==,!=(std::match_results)

来自 cppreference.cn
< cpp‎ | regex‎ | match results
 
 
 
正则表达式库
(C++11)
算法
迭代器
异常
特性
常量
(C++11)
正则表达式语法
 
 
定义于头文件 <regex>
template< class BidirIt, class Alloc >

bool operator==( match_results<BidirIt,Alloc>& lhs,

                 match_results<BidirIt,Alloc>& rhs );
(1) (since C++11)
template< class BidirIt, class Alloc >

bool operator!=( match_results<BidirIt,Alloc>& lhs,

                 match_results<BidirIt,Alloc>& rhs );
(2) (since C++11)
(until C++20)

比较两个 match_results 对象。

两个 match_results 相等,如果以下条件成立:

  • 两个对象都不是就绪状态,或者
  • 两个 match_results 都是就绪状态,且以下条件成立:
  • lhs.empty()rhs.empty() 均为真,或者
  • !lhs.empty()!rhs.empty() 均为真,且以下条件成立:
  • lhs.prefix() == rhs.prefix()
  • lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin())
  • lhs.suffix() == rhs.suffix()
1) 检查 lhsrhs 是否相等。
2) 检查 lhsrhs 是否不相等。

!= 运算符是自 operator== 合成的

(since C++20)

内容

[编辑] 参数

lhs, rhs - 要比较的 match results
类型要求
-
BidirIt 必须满足 LegacyBidirectionalIterator 的要求。
-
Alloc 必须满足 Allocator 的要求。

[编辑] 返回值

1) 如果 lhsrhs 相等,则返回 true,否则返回 false
2) 如果 lhsrhs 不相等,则返回 true,否则返回 false

[编辑] 异常

可能抛出实现定义的异常。

[编辑] 示例