public member function
<regex>

std::match_results::cend

const_iterator cend() const;
返回指向結尾的 const_iterator
返回一個const_iterator指向match_results物件中包含的 sub_match 元素序列中超出末尾的位置。 與match_results::cbegin 一起,這些函式描述了一個範圍,該範圍包含match_results物件中的所有匹配項。

match_results中,由於包含的匹配項始終是const,因此此函式與match_results::end完全相同。

引數



返回值

指向 match_results 物件中匹配項序列中 sub_match 超出末尾 位置的迭代器。

成員型別const_iterator(與成員型別相同iterator)是一個 前向迭代器 型別。
match_results 物件中包含的匹配項始終為常量。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// match_results::cbegin/cend
// - using smatch, a standard alias of match_results<string::iterator>
#include <iostream>
#include <string>
#include <regex>

int main ()
{
  std::string s ("subject");
  std::smatch m;
  std::regex e ("(sub)(.*)");

  std::regex_match ( s, m, e );

  std::cout << "matches:" << std::endl;
  for (std::smatch::iterator it = m.cbegin(); it!=m.cend(); ++it) {
	std::cout << *it << std::endl;
  }
  return 0;
}

輸出
matches:
subject
sub
ject



另見