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

出自cppreference.com
< 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

[編輯] 異常

可能會拋出由實現定義的異常。

[編輯] 示例