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 对象
(公开成员函数)
[静态]
计算空终止字符串的长度
(公开静态成员函数)
确定字符的等价关键
(公开成员函数)
决定字符的无关大小写的等价关键
(公开成员函数)
确定给定字符串的搜索关键,用于提供对照顺序
(公开成员函数)
确定字符序列的初等搜索关键,用于确定等价类
(公开成员函数)
以名获得对照元素
(公开成员函数)
以名获得字符类
(公开成员函数)
指示本地化字符类的从属关系
(公开成员函数)
把代表数位的序列翻译成整数值
(公开成员函数)
设置本地环境
(公开成员函数)
获得本地环境
(公开成员函数)

版本历史

  • (当前 | 先前 2017年6月16日 (五) 09:02Fruderica讨论 | 贡献 . . (2,197字节) (-10). . (撤销)
  • 当前 | 先前 2017年6月16日 (五) 09:00Fruderica讨论 | 贡献. . (2,207字节) (-2,506). . (撤销)
  • 当前 | 先前 2013年7月2日 (二) 11:14P12bot讨论 | 贡献 . . (4,713字节) (-145). . (Use {{lc}}. Update links. Various fixes.) (撤销)
  • 当前 | 先前 2012年11月2日 (五) 11:42P12bot讨论 | 贡献 . . (4,858字节) (+241). . (r2.7.3) (机器人添加:de, en, es, fr, it, ja, pt, ru) (撤销)
  • 当前 | 先前 2012年10月27日 (六) 12:11P12讨论 | 贡献 . . (4,617字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 06:00TranslationBot讨论 | 贡献. . (4,617字节) (-120). . (Translated from the English version using Google Translate) (撤销)
  • 当前 | 先前 2012年10月25日 (四) 15:33P12讨论 | 贡献 . . (4,737字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前) 2012年10月25日 (四) 12:00TranslationBot讨论 | 贡献. . (4,737字节) (+4,737). . (Translated from the English version using Google Translate)