std::collate::transform, std::collate::do_transform

来自cppreference.com
< cpp‎ | locale‎ | collate

定义于头文件 <locale>
public:
string_type transform( const CharT* low, const CharT* high ) const;
(1)
protected:
string_type do_transform( const CharT* low, const CharT* high ) const;
(2)
1)
公共成员函数,调用受保护的最派生类的虚成员函数do_transform的.
原文:
public member function, calls the protected virtual member function do_transform of the most derived class.
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
2)
转换的字符序列[low, high)一个字符串相比,字典(例如与operator<的字符串)与另一个字符串调用transform()的结果,产生相同的结果,在相同的两个字符串调用do_compare().
原文:
Converts the character sequence [low, high) to a string that, compared lexicographically (e.g. with operator< for strings) with the result of calling transform() on another string, produces the same result as calling do_compare() on the same two strings.
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。

目录

[编辑] 参数

low -
指针序列中的第一个字符转换
原文:
pointer to the first character in the sequence to transform
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
high -
过去的指针的序列转换
原文:
one past the end pointer for the sequence to transform
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。

[编辑] 返回值

该字符串改造,使变换后的字符串的字典比较可以用来代替原稿整理。在“C”语言环境中,返回的字符串是完全相同的副本[low, high)。在其他语言环境中,返回的字符串的内容是实现定义的,规模相当长的时间.
原文:
The string transformed so that lexicographic comparison of the transformed strings may be used instead of collating of the originals. In the "C" locale, the returned string is the exact copy of [low, high). In other locales, the contents of the returned string are implementation-defined, and the size may be considerably longer.
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。

[编辑] 注释

除了使用排序规则,执行特定的格式变换后的字符串被称为的std :: regex_traits <> :: transform_primary,这是能够提取的等价类信息.
原文:
In addition to the the use in collation, the implementation-specific format of the transformed string is known to 的std :: regex_traits <> :: transform_primary, which is able to extract the equivalence class information.
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。

[编辑] 示例

#include <iostream>
#include <iomanip>
#include <locale>
 
int main()
{
    std::locale::global(std::locale("sv_SE.utf8"));
    auto& f = std::use_facet<std::collate<wchar_t>>(std::locale());
 
    std::wstring in1 = L"\u00e4ngel";
    std::wstring in2 = L"\u00e5r";
 
    std::wstring out1 = f.transform(&in1[0], &in1[0] + in1.size());
    std::wstring out2 = f.transform(&in2[0], &in2[0] + in2.size());
 
    std::wcout << "In the Swedish locale: ";
    if(out1 < out2)
         std::wcout << in1 << " before " << in2 << '\n';
    else
         std::wcout << in2 << " before " << in1 << '\n';
 
    std::wcout << "In lexicographic comparison: ";
    if(in1 < in2)
         std::wcout << in1 << " before " << in2 << '\n';
    else
         std::wcout << in2 << " before " << in1 << '\n';
 
}

输出:

In the Swedish locale: år before ängel
In lexicographic comparison: ängel before år

[编辑] 另请参阅

转换一个字符串,使strcmp和strcoll产生相同的结果
原文:
transform a string so that strcmp would produce the same result as strcoll
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。

(函数) [编辑]
转换宽字符串,使wcscmp和wcscoll产生相同的结果
原文:
transform a wide string so that wcscmp would produce the same result as wcscoll
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。

(函数) [编辑]