std::numpunct<CharT>::truename, do_truename, falsename, 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) |
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
#include <iostream> #include <locale> #include <iomanip> 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; std::cout << "default locale: " << true << true << false << false << '\n'; std::cout.imbue(std::locale(std::cout.getloc(), new custom_tf)); std::cout << "locale with modified numpunct: " << true << true << false << false << '\n'; }
Output:
default locale: truetruefalsefalse locale with modified numpunct: ttff
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/locale/numpunct/truefalsename