| 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 | ||||
numpunct::truenamenumpunct::do_truenamenumpunct::falsenamenumpunct::do_falsename |
Defined in header <locale> | ||
public: string_type truename()const; | (1) | |
public: string_type falsename()const; | (2) | |
protected: virtual string_type do_truename()const; | (3) | |
protected: virtual string_type do_falsename()const; | (4) | |
do_truename anddo_falsename of the most derived class respectively.string_type to use as the representation oftrue. The standard specializations ofstd::numpunct return"true" andL"true".string_type to use as the representation offalse. The standard specializations ofstd::numpunct return"false" andL"false".#include <iomanip>#include <iostream>#include <locale> struct custom_tf:std::numpunct<char>{std::string do_truename()const{return{'t'};}std::string do_falsename()const{return{'f'};}}; int main(){std::cout<<std::boolalpha; // default boolalpha outputstd::cout<<"Default locale,\n"" boolalpha true: "<<true<<"\n"" boolalpha false: "<<false<<"\n\n"; // with custom_tf applied to localestd::cout.imbue(std::locale(std::cout.getloc(), new custom_tf));std::cout<<"Locale with modified numpunct,\n"" boolalpha true: "<<true<<"\n"" boolalpha false: "<<false<<'\n';}
Output:
Default locale, boolalpha true: true boolalpha false: false Locale with modified numpunct, boolalpha true: t boolalpha false: f