std::regex_traits
定义于头文件
<regex> |
||
template< class CharT >
class regex_traits; |
(C++11 起) | |
类型特性模板 regex_traits
将类型集合及在类型 CharT
上的操作所需的函数提供给 std::basic_regex 。
因为大多数 regex 操作是对本地环境敏感的(设置 std::regex_constants::collate 标志时),从而 regex_traits 类典型地保有一个作为私有成员的 std::locale 实例。
标准特化
标准库定义 std::regex_traits
的二个特化:
std::regex_traits<char> |
|
std::regex_traits<wchar_t> |
这些特化使得 std::basic_regex<char> (别名 std::regex )和 std::basic_regex<wchar_t> (别名 std::wregex )可用。为将 std::basic_regex 用于其他字符类型(例如 char32_t ),必须使用用户提供的特性类。
成员类型
类型 | 定义 |
char_type |
CharT |
string_type |
std::basic_string<CharT> |
locale_type |
用于正则表达式中本地化行为的本地环境。必须为可复制构造 (CopyConstructible) |
char_class_type |
表示字符分类,并足以保有 lookup_classname 所返回的实现指定集合。必须是位掩码类型 (BitmaskType) 。 |
成员函数
构造 regex_traits 对象 (公开成员函数) |
|
[静态]
|
计算空终止字符串的长度 (公开静态成员函数) |
确定字符的等价关键 (公开成员函数) |
|
决定字符的无关大小写的等价关键 (公开成员函数) |
|
确定给定字符串的搜索关键,用于提供对照顺序 (公开成员函数) |
|
确定字符序列的初等搜索关键,用于确定等价类 (公开成员函数) |
|
以名获得对照元素 (公开成员函数) |
|
以名获得字符类 (公开成员函数) |
|
指示本地化字符类的从属关系 (公开成员函数) |
|
把代表数位的序列翻译成整数值 (公开成员函数) |
|
设置本地环境 (公开成员函数) |
|
获得本地环境 (公开成员函数) |