std::regex_traits::transform_primary

来自cppreference.com
< cpp‎ | regex‎ | regex traits

template< class ForwardIt >
string_type transform_primary( ForwardIt first, ForwardIt last) const
获得主要的排序键的字符序列(忽略大小写的情况下,变音符号,变体等)[first, last),比另一个主要的排序键与operator<如果一个主的排序键比较少,那么第一个排序键的字符序列之前的字符序列产生第二个排序的关键,在当前充满语言环境的整理顺序.
原文:
Obtains the primary (ignoring case, diacritics, variant, etc) sort key for the character sequence [first, last), such that if a primary sort key compares less than another primary sort key with operator<, then the character sequence that produced the first sort key comes before the character sequence that produced the second sort key, in the currently imbued locale's primary collation order.
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
正则表达式库使用这一特点,对等价类的字符相匹配。例如,正则表达式[[=a=]]是相当于字符c1如果traits.transform_primary(c1)相当于traits.transform_primary("a")(这是真的为任何c1"AÀÁÂÃÄÅaàáâãäå")。需要注意的是transform_primary()需要的字符序列等价类的说法,因为可能是多字符,如[[=ll=]].
原文:
The regex library uses this trait to match characters against equivalence classes. For example, the regex [[=a=]] is equivalent to the character c1 if traits.transform_primary(c1) is equivalent to traits.transform_primary("a") (which is true for any c1 from "AÀÁÂÃÄÅaàáâãäå"). Note that transform_primary() takes a character sequence argument because equivalence classes may be multicharacter, such as [[=ll=]].
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
有没有可移植的方式定义主条款std::locale日期排序键从核对经由std::collate::transform()主等价密钥的密钥转换区域设置特定的,并且如果用户取代std::collate刻面,该转换的不再已知标准库中的std::regex_traits。标准库专业的std::regex_traits当前充满的地区,除非std::collate方面不会取代用户返回一个空字符串,也可以匹配系统提供的std::collate方面),在这种情况下,std::collate_byname<charT>::transform(first, last)执行,它的产生是排序键的转换为预期的​​主要排序键使用特定语言环境的转换.
原文:
There is no portable way to define primary sort key in terms of std::locale since the conversion from the collation key returned by std::collate::transform() to the primary equivalence key is locale-specific, and if the user replaces the std::collate facet, that conversion is no longer known to the standard library's std::regex_traits. Standard library specializations of std::regex_traits return an empty string unless the std::collate facet of the currently-imbued locale was not replaced by the user, and still matches the system-supplied std::collate facet), in which case std::collate_byname<charT>::transform(first, last) is executed and the sort key it produces is converted to the expected primary sort key using a locale-specific conversion.
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。

[编辑] 参数

first, last -
一对迭代器,它决定了要比较的字符序列
原文:
a pair of iterators which determines the sequence of characters to compare
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
类型要求
-
ForwardIt 必须满足 ForwardIterator 的要求。

[编辑] 返回值

主要的排序键的字符序列[first, last)在目前充满的区域设置,忽略大小写的情况下,变种,变音符号,等等
原文:
The primary sort key for the character sequence [first, last) in the currently imbued locale, ignoring case, variant, diacritics, etc.
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。

[编辑] 示例

演示正则表达式的功能,通过transform_primary()
原文:
Demonstrates the regex feature that works through transform_primary()
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。

#include <iostream>
#include <regex>
 
int main()
{
    std::locale::global(std::locale("en_US.UTF-8"));
    std::wstring str = L"AÀÁÂÃÄÅaàáâãäå";
    std::wregex re(L"[[=a=]]*", std::regex::basic);
    std::cout << std::boolalpha << std::regex_match(str, re) << '\n';
}

输出:

true