std::codecvt<InternT,ExternT,StateT>:: always_noconv, do_always_noconv
| Localization library | |||||||||||||||||||||||||
| Regular expressions library (C++11) | |||||||||||||||||||||||||
| Formatting library (C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
|
codecvt::always_noconv
codecvt::do_always_noconv
|
||||
|
定义于头文件
<locale>
|
||
| (1) | ||
|
public
:
bool always_noconv ( ) const throw ( ) ; |
(C++11 前) | |
|
public
:
bool always_noconv ( ) const noexcept ; |
(C++11 起) | |
| (2) | ||
|
protected
:
virtual bool do_always_noconv ( ) const throw ( ) ; |
(C++11 前) | |
|
protected
:
virtual bool do_always_noconv ( ) const noexcept ; |
(C++11 起) | |
do_always_noconv
。
返回值
true 表示该转换facet不执行任何转换, false 表示其他情况。
不进行转换的特化 std:: codecvt < char , char , std:: mbstate_t > 返回 true 。
注释
此函数可用于例如在实现 std::basic_filebuf::underflow 和 std::basic_filebuf::overflow 时,若已知植入 std::basic_filebuf 的区域设置不执行任何转换,则使用批量字符复制而非调用 std::codecvt::in 或 std::codecvt::out 。
示例
#include <iostream> #include <locale> int main() { std::cout << "The non-converting char<->char codecvt::always_noconv() returns " << std::boolalpha << std::use_facet<std::codecvt<char, char, std::mbstate_t>>( std::locale() ).always_noconv() << '\n' << "while wchar_t<->char codecvt::always_noconv() returns " << std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>( std::locale() ).always_noconv() << '\n'; }
输出:
The non-converting char<->char codecvt::always_noconv() returns true while wchar_t<->char codecvt::always_noconv() returns false