std::codecvt<InternT,ExternT,StateT>::always_noconv, do_always_noconv
来自 cppreference.cn
定义于头文件 <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 起) | |
1) 公有成员函数,调用最派生类的成员函数
do_always_noconv
。[编辑] 返回值
true 如果此转换 facet 不执行任何转换,否则返回 false。
非转换特化 std::codecvt<char, char, std::mbstate_t> 返回 true。
[编辑] 注解
此函数可能用于例如 std::basic_filebuf::underflow 和 std::basic_filebuf::overflow 的实现中,以使用批量字符复制而不是调用 std::codecvt::in 或 std::codecvt::out,如果已知在 std::basic_filebuf 中注入的区域设置不执行任何转换。
[编辑] 示例
运行此代码
#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