Namespaces
Variants

std::regex_traits<CharT>:: transform

From cppreference.net
Regular expressions library
Classes
(C++11)
Algorithms
Iterators
Exceptions
Traits
Constants
(C++11)
Regex Grammar
template < class ForwardIt >
string_type transform ( ForwardIt first, ForwardIt last ) const ;

获取字符序列 [ first , last ) 的排序键,使得若某排序键通过 operator < 比较小于另一排序键,则生成第一个排序键的字符序列在当前嵌入区域设置的排序规则中位于生成第二个排序键的字符序列之前。

例如,当设置了正则表达式标志 std::regex_constants::collate 时,序列 [a-b] 将匹配某个字符 c1 ,当且仅当 traits. transform ( "a" ) <= traits. transform ( c1 ) <= traits. transform ( "b" ) 。需注意此函数以字符序列作为参数,以适配类似 [ [ . ae . ] - d ] 这类范围定义。

标准库对 std::regex_traits 的特化版本会返回 std:: use_facet < std:: collate < CharT >> ( getloc ( ) ) . transform ( str. data ( ) , str. data ( ) + str. length ( ) ) ,其中 str 是通过 string_type str ( first, last ) 构造的临时字符串。

参数

first, last - 一对 LegacyForwardIterator s ,用于指定要比较的字符序列
类型要求
-
ForwardIt 必须满足 LegacyForwardIterator 的要求。

返回值

在当前嵌入的区域设置中,字符序列 [ first , last ) 的排序键。

示例