STD::REGEX_TOKEN_ITERATOR(3)

πŸŽ€ std::regex_token_iterator< _Bi_iter, _Ch_type, _Rx_traits > πŸŽ€

omg hi bestie πŸ’– welcome to the libstdc++ Library Functions Manual, section 3, where we're talking about the little iterator that could: std::regex_token_iterator. It lives in the <regex> header and it's literally the main character of "find me all the matches, or just the ones I asked for." Let's get into it πŸ¦‹


✨ NAME ✨

std::regex_token_iterator< _Bi_iter, _Ch_type, _Rx_traits > β€” the iterator that walks over submatches in a range, or splits a text string wide open, no cap πŸ“


✨ 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). πŸ’…

So the whole point of this iterator is to enumerate all β€” or all the specified ones β€” matches of a regular expression inside a text range. And when you dereference it? You get a std::sub_match object. Periodt. ✨

Since: C++11


🧚 Constructor & Destructor Documentation 🧚

🫢 regex_token_iterator ()

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. Heads up bestie: a default-constructed regex_token_iterator is a singular iterator, and it will compare equal to the one-past-the-end value for any iterator of the same type. It's giving "empty but valid" energy 😌

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

🫢 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<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.

🫢 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)

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.

🫢 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)

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.

🫢 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)

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.

🫢 regex_token_iterator (const regex_token_iterator< _Bi_iter, _Ch_type, _Rx_traits > & __rhs)

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. Twin energy fr fr πŸ‘―

Parameters

  • __rhs [IN] A regex_token_iterator to copy.

πŸ’… Member Function Documentation πŸ’…

operator*

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. Give me the goods bestie ✨

operator++

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. Next one, let's gooo πŸ”₯

References regex_token_iterator().

operator++ (int)

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. Same vibe, but it hands you the old value first πŸ’–

operator->

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. Pointing at the member like πŸ‘‰πŸ‘‘

operator=

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. Glow-up via assignment, honestly 🌈

Parameters

  • __rhs [IN] A regex_token_iterator to copy.

References regex_token_iterator().

operator==

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. Are we the same? vibe check 🫢

References regex_token_iterator().


πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for libstdc++ from the source code. Not me writing a single line of this by hand, the tooling ate and left no crumbs πŸ’…


and that's the whole page bestie!! mwah πŸ’– this was the libstdc++ manual, section 3, page std::regex...Rx_traits >(3) β€” go forth and enumerate those submatches, you absolute icon βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from
  • arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
  • fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: libstdc++-docs 16.2.1-2.fc44
  • fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms