std::regex_traits
来自 cppreference.cn
在头文件 <regex> 中定义 |
||
template< class CharT > class regex_traits; |
(C++11 起) | |
类型特性模板 regex_traits
为 std::basic_regex 提供操作类型 CharT
所需的类型集和函数集。
由于许多正则表达式操作都是与区域设置相关的(当设置 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 对象 (public member function) | |
[静态] |
计算以 null 结尾的字符字符串的长度 (public static member function) |
确定字符的等价键 (public member function) | |
确定字符的大小写不敏感等价键 (public member function) | |
确定给定字符串的排序键,用于提供整理顺序 (public member function) | |
确定字符序列的主排序键,用于确定等价类 (public member function) | |
按名称获取整理元素 (public member function) | |
按名称获取字符类 (public member function) | |
指示是否属于本地化字符类 (public member function) | |
将表示数字的字符转换为整数值 (public member function) | |
设置区域设置 (public member function) | |
获取区域设置 (public member function) |