public member function
<locale>

std::numpunct::truename

string_type truename() const;
String representation of true
Returns the string used to represent the boolean value true.

Internally, this function simply calls the virtual protected member do_truename, which for the standard specializations returns:
specializationreturns
numpunct<char>"true"
numpunct<wchar_t>L"true"

Parameters

none

Return value

The string used to represent the boolean value true.
Member type string_type is a basic_string type with the same character type as the facet (defined as an alias of basic_string<charT>, where charT is numpunct's template parameter).

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// numpunct::truename example
#include <iostream>       // std::cout
#include <string>         // std::string
#include <locale>         // std::locale, std::numpunct, std::use_facet

int main ()
{
  const std::numpunct<char>& punct_facet =
    std::use_facet<std::numpunct<char> >(std::cout.getloc());

  std::string str = "2+2=4 is ";
  if (2+2==4)
    str+=punct_facet.truename();
  else
    str+=punct_facet.falsename();

  std::cout << str << '\n';
  return 0;
}


Output:

2+2=4 is true

Data races

The facet is accessed.

Exception safety

Strong guarantee: No side effects in case an exception is thrown.

See also