CppDS.com

C++ 98 11 14 17 20 手册

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

来自cppreference.com
< cpp‎ | regex‎ | match results
定义于头文件 <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 相等:

  • 无一对象为就绪
  • 二个 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 是否不相等。

参数

lhs, rhs - 要比较的 match_results
类型要求
-
BidirIt 必须满足遗留双向迭代器 (LegacyBidirectionalIterator) 的要求。
-
Alloc 必须满足分配器 (Allocator) 的要求。

返回值

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

异常

(无)

示例

关闭