命名空间
变体
操作

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) (C++11 起)
template< class BidirIt, class Alloc >

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

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

比较两个 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== 合成

(C++20 起)

目录

[编辑] 参数

lhs, rhs - 要比较的匹配结果
类型要求
-
BidirIt 必须满足 LegacyBidirectionalIterator 的要求。
-
Alloc 必须满足 Allocator 的要求。

[编辑] 返回值

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

[编辑] 异常

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

[编辑] 示例