widen
描述 (Description)
它用于加宽字符和内部,此函数只调用虚拟保护成员do_widen,默认情况下在通用模板和字符串特化(ctype
声明 (Declaration)
以下是std :: ctype :: widen的声明。
C++98
char_type tolower (char_type c) const;
C++11
char_type tolower (char_type c) const;
参数 (Parameters)
c - 它是一种char类型。
low,high - 它是指向字符序列的开头和结尾的指针。
to - 它是指向构面字符类型的一系列元素的指针。
返回值 (Return Value)
它返回c的转换。
异常 (Exceptions)
如果抛出异常,则facet对象中没有更改,但范围中的字符可能已受到影响。
数据竞争 (Data races)
http://tpcg.io/YqaGeY访问该对象以及[低,高]范围内的元素。
例子 (Example)
在下面的例子中解释了std :: ctype :: widen。
#include <iostream>
#include <locale>
int main () {
std::locale loc;
const char narrow_phrase[] = "Sairamkrishna Mammahe";
wchar_t wide_phrase[sizeof(narrow_phrase)];
std::wcout << L"The first wide character is: ";
wchar_t wc = std::use_facet< std::ctype<wchar_t> >(loc).widen ( *narrow_phrase );
std::wcout << wc << std::endl;
std::wcout << L"The wide-character phrase is: ";
std::use_facet< std::ctype<wchar_t> >(loc).widen (narrow_phrase,
narrow_phrase+sizeof(narrow_phrase),
wide_phrase);
std::wcout << wide_phrase << std::endl;
return 0;
}
让我们编译并运行上面的程序,这将产生以下结果 -
The first wide character is: S
The wide-character phrase is: Sairamkrishna Mammahe