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_typetypedef std::forward_iterator_tag iterator_categorytypedef std::input_iterator_tag iterator_concepttypedef const value_type * pointertypedef const value_type & referencetypedef basic_regex< _Ch_type, _Rx_traits > regex_typetypedef sub_match< _Bi_iter > value_type
π Public Member Functions
regex_token_iterator ()β Default constructs aregex_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)=deleteregex_token_iterator (_Bi_iter, _Bi_iter, const regex_type &&, const std::vector< int > &, regex_constants::match_flag_type=regex_constants::match_default)=deleteregex_token_iterator (_Bi_iter, _Bi_iter, const regex_type &&, initializer_list< int >, regex_constants::match_flag_type=regex_constants::match_default)=deleteregex_token_iterator (_Bi_iter, _Bi_iter, const regex_type &&, int=0, regex_constants::match_flag_type=regex_constants::match_default)=deleteregex_token_iterator (const regex_token_iterator &__rhs)β Copy constructs aregex_token_iterator.const value_type & operator* () constβ Dereferences aregex_token_iterator.regex_token_iterator & operator++ ()β Increments aregex_token_iterator.regex_token_iterator operator++ (int)β Postincrements aregex_token_iterator.const value_type * operator-> () constβ Selects aregex_token_iteratormember.regex_token_iterator & operator= (const regex_token_iterator &__rhs)β Assigns aregex_token_iteratorto another.bool operator== (const regex_token_iterator &__rhs) constβ Compares aregex_token_iteratorto 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:-1each enumerated subexpression does NOT match the regular expression (aka field splitting)0the entire string matching the subexpression is returned for each match within the text.>0enumerates 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] Aregex_token_iteratorto 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] Aregex_token_iteratorto 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