public member function
<regex>

std::regex_token_iterator::operator==

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

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

引數

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

返回值

true如果兩個regex_token_iterator比較相等。false否則為 false。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// regex_token_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_token_iterator<std::string::iterator> rend; // end-of-sequence iterator

  // iterate over second submatches of each match:
  std::regex_token_iterator<std::string::iterator> rit ( s.begin(), s.end(), e, 2 );

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

  return 0;
}

輸出
ject
marine
sequence


另見