名稱空間
變體
操作

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

[編輯] 異常

可能丟擲實現定義的異常。

[編輯] 示例