---
name: "std::regex_token_iterator"
section: "3"
platform: "linux"
package: "gcc"
version: "16.2.1+r23+gd564253eb6c8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/std::regex_token_iterator"
---

# std::regex\_token\_iterator(3)

## NAME

std::regex\_token\_iterator\< \_Bi\_iter, \_Ch\_type, \_Rx\_traits \>

## SYNOPSIS

\#include \<regex\>

### Public Types

typedef std::ptrdiff\_t **difference\_type**\
 typedef **std::forward\_iterator\_tag** **iterator\_category**\
 typedef **std::input\_iterator\_tag** **iterator\_concept**\
 typedef const value\_type \* **pointer**\
 typedef const value\_type & **reference**\
 typedef **basic\_regex**\< \_Ch\_type, \_Rx\_traits \> **regex\_type**\
 typedef **sub\_match**\< \_Bi\_iter \> **value\_type**\

### Public Member Functions

**regex\_token\_iterator** ()\
 Default constructs a regex\_token\_iterator.  template\<std::size\_t \_Nm\> **regex\_token\_iterator** (\_Bi\_iter \_\_a, \_Bi\_iter \_\_b, const regex\_type &\_\_re, const int(&\_\_submatches)\[\_Nm\], **regex\_constants::match\_flag\_type** \_\_m=**regex\_constants::match\_default**)\
 **regex\_token\_iterator** (\_Bi\_iter \_\_a, \_Bi\_iter \_\_b, const regex\_type &\_\_re, const **std::vector**\< int \> &\_\_submatches, **regex\_constants::match\_flag\_type** \_\_m=**regex\_constants::match\_default**)\
 **regex\_token\_iterator** (\_Bi\_iter \_\_a, \_Bi\_iter \_\_b, const regex\_type &\_\_re, **initializer\_list**\< int \> \_\_submatches, **regex\_constants::match\_flag\_type** \_\_m=**regex\_constants::match\_default**)\
 **regex\_token\_iterator** (\_Bi\_iter \_\_a, \_Bi\_iter \_\_b, const regex\_type &\_\_re, int \_\_submatch=0, **regex\_constants::match\_flag\_type** \_\_m=**regex\_constants::match\_default**)\
 template\<std::size\_t \_Nm\> **regex\_token\_iterator** (\_Bi\_iter, \_Bi\_iter, const regex\_type &&, const int(&)\[\_Nm\], **regex\_constants::match\_flag\_type**=**regex\_constants::match\_default**)=delete\
 **regex\_token\_iterator** (\_Bi\_iter, \_Bi\_iter, const regex\_type &&, const **std::vector**\< int \> &, **regex\_constants::match\_flag\_type**=**regex\_constants::match\_default**)=delete\
 **regex\_token\_iterator** (\_Bi\_iter, \_Bi\_iter, const regex\_type &&, **initializer\_list**\< int \>, **regex\_constants::match\_flag\_type**=**regex\_constants::match\_default**)=delete\
 **regex\_token\_iterator** (\_Bi\_iter, \_Bi\_iter, const regex\_type &&, int=0, **regex\_constants::match\_flag\_type**=**regex\_constants::match\_default**)=delete\
 **regex\_token\_iterator** (const regex\_token\_iterator &\_\_rhs)\
 Copy constructs a regex\_token\_iterator.  const value\_type & **operator\*** () const\
 Dereferences a regex\_token\_iterator.  **regex\_token\_iterator** & **operator++** ()\
 Increments a regex\_token\_iterator.  **regex\_token\_iterator** **operator++** (int)\
 Postincrements a regex\_token\_iterator.  const value\_type \* **operator-\>** () const\
 Selects a regex\_token\_iterator member.  **regex\_token\_iterator** & **operator=** (const **regex\_token\_iterator** &\_\_rhs)\
 Assigns a regex\_token\_iterator to another.  bool **operator==** (const **regex\_token\_iterator** &\_\_rhs) const\
 Compares a regex\_token\_iterator to another for equality.  bool **operator==** (**default\_sentinel\_t**) const noexcept\

## Detailed Description

### template\<typename \_Bi\_iter, typename \_Ch\_type = typename iterator\_traits\<\_Bi\_iter\>::value\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\>

class std::regex\_token\_iterator\< \_Bi\_iter, \_Ch\_type, \_Rx\_traits \>"Iterates over submatches in a range (or *splits* a text string).

The purpose of this iterator is to enumerate all, or all specified, matches of a regular expression within a text range. The dereferenced value of an iterator of this class is a std::sub\_match object.

**Since**

C++11

## Constructor & Destructor Documentation

### template\<typename \_Bi\_iter, typename \_Ch\_type = typename iterator\_traits\<\_Bi\_iter\>::value\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> std::regex\_token\_iterator\< \_Bi\_iter, \_Ch\_type, \_Rx\_traits \>::regex\_token\_iterator () \[inline\]

Default constructs a regex\_token\_iterator. A default-constructed regex\_token\_iterator is a singular iterator that will compare equal to the one-past-the-end value for any iterator of the same type.

Referenced by **operator++()**, **operator=()**, and **operator==()**.

### template\<typename \_Bi\_iter, typename \_Ch\_type = typename iterator\_traits\<\_Bi\_iter\>::value\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> std::regex\_token\_iterator\< \_Bi\_iter, \_Ch\_type, \_Rx\_traits \>::regex\_token\_iterator (\_Bi\_iter \_\_a, \_Bi\_iter \_\_b, const regex\_type & \_\_re, int \_\_submatch = 0, regex\_constants::match\_flag\_type \_\_m = regex\_constants::match\_default) \[inline\]

Constructs a regex\_token\_iterator...

**Parameters**

*\_\_a* \[IN\] The start of the text to search. \
 *\_\_b* \[IN\] One-past-the-end of the text to search. \
 *\_\_re* \[IN\] The regular expression to search for. \
 *\_\_submatch* \[IN\] Which submatch to return. There are some special values for this parameter:

- •

  \-1 each enumerated subexpression does NOT match the regular expression (aka field splitting)

- •

  0 the entire string matching the subexpression is returned for each match within the text.

- •

  \>0 enumerates only the indicated subexpression from a match within the text.

*\_\_m* \[IN\] Policy flags for match rules.

### template\<typename \_Bi\_iter, typename \_Ch\_type = typename iterator\_traits\<\_Bi\_iter\>::value\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> std::regex\_token\_iterator\< \_Bi\_iter, \_Ch\_type, \_Rx\_traits \>::regex\_token\_iterator (\_Bi\_iter \_\_a, \_Bi\_iter \_\_b, const regex\_type & \_\_re, const std::vector\< int \> & \_\_submatches, regex\_constants::match\_flag\_type \_\_m = regex\_constants::match\_default) \[inline\]

Constructs a regex\_token\_iterator...

**Parameters**

*\_\_a* \[IN\] The start of the text to search. \
 *\_\_b* \[IN\] One-past-the-end of the text to search. \
 *\_\_re* \[IN\] The regular expression to search for. \
 *\_\_submatches* \[IN\] A list of subexpressions to return for each regular expression match within the text. \
 *\_\_m* \[IN\] Policy flags for match rules.

### template\<typename \_Bi\_iter, typename \_Ch\_type = typename iterator\_traits\<\_Bi\_iter\>::value\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> std::regex\_token\_iterator\< \_Bi\_iter, \_Ch\_type, \_Rx\_traits \>::regex\_token\_iterator (\_Bi\_iter \_\_a, \_Bi\_iter \_\_b, const regex\_type & \_\_re, initializer\_list\< int \> \_\_submatches, regex\_constants::match\_flag\_type \_\_m = regex\_constants::match\_default) \[inline\]

Constructs a regex\_token\_iterator...

**Parameters**

*\_\_a* \[IN\] The start of the text to search. \
 *\_\_b* \[IN\] One-past-the-end of the text to search. \
 *\_\_re* \[IN\] The regular expression to search for. \
 *\_\_submatches* \[IN\] A list of subexpressions to return for each regular expression match within the text. \
 *\_\_m* \[IN\] Policy flags for match rules.

### template\<typename \_Bi\_iter, typename \_Ch\_type = typename iterator\_traits\<\_Bi\_iter\>::value\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> template\<std::size\_t \_Nm\> std::regex\_token\_iterator\< \_Bi\_iter, \_Ch\_type, \_Rx\_traits \>::regex\_token\_iterator (\_Bi\_iter \_\_a, \_Bi\_iter \_\_b, const regex\_type & \_\_re, const int(&) \_\_submatches\[\_Nm\], regex\_constants::match\_flag\_type \_\_m = regex\_constants::match\_default) \[inline\]

Constructs a regex\_token\_iterator...

**Parameters**

*\_\_a* \[IN\] The start of the text to search. \
 *\_\_b* \[IN\] One-past-the-end of the text to search. \
 *\_\_re* \[IN\] The regular expression to search for. \
 *\_\_submatches* \[IN\] A list of subexpressions to return for each regular expression match within the text. \
 *\_\_m* \[IN\] Policy flags for match rules.

### template\<typename \_Bi\_iter, typename \_Ch\_type = typename iterator\_traits\<\_Bi\_iter\>::value\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> std::regex\_token\_iterator\< \_Bi\_iter, \_Ch\_type, \_Rx\_traits \>::regex\_token\_iterator (const regex\_token\_iterator\< \_Bi\_iter, \_Ch\_type, \_Rx\_traits \> & \_\_rhs) \[inline\]

Copy constructs a regex\_token\_iterator.

**Parameters**

*\_\_rhs* \[IN\] A regex\_token\_iterator to copy.

## Member Function Documentation

### template\<typename \_Bi\_iter, typename \_Ch\_type = typename iterator\_traits\<\_Bi\_iter\>::value\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> const value\_type & std::regex\_token\_iterator\< \_Bi\_iter, \_Ch\_type, \_Rx\_traits \>::operator\* () const \[inline\]

Dereferences a regex\_token\_iterator.

### template\<typename \_Bi\_iter, typename \_Ch\_type, typename \_Rx\_traits\> regex\_token\_iterator\< \_Bi\_iter, \_Ch\_type, \_Rx\_traits \> & std::regex\_token\_iterator\< \_Bi\_iter, \_Ch\_type, \_Rx\_traits \>::operator++ ()

Increments a regex\_token\_iterator.

References **regex\_token\_iterator()**.

### template\<typename \_Bi\_iter, typename \_Ch\_type = typename iterator\_traits\<\_Bi\_iter\>::value\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> regex\_token\_iterator std::regex\_token\_iterator\< \_Bi\_iter, \_Ch\_type, \_Rx\_traits \>::operator++ (int ) \[inline\]

Postincrements a regex\_token\_iterator.

### template\<typename \_Bi\_iter, typename \_Ch\_type = typename iterator\_traits\<\_Bi\_iter\>::value\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> const value\_type \* std::regex\_token\_iterator\< \_Bi\_iter, \_Ch\_type, \_Rx\_traits \>::operator-\> () const \[inline\]

Selects a regex\_token\_iterator member.

### template\<typename \_Bi\_iter, typename \_Ch\_type, typename \_Rx\_traits\> regex\_token\_iterator\< \_Bi\_iter, \_Ch\_type, \_Rx\_traits \> & std::regex\_token\_iterator\< \_Bi\_iter, \_Ch\_type, \_Rx\_traits \>::operator= (const regex\_token\_iterator\< \_Bi\_iter, \_Ch\_type, \_Rx\_traits \> & \_\_rhs)

Assigns a regex\_token\_iterator to another.

**Parameters**

*\_\_rhs* \[IN\] A regex\_token\_iterator to copy.

References **regex\_token\_iterator()**.

### template\<typename \_Bi\_iter, typename \_Ch\_type, typename \_Rx\_traits\> bool std::regex\_token\_iterator\< \_Bi\_iter, \_Ch\_type, \_Rx\_traits \>::operator== (const regex\_token\_iterator\< \_Bi\_iter, \_Ch\_type, \_Rx\_traits \> & \_\_rhs) const

Compares a regex\_token\_iterator to another for equality.

References **regex\_token\_iterator()**.

## Author

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