public member function
<regex>

std::match_results::cend

const_iterator cend() const;
Return const_iterator to end
Returns a const_iterator pointing to the past-the-end position in the sequence of sub_match elements contained in the match_results object. Together with match_results::cbegin, these functions describe a range that encompasses all the matches in the match_results object.

In match_results, where the matches contained are always const, this function is exactly the same as match_results::end.

Parameters

none

Return value

An iterator to to the sub_match past-the-end location in the sequence of matches in the match_results object.

Member type const_iterator (the same as member type iterator) is a forward iterator type.
The matches contained in a match_results object are always const.

Example

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;
}

Output:
matches:
subject
sub
ject



See also