class template
<regex>

std::regex_traits

template <class charT> class regex_traits;
Regex traits
Regex traits classes specify some of the semantics for regular expressions.

Every basic_regex object uses the member functions provided by its regex traits class to perform some of its most basic tasks.

regex_traits is a class template used as default regex traits by standard basic_regex objects.

[Note: regex_traits refers to the name of a class template defined in header <regex>, while regex traits (no underscore) refers generically to a certain kind of classes. This page makes reference to both.]

An instantitation of basic_regex other that regex can use a different class as regex traits class to customize the behavior of the basic_regex object.

A custom regex traits does not need to have the standard regex_traits class template as a base class, but it shall define the same members and respect its required semantics.

The reference in these pages includes in its description both the behavior of the standard regex_traits class and the required behavior for other classes that intend to be used as regex traits classes.

Template parameters

charT
The character type.
Strings used with the basic_regex object are sequences of characters of this type.

Member types

The following aliases are member types of regex_traits. Any custom regex traits is expected to have these same member types defined:

member typerequirement for regex traits classesdefinition in regex_traits
char_typethe character type (the same as the one used in the basic_regex object)the first template parameter (charT)
string_typebasic_string<char_type> (see string)basic_string<charT>
locale_typea copy-constructible locale typethe standard locale type
char_class_typea bitmask type suitable as return type of member lookup_classnamea bitmask type

Member functions