public member function
<regex>

std::regex_iterator::operator==

bool operator==(const regex_iterator& rhs) const;
比較 regex_iterator
返回值true(真)如果 rhsregex_iterator 物件比較相等。

如果以下任何一個條件為真,則兩個 regex_iterator 比較相等
  • 它們都是序列結束迭代器
  • 其中一個被構造為或賦值為另一個的副本,並且現在指向相同的匹配項。
  • 它們都使用等效的引數 firstlastflags 構造,都使用相同的 regex 物件,並且現在都指向相同的匹配項(它們的內部 match_results 物件比較相等)。

引數

rhs
相同型別的另一個 regex_iterator 物件。

返回值

true(真)如果兩個 regex_iterator 比較相等。false(假)否則為 false。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// regex_iterator example
#include <iostream>
#include <string>
#include <regex>

int main ()
{
  std::string s ("this subject has a submarine as a subsequence");
  std::regex e ("\\b(sub)([^ ]*)");   // matches words beginning by "sub"

  std::regex_iterator<std::string::iterator> rit ( s.begin(), s.end(), e );
  std::regex_iterator<std::string::iterator> rend;

  while (!(rit==rend)) {
    std::cout << rit->str() << std::endl;
    ++rit;
  }

  return 0;
}

輸出
subject
submarine
subsequence



另見