From cppreference.com
Defined in header
public:boolalways_noconv()constthrow(); (1)(until C++11)public:boolalways_noconv()constnoexcept;(since C++11)protected:virtualbooldo_always_noconv()constthrow(); (2)(until C++11)protected:virtualbooldo_always_noconv()constnoexcept;(since C++11)1) Public member function, calls the member function do_always_noconv of the most derived class.
2) Returns true if both
and
return std::codecvt_base::noconv for all valid inputs.
Return value
true if this conversion facet performs no conversions, false otherwise.
The non-converting specialization std::codecvt<char,char,std::mbstate_t> returns true.
Notes
This function may be used e.g. in the implementation of
and
to use bulk character copy instead of calling
or
if it is known that the locale imbued in the
does not perform any conversions.
Example
Run this code
#include<iostream>#include<locale>intmain(){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';}Output:
The non-converting char<->char codecvt::always_noconv() returns true while wchar_t<->char codecvt::always_noconv() returns false