public member function
<regex>

std::match_results::match_results

default (1)
explicit match_results ( const allocator_type& alloc = allocator_type() );
copy (2)
match_results ( const match_results& m );
move (3)
match_results ( match_results&& m );
Construct match_results
Constructs a match_results object, which is either default-initialized or with the contents of m (copy/move constructors).

When default-constructed (1), a match_results's object ready member function returns false.

Parameters

alloc
Allocator object to be used instead of constructing a new one.
For class instantiations using their version of the default allocator class template, this parameter is not relevant.
Member type allocator_type is defined in match_results as an alias of its second template parameter (Alloc).
m
Another match_results object of the same type (with the same class template arguments), whose contents are either copied or moved.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// match_results constructor
// - using cmatch, a standard alias of match_results<const char*>
#include <iostream>
#include <regex>

int main ()
{
  std::cmatch m;          // default constructor

  std::regex_match ( "subject", m, std::regex("sub(.*)") );

  std::cmatch mcopy (m);  // copy constructor

  for (unsigned i=0; i<mcopy.size(); ++i)
    std::cout << "match " << i << ": " << mcopy[i] << std::endl;

  return 0;
}


Output:
match 1: subject
match 2: ject

See also