STD::SUB_MATCH(3)
πΈ std::sub_match< _BiIter > β Library Functions Manual, section (3) π
okay bestie, welcome to the group chat for std::sub_match< _BiIter >. this is a Library Functions Manual situation, section 3, and she's giving very much "I am one tiny piece of <regex> and I have OPINIONS." let's get into it π«Ά
β¨ NAME β¨
std::sub_match< _BiIter > β the little object that holds one matched sub-expression. no cap. π
β¨ SYNOPSIS β¨
#include <regex>
π Public Types π
typedef __iter_traits::difference_type difference_typetypedef _BiIter iteratortypedef basic_string< value_type > string_typetypedef __iter_traits::value_type value_type
π¦ Public Member Functions π¦
int compare (const sub_match &__s) constβ Compares this and another matched sequence.difference_type length () const noexceptβ Gets the length of the matching sequence.operator string_type () constβ Gets the matching sequence as a string.string_type str () constβ Gets the matching sequence as a string.void swap (sub_match &__s) noexcept(__is_nothrow_swappable< _BiIter >::value)β Swap the values of twosub_matchobjects.int compare (const string_type &__s) constβ Compares thissub_matchto a string.int compare (const value_type *__s) constβ Compares thissub_matchto a string.
π Public Attributes π
iterator firstbool matchediterator second
π Related Symbols π
heads up bestie β (Note that these are not member symbols.) they're just, like, the friends she rolls with. π
template<typename _BiIter> bool operator== (const sub_match< _BiIter > &__lhs, const sub_match< _BiIter > &__rhs)β Tests the equivalence of two regular expression submatches.template<typename _BiIter> auto operator<=> (const sub_match< _BiIter > &__lhs, const sub_match< _BiIter > &__rhs) noexcept(__detail::__is_contiguous_iter< _BiIter >::value)β Three-way comparison of two regular expression submatches.template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> bool operator== (const sub_match< _Bi_iter > &__lhs, const __sub_match_string< _Bi_iter, _Ch_traits, _Ch_alloc > &__rhs)β Tests the equivalence of a regular expression submatch and a string.template<typename _Bi_iter, typename _Ch_traits, typename _Alloc> auto operator<=> (const sub_match< _Bi_iter > &__lhs, const __sub_match_string< _Bi_iter, _Ch_traits, _Alloc > &__rhs) noexcept(__detail::__is_contiguous_iter< _Bi_iter >::value)β Three-way comparison of a regular expression submatch and a string.template<typename _Bi_iter> bool operator== (const sub_match< _Bi_iter > &__lhs, typename iterator_traits< _Bi_iter >::value_type const *__rhs)β Tests the equivalence of a regular expression submatch and a C string.template<typename _Bi_iter> auto operator<=> (const sub_match< _Bi_iter > &__lhs, typename iterator_traits< _Bi_iter >::value_type const *__rhs) noexcept(__detail::__is_contiguous_iter< _Bi_iter >::value)β Three-way comparison of a regular expression submatch and a C string.template<typename _Bi_iter> bool operator== (const sub_match< _Bi_iter > &__lhs, typename iterator_traits< _Bi_iter >::value_type const &__rhs)β Tests the equivalence of a regular expression submatch and a character.template<typename _Bi_iter> auto operator<=> (const sub_match< _Bi_iter > &__lhs, typename iterator_traits< _Bi_iter >::value_type const &__rhs) noexcept(__detail::__is_contiguous_iter< _Bi_iter >::value)β Three-way comparison of a regular expression submatch and a character.template<typename _Ch_type, typename _Ch_traits, typename _Bi_iter> basic_ostream< _Ch_type, _Ch_traits > & operator<< (basic_ostream< _Ch_type, _Ch_traits > &__os, const sub_match< _Bi_iter > &__m)β Inserts a matched string into an output stream.
π Detailed Description π
template<typename _BiIter>
class std::sub_match< _BiIter >
"A sequence of characters matched by a particular marked sub-expression." β¨ okay so that's the whole personality.
An object of this class is basically a pair of iterators marking a matched subexpression inside a regular expression pattern match. and the way that she can be converted to and compared with std::basic_string objects of the same character type as the pattern matched by the regular expression?? iconic behaviour, honestly.
A sub_match<Iter> has a public base class of type pair<Iter, Iter>, so she inherits pair's data members named first and second. the iterators that make up the pair are the usual half-open interval referencing the actual original pattern matched. no cap, half-open, meaning it does not include the second one. π
Since β C++11 (vintage, but in a baby way πΈ)
π§ Member Function Documentation π§
template<typename _BiIter> int std::sub_match< _BiIter >::compare (const string_type & __s) const [inline]
Compares this sub_match to a string.
Parameters
__sβ A string to compare to thissub_match.
Return values
negativeβ This matched sequence will collate before__s.zeroβ This matched sequence is equivalent to__s.positiveβ This matched sequence will collate after__s.
template<typename _BiIter> int std::sub_match< _BiIter >::compare (const sub_match< _BiIter > & __s) const [inline]
Compares this and another matched sequence.
Parameters
__sβ Another matched sequence to compare to this one.
Return values
negativeβ This matched sequence will collate before__s.zeroβ This matched sequence is equivalent to__s.positiveβ This matched sequence will collate after__s.
Referenced by std::sub_match< const char * >::operator==(), and std::sub_match< const char * >::operator==(). (yes bestie, it's listed twice, we don't make the rules π)
template<typename _BiIter> int std::sub_match< _BiIter >::compare (const value_type * __s) const [inline]
Compares this sub_match to a string.
Parameters
__sβ A string to compare to thissub_match.
Return values
negativeβ This matched sequence will collate before__s.zeroβ This matched sequence is equivalent to__s.positiveβ This matched sequence will collate after__s.
template<typename _BiIter> difference_type std::sub_match< _BiIter >::length () const [inline], [noexcept]
Gets the length of the matching sequence. that's it. that's the function. noexcept queen π
template<typename _BiIter> std::sub_match< _BiIter >::operator string_type () const [inline]
Gets the matching sequence as a string.
Returns β the matching sequence as a string.
This is the implicit conversion operator. It is identical to the str() member function except that it will want to pop up in unexpected places and cause a great deal of confusion and cursing from the unwary. π bestie this is a WARNING. she will show up uninvited. she is the main character. she was not on the guest list. π
template<typename _BiIter> string_type std::sub_match< _BiIter >::str () const [inline]
Gets the matching sequence as a string.
Returns β the matching sequence as a string.
Referenced by std::sub_match< const char * >::operator string_type().
template<typename _BiIter> void std::sub_match< _BiIter >::swap (sub_match< _BiIter > & __s) [inline], [noexcept]
Swap the values of two sub_match objects. trading places, very freaky friday of them π₯
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. (not a human, just a very dedicated robot, we stan π«Ά)
okay that's the whole page, love u, bye π β this has been std::sub_m...< _BiIter >(3), brought to you by libstdc++, and remember: no gatekeeping regex. periodt. ππβ¨
π¦ 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