From cppreference.com
Defined in header
public:string_typetruename()const; (1) public:string_typefalsename()const; (2) protected:virtualstring_typedo_truename()const; (3) protected:virtualstring_typedo_falsename()const; (4) 1,2) Public member function, calls the member function do_truename and do_falsename of the most derived class respectively.
3) Returns the string to be used as the representation of the boolean value true.
4) Returns the string to be used as the representation of the boolean value false.
Return value
1,3) The object of type string_type to use as the representation of true. The standard specializations of std::numpunct return "true" and L"true".
2,4) The object of type string_type to use as the representation of false. The standard specializations of std::numpunct return "false" and L"false".
Example
Run this code
#include<iomanip>#include<iostream>#include<locale>structcustom_tf:std::numpunct<char>{std::stringdo_truename()const{return{'t'};}std::stringdo_falsename()const{return{'f'};}};intmain(){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(),newcustom_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