std::regex_traits
来自 cppreference.cn
定义于头文件 <regex> |
||
template< class CharT > class regex_traits; |
(since C++11) | |
类型特征模板 regex_traits
为 std::basic_regex 提供操作类型 CharT
所需的类型和函数集合。
由于许多正则表达式操作是 locale 敏感的 (当 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)一起使用,必须使用用户提供的 traits 类。
[编辑] 成员类型
类型 | 定义 |
char_type
|
CharT
|
string_type
|
std::basic_string<CharT> |
locale_type
|
用于正则表达式中本地化行为的 locale。 必须是 可复制构造 (CopyConstructible) |
char_class_type
|
表示字符分类,并能够容纳 lookup_classname 返回的实现定义的集合。 必须是 位掩码类型 (BitmaskType)。 |
[编辑] 成员函数
构造 regex_traits 对象 (公有成员函数) | |
[静态] |
计算空终止字符字符串的长度 (公有静态成员函数) |
确定字符的等价键 (公有成员函数) | |
确定字符的大小写不敏感等价键 (公有成员函数) | |
确定给定字符串的排序键,用于提供排序规则 (公有成员函数) | |
确定字符序列的主排序键,用于确定等价类 (公有成员函数) | |
通过名称获取排序规则元素 (公有成员函数) | |
通过名称获取字符类 (公有成员函数) | |
指示是否属于本地化字符类 (公有成员函数) | |
将表示数字的字符转换为整数值 (公有成员函数) | |
设置 locale (公有成员函数) | |
获取 locale (公有成员函数) |