---
name: "std::tr1::match_results"
section: "3cxx"
platform: "linux"
package: "libstdc++6-4.4-doc"
version: "4.4.5-8"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/std::tr1::match_results"
---

# std::tr1::match\_results(3cxx)

The results of a match or search operation.

## NAME

std::tr1::match\_results -

The results of a match or search operation.

## SYNOPSIS

Inherits **vector\< std::tr1::sub\_match\< \_Bi\_iter \>, \_Allocator \>**.

### Private Types

typedef \_Tp\_alloc\_type::const\_pointer **const\_pointer**\
 typedef **std::reverse\_iterator**\< const\_iterator \> **const\_reverse\_iterator**\
 typedef \_Tp\_alloc\_type::pointer **pointer**\
 typedef **std::reverse\_iterator**\< iterator \> **reverse\_iterator**\

### Private Member Functions

\_Tp\_alloc\_type::pointer **\_M\_allocate** (size\_t \_\_n)\
 pointer **\_M\_allocate\_and\_copy** (size\_type \_\_n, \_ForwardIterator \_\_first, \_ForwardIterator \_\_last)\
 void **\_M\_assign\_aux** (\_ForwardIterator \_\_first, \_ForwardIterator \_\_last, **std::forward\_iterator\_tag**)\
 void **\_M\_assign\_aux** (\_InputIterator \_\_first, \_InputIterator \_\_last, **std::input\_iterator\_tag**)\
 void **\_M\_assign\_dispatch** (\_Integer \_\_n, \_Integer \_\_val, \_\_true\_type)\
 void **\_M\_assign\_dispatch** (\_InputIterator \_\_first, \_InputIterator \_\_last, \_\_false\_type)\
 size\_type **\_M\_check\_len** (size\_type \_\_n, const char \*\_\_s) const\
 void **\_M\_deallocate** (typename \_Tp\_alloc\_type::pointer \_\_p, size\_t \_\_n)\
 void **\_M\_erase\_at\_end** (pointer \_\_pos)\
 void **\_M\_fill\_assign** (size\_type \_\_n, const **value\_type** &\_\_val)\
 void **\_M\_fill\_initialize** (size\_type \_\_n, const **value\_type** &\_\_value)\
 void **\_M\_fill\_insert** (iterator \_\_pos, size\_type \_\_n, const **value\_type** &\_\_x)\
 const \_Tp\_alloc\_type & **\_M\_get\_Tp\_allocator** () const\
 \_Tp\_alloc\_type & **\_M\_get\_Tp\_allocator** ()\
 void **\_M\_initialize\_dispatch** (\_Integer \_\_n, \_Integer \_\_value, \_\_true\_type)\
 void **\_M\_initialize\_dispatch** (\_InputIterator \_\_first, \_InputIterator \_\_last, \_\_false\_type)\
 void **\_M\_insert\_aux** (iterator \_\_position, \_Args &&...\_\_args)\
 void **\_M\_insert\_dispatch** (iterator \_\_pos, \_Integer \_\_n, \_Integer \_\_val, \_\_true\_type)\
 void **\_M\_insert\_dispatch** (iterator \_\_pos, \_InputIterator \_\_first, \_InputIterator \_\_last, \_\_false\_type)\
 void **\_M\_range\_check** (size\_type \_\_n) const\
 void **\_M\_range\_initialize** (\_ForwardIterator \_\_first, \_ForwardIterator \_\_last, **std::forward\_iterator\_tag**)\
 void **\_M\_range\_initialize** (\_InputIterator \_\_first, \_InputIterator \_\_last, **std::input\_iterator\_tag**)\
 void **\_M\_range\_insert** (iterator \_\_pos, \_ForwardIterator \_\_first, \_ForwardIterator \_\_last, **std::forward\_iterator\_tag**)\
 void **\_M\_range\_insert** (iterator \_\_pos, \_InputIterator \_\_first, \_InputIterator \_\_last, **std::input\_iterator\_tag**)\
 void **assign** (\_InputIterator \_\_first, \_InputIterator \_\_last)\
 void **assign** (size\_type \_\_n, const **value\_type** &\_\_val)\
 void **assign** (**initializer\_list**\< **value\_type** \> \_\_l)\
 reference **at** (size\_type \_\_n)\
 const\_reference **at** (size\_type \_\_n) const\
 reference **back** ()\
 const\_reference **back** () const\
 iterator **begin** ()\
 size\_type **capacity** () const\
 void **clear** ()\
 **const\_reverse\_iterator** **crbegin** () const\
 **const\_reverse\_iterator** **crend** () const\
 const\_pointer **data** () const\
 pointer **data** ()\
 iterator **emplace** (iterator \_\_position, \_Args &&...\_\_args)\
 void **emplace\_back** (\_Args &&...\_\_args)\
 iterator **end** ()\
 iterator **erase** (iterator \_\_position)\
 iterator **erase** (iterator \_\_first, iterator \_\_last)\
 reference **front** ()\
 const\_reference **front** () const\
 allocator\_type **get\_allocator** () const\
 iterator **insert** (iterator \_\_position, const **value\_type** &\_\_x)\
 void **insert** (iterator \_\_position, **initializer\_list**\< **value\_type** \> \_\_l)\
 void **insert** (iterator \_\_position, \_InputIterator \_\_first, \_InputIterator \_\_last)\
 iterator **insert** (iterator \_\_position, **value\_type** &&\_\_x)\
 void **insert** (iterator \_\_position, size\_type \_\_n, const **value\_type** &\_\_x)\
 size\_type **max\_size** () const\
 const\_reference **operator\[\]** (size\_type \_\_n) const\
 reference **operator\[\]** (size\_type \_\_n)\
 void **pop\_back** ()\
 void **push\_back** (const **value\_type** &\_\_x)\
 void **push\_back** (**value\_type** &&\_\_x)\
 **const\_reverse\_iterator** **rbegin** () const\
 **reverse\_iterator** **rbegin** ()\
 **reverse\_iterator** **rend** ()\
 **const\_reverse\_iterator** **rend** () const\
 void **reserve** (size\_type \_\_n)\
 void **resize** (size\_type \_\_new\_size, **value\_type** \_\_x=**value\_type**())\
 void **swap** (**vector** &&\_\_x)\

### Private Attributes

\_Vector\_impl **\_M\_impl**\

### 10.? Public Types

typedef **sub\_match**\< \_Bi\_iter \> **value\_type**\
 typedef \_Allocator::const\_reference **const\_reference**\
 typedef const\_reference **reference**\
 typedef \_Base\_type::const\_iterator **const\_iterator**\
 typedef const\_iterator **iterator**\
 typedef **iterator\_traits**\< \_Bi\_iter \>::difference\_type **difference\_type**\
 typedef \_Allocator::size\_type **size\_type**\
 typedef \_Allocator **allocator\_type**\
 typedef **iterator\_traits**\< \_Bi\_iter \>::**value\_type** **char\_type**\
 typedef **basic\_string**\< char\_type \> **string\_type**\

### 10.1 Construction, Copying, and Destruction

**match\_results** (const \_Allocator &\_\_a=\_Allocator())\
 **match\_results** (const **match\_results** &\_\_rhs)\
 **match\_results** & **operator=** (const **match\_results** &\_\_rhs)\
 **~match\_results** ()\

### 10.2 Size

size\_type **size** () const \
 bool **empty** () const \

### 10.3 Element Access

difference\_type **length** (size\_type \_\_sub=0) const \
 difference\_type **position** (size\_type \_\_sub=0) const \
 **string\_type** **str** (size\_type \_\_sub=0) const \
 const\_reference **operator\[\]** (size\_type \_\_sub) const \
 const\_reference **prefix** () const \
 const\_reference **suffix** () const \
 const\_iterator **begin** () const \
 const\_iterator **cbegin** () const \
 const\_iterator **end** () const \
 const\_iterator **cend** () const \

### 10.4 Formatting

 These functions perform formatted substitution of the matched character sequences into their target. The format specifiers and escape sequences accepted by these functions are determined by their `flags` parameter as documented above.  template\<typename \_Out\_iter \> \_Out\_iter **format** (\_Out\_iter \_\_out, const **string\_type** &\_\_fmt, **regex\_constants::match\_flag\_type** \_\_flags=regex\_constants::format\_default) const \
 **string\_type** **format** (const **string\_type** &\_\_fmt, **regex\_constants::match\_flag\_type** \_\_flags=regex\_constants::format\_default) const \

### 10.6 Swap

void **swap** (**match\_results** &\_\_that)\

## Detailed Description

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> class std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>

The results of a match or search operation.

A collection of character sequences representing the result of a regular expression match. Storage for the collection is allocated and freed as necessary by the member functions of class template **match\_results**.

This class satisfies the Sequence requirements, with the exception that only the operations defined for a const-qualified Sequence are supported.

The **sub\_match** object stored at index 0 represents sub-expression 0, i.e. the whole match. In this case the **sub\_match** member matched is always true. The **sub\_match** object stored at index n denotes what matched the marked sub-expression n within the matched expression. If the sub-expression n participated in a regular expression match then the **sub\_match** member matched evaluates to true, and members first and second denote the range of characters \[first, second) which formed that match. Otherwise matched is false, and members first and second point to the end of the sequence that was searched.

Definition at line 1763 of file tr1\_impl/regex.

## Constructor & Destructor Documentation

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>::match\_results (const \_Allocator & \_\_a = `_Allocator()`)` [inline, explicit]`

Constructs a default match\_results container. **Postcondition:**

**size()** returns 0 and **str()** returns an empty string.

Definition at line 1799 of file tr1\_impl/regex.

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>::match\_results (const match\_results\< \_Bi\_iter, \_Allocator \> & \_\_rhs)` [inline]`

Copy constructs a match\_results.

Definition at line 1806 of file tr1\_impl/regex.

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>::~match\_results ()` [inline]`

Destroys a match\_results object.

Definition at line 1825 of file tr1\_impl/regex.

## Member Function Documentation

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> const\_iterator std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>::begin () const` [inline]`

Gets an iterator to the start of the sub\_match collection.

Reimplemented from **std::vector\< std::tr1::sub\_match\< \_Bi\_iter \>, \_Allocator \>**.

Definition at line 1947 of file tr1\_impl/regex.

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> const\_iterator std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>::cbegin () const` [inline]`

Gets an iterator to the start of the sub\_match collection.

Reimplemented from **std::vector\< std::tr1::sub\_match\< \_Bi\_iter \>, \_Allocator \>**.

Definition at line 1955 of file tr1\_impl/regex.

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> const\_iterator std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>::cend () const` [inline]`

Gets an iterator to one-past-the-end of the collection.

Reimplemented from **std::vector\< std::tr1::sub\_match\< \_Bi\_iter \>, \_Allocator \>**.

Definition at line 1971 of file tr1\_impl/regex.

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> bool std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>::empty () const` [inline]`

Indicates if the match\_results contains no results. **Return values:**

*true* The match\_results object is empty. \
 *false* The match\_results object is not empty.

Reimplemented from **std::vector\< std::tr1::sub\_match\< \_Bi\_iter \>, \_Allocator \>**.

Definition at line 1858 of file tr1\_impl/regex.

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> const\_iterator std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>::end () const` [inline]`

Gets an iterator to one-past-the-end of the collection.

Reimplemented from **std::vector\< std::tr1::sub\_match\< \_Bi\_iter \>, \_Allocator \>**.

Definition at line 1963 of file tr1\_impl/regex.

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> string\_type std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>::format (const string\_type & \_\_fmt, regex\_constants::match\_flag\_type \_\_flags = `regex_constants::format_default`) const Todo

Implement this function.

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> template\<typename \_Out\_iter \> \_Out\_iter std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>::format (\_Out\_iter \_\_out, const string\_type & \_\_fmt, regex\_constants::match\_flag\_type \_\_flags = `regex_constants::format_default`) const Todo

Implement this function.

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> difference\_type std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>::length (size\_type \_\_sub = `0`) const` [inline]`

Gets the length of the indicated submatch. **Parameters:**

*sub* indicates the submatch.

This function returns the length of the indicated submatch, or the length of the entire match if `sub` is zero (the default).

Definition at line 1876 of file tr1\_impl/regex.

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> match\_results& std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>::operator= (const match\_results\< \_Bi\_iter, \_Allocator \> & \_\_rhs)` [inline]`

Assigns rhs to \*this.

Definition at line 1815 of file tr1\_impl/regex.

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> const\_reference std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>::operator\[\] (size\_type \_\_sub) const` [inline]`

Gets a sub\_match reference for the match or submatch. **Parameters:**

*sub* indicates the submatch.

This function gets a reference to the indicated submatch, or the entire match if `sub` is zero.

If `sub` \>= **size()** then this function returns a sub\_match with a special value indicating no submatch.

Definition at line 1918 of file tr1\_impl/regex.

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> difference\_type std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>::position (size\_type \_\_sub = `0`) const` [inline]`

Gets the offset of the beginning of the indicated submatch. **Parameters:**

*sub* indicates the submatch.

This function returns the offset from the beginning of the target sequence to the beginning of the submatch, unless the value of `sub` is zero (the default), in which case this function returns the offset from the beginning of the target sequence to the beginning of the match.

Definition at line 1890 of file tr1\_impl/regex.

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> const\_reference std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>::prefix () const` [inline]`

Gets a sub\_match representing the match prefix. This function gets a reference to a sub\_match object representing the part of the target range between the start of the target range and the start of the match.

Definition at line 1929 of file tr1\_impl/regex.

Referenced by std::tr1::match\_results\< \_Bi\_iter \>::position().

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> size\_type std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>::size () const` [inline]`

Gets the number of matches and submatches. The number of matches for a given regular expression will be either 0 if there was no match or mark\_count() + 1 if a match was successful. Some matches may be empty.

**Returns:**

the number of matches found.

Reimplemented from **std::vector\< std::tr1::sub\_match\< \_Bi\_iter \>, \_Allocator \>**.

Definition at line 1845 of file tr1\_impl/regex.

Referenced by std::tr1::match\_results\< \_Bi\_iter \>::empty().

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> string\_type std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>::str (size\_type \_\_sub = `0`) const` [inline]`

Gets the match or submatch converted to a string type. **Parameters:**

*sub* indicates the submatch.

This function gets the submatch (or match, if `sub` is zero) extracted from the target range and converted to the associated string type.

Definition at line 1904 of file tr1\_impl/regex.

Referenced by std::tr1::match\_results\< \_Bi\_iter \>::length().

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> const\_reference std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>::suffix () const` [inline]`

Gets a sub\_match representing the match suffix. This function gets a reference to a sub\_match object representing the part of the target range between the end of the match and the end of the target range.

Definition at line 1940 of file tr1\_impl/regex.

### template\<typename \_Bi\_iter, typename \_Allocator = allocator\<sub\_match\<\_Bi\_iter\> \>\> void std::tr1::match\_results\< \_Bi\_iter, \_Allocator \>::swap (match\_results\< \_Bi\_iter, \_Allocator \> & \_\_that)` [inline]`

Swaps the contents of two **match\_results**.

Definition at line 2029 of file tr1\_impl/regex.

Referenced by std::tr1::match\_results\< \_Bi\_iter \>::operator=(), std::tr1::swap(), and std::tr1::match\_results\< \_Bi\_iter \>::swap().

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
