STD::REGEX_TRAITS(3cxx)
π NAME π
okay bestie, welcome to the std::regex_traits< _Ch_type >(3cxx) page π This is all about std::regex_traits< _Ch_type > β and the official vibe is: describes aspects of a regular expression. periodt β¨
β¨ SYNOPSIS β¨
#include <regex>
πΈ Public Types πΈ
the type aliases are giving βsmall but iconicβ:
typedef _RegexMask char_class_type
typedef _Ch_type char_type
typedef std::locale locale_type
typedef std::basic_string< char_type > string_type
π Public Member Functions π
regex_traits()β Constructs a default traits object. default-constructor slay π«Άlocale_type getloc () constβ Gets a copy of the current locale in use by theregex_traitsobject.locale_type imbue (locale_type __loc)β Imbues theregex_traitsobject with a copy of a new locale.bool isctype (_Ch_type __c, char_class_type __f) constβ Determines ifcis a member of an identified class.template<typename _Fwd_iter > char_class_type lookup_classname (_Fwd_iter __first, _Fwd_iter __last, bool __icase=false) constβ Maps one or more characters to a named character classification.template<typename _Fwd_iter > string_type lookup_collatename (_Fwd_iter __first, _Fwd_iter __last) constβ Gets a collation element by name.template<typename _Fwd_iter > string_type transform (_Fwd_iter __first, _Fwd_iter __last) constβ Gets a sort key for a character sequence.template<typename _Fwd_iter > string_type transform_primary (_Fwd_iter __first, _Fwd_iter __last) constβ Gets a sort key for a character sequence, independent of case.char_type translate (char_type __c) constβ Performs the identity translation.char_type translate_nocase (char_type __c) constβ Translates a character into a case-insensitive equivalent.int value (_Ch_type __ch, int __radix) constβ Converts a digit to anint.
β Static Public Member Functions β
static std::size_t length (const char_type *__p)β Gives the length of a C-style string starting at__p.
π‘οΈ Protected Attributes π‘οΈ
locale_type _M_localeβ yes bestie, thatβs the protected attribute, no extra lore π
π« Detailed Description π«
the docs literally print the template line as template<typename _Ch_type> and then the class line as:
class std::regex_traits< _Ch_type >"Describes aspects of a regular expression.
(yes, thereβs a stray quote in there β iconic, not me fixing it π)
so what is this class? itβs a regular expression traits class that satisfies the requirements of section [28.7] β¨
the class regex is parameterized around a set of related types and functions used to complete the definition of its semantics. this class satisfies the requirements of such a traits class. no cap π«Ά
Since: C++11
π§Έ Constructor & Destructor Documentation π§Έ
πΈ regex_traits ()
template<typename _Ch_type > std::regex_traits< _Ch_type >::regex_traits ()
[inline]
Constructs a default traits object. cute, simple, default π
π Member Function Documentation π
π¦ getloc ()
template<typename _Ch_type > locale_type std::regex_traits< _Ch_type
>::getloc () const [inline]
Gets a copy of the current locale in use by the regex_traits object.
Referenced by std::regex_traits< _CharType >::isctype().
π imbue (locale_type __loc)
template<typename _Ch_type > locale_type std::regex_traits< _Ch_type
>::imbue (locale_type __loc) [inline]
Imbues the regex_traits object with a copy of a new locale.
Parameters
__locβ A locale.
Returns
- a copy of the previous locale in use by the
regex_traitsobject.
Note
Callingimbuewith a different locale than the one currently in use invalidates all cached data held by*this. thatβs the drama, bestie π
π₯ isctype (_Ch_type __c, char_class_type __f)
template<typename _Ch_type > bool std::regex_traits< _Ch_type >::isctype
(_Ch_type __c, char_class_type __f) const
Determines if c is a member of an identified class.
Parameters
__cβ a character.__fβ a class type (as returned fromlookup_classname).
Returns
trueif the character__cis a member of the classification represented by__f,falseotherwise.
Exceptions
std::bad_castif the current locale does not have actypefacet.
π length (const char_type * __p)
template<typename _Ch_type > static std::size_t std::regex_traits< _Ch_type
>::length (const char_type * __p) [inline], [static]
Gives the length of a C-style string starting at __p.
Parameters
__pβ a pointer to the start of a character sequence.
Returns
- the number of characters between
*__pand the first default-initialized value of typechar_type. In other words, uses the C-string algorithm for determining the length of a sequence of characters.
References std::basic_string< _CharT, _Traits, _Alloc >::length().
πΈ lookup_classname (_Fwd_iter __first, _Fwd_iter __last, bool __icase = false)
template<typename _Ch_type > template<typename _Fwd_iter > regex_traits<
_Ch_type >::char_class_type std::regex_traits< _Ch_type
>::lookup_classname (_Fwd_iter __first, _Fwd_iter __last, bool __icase =
false) const
Maps one or more characters to a named character classification.
Parameters
__firstβ beginning of the character sequence.__lastβ one-past-the-end of the character sequence.__icaseβ ignores the case of the classification name.
Returns
- an unspecified value that represents the character classification named by the character sequence designated by the iterator range
[__first, __last). Ificaseis true, the returned mask identifies the classification regardless of the case of the characters to be matched (for example,[[:lower:]]is the same as[[:alpha:]]), otherwise a case-dependent classification is returned. The value returned shall be independent of the case of the characters in the character sequence. If the name is not recognized then returns a value that compares equal to0.
At least the following names (or their wide-character equivalent) are supported.
dwsalnumalphablankcntrldigitgraphlowerprintpunctspaceupperxdigit
π«Ά lookup_collatename (_Fwd_iter __first, _Fwd_iter __last)
template<typename _Ch_type > template<typename _Fwd_iter > regex_traits<
_Ch_type >::string_type std::regex_traits< _Ch_type
>::lookup_collatename (_Fwd_iter __first, _Fwd_iter __last) const
Gets a collation element by name.
Parameters
__firstβ beginning of the collation element name.__lastβ one-past-the-end of the collation element name.
Returns
- a sequence of one or more characters that represents the collating element consisting of the character sequence designated by the iterator range
[__first, __last). Returns an empty string if the character sequence is not a valid collating element.
π transform (_Fwd_iter __first, _Fwd_iter __last)
template<typename _Ch_type > template<typename _Fwd_iter > string_type
std::regex_traits< _Ch_type >::transform (_Fwd_iter __first, _Fwd_iter
__last) const [inline]
Gets a sort key for a character sequence.
Parameters
__firstβ beginning of the character sequence.__lastβ one-past-the-end of the character sequence.
Returns
- a sort key for the character sequence designated by the iterator range
[F1, F2)such that if the character sequence[G1, G2)sorts before the character sequence[H1, H2)thenv.transform(G1, G2) < v.transform(H1, H2).
what this really does is provide a more efficient way to compare a string to multiple other strings in locales with fancy collation rules and equivalence classes.
Returns
- a locale-specific sort key equivalent to the input range.
Exceptions
std::bad_castif the current locale does not have acollatefacet.
References std::basic_string< _CharT, _Traits, _Alloc >::data(), and std::basic_string< _CharT, _Traits, _Alloc >::size().
Referenced by std::regex_traits< _Ch_type >::transform_primary().
π¦ transform_primary (_Fwd_iter __first, _Fwd_iter __last)
template<typename _Ch_type > template<typename _Fwd_iter > string_type
std::regex_traits< _Ch_type >::transform_primary (_Fwd_iter __first,
_Fwd_iter __last) const [inline]
Gets a sort key for a character sequence, independent of case.
Parameters
__firstβ beginning of the character sequence.__lastβ one-past-the-end of the character sequence.
Effects: if typeid(use_facet<collate<_Ch_type> >) == typeid(collate_byname<_Ch_type>) and the form of the sort key returned by collate_byname<_Ch_type>::transform(__first, __last) is known and can be converted into a primary sort key then returns that key, otherwise returns an empty string.
Todo
Implement this function correctly. yes bestie, the docs said it, not me π
References std::regex_traits< _Ch_type >::transform().
π translate (char_type __c)
template<typename _Ch_type > char_type std::regex_traits< _Ch_type
>::translate (char_type __c) const [inline]
Performs the identity translation.
Parameters
__cβ A character to the locale-specific character set.
Returns
__c.
π translate_nocase (char_type __c)
template<typename _Ch_type > char_type std::regex_traits< _Ch_type
>::translate_nocase (char_type __c) const [inline]
Translates a character into a case-insensitive equivalent.
Parameters
__cβ A character to the locale-specific character set.
Returns
- the locale-specific lower-case equivalent of
__c.
Exceptions
std::bad_castif the imbued locale does not support thectypefacet.
π₯ value (_Ch_type __ch, int __radix)
template<typename _Ch_type > int std::regex_traits< _Ch_type >::value
(_Ch_type __ch, int __radix) const
Converts a digit to an int.
Parameters
__chβ a character representing a digit.__radixβ the radix if the numeric conversion (limited to8,10, or16).
Returns
- the value represented by the digit
__chin baseradixif the character__chis a valid digit in baseradix; otherwise returns-1.
References std::basic_ios< _CharT, _Traits >::fail(), std::hex(), and std::oct().
π Author π
Generated automatically by Doxygen for libstdc++ from the source code.
sign-off time, bestie: this pageβs footer is all libstdc++std::regex_traits< _Ch_type >(3cxx) β source/version energy is libstdc++, generated by Doxygen from the source code, and thereβs no date printed, so the calendar said nothing and I respect that πβ¨
π¦ where this page comes from
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms