public member function
<locale>

std::locale::name

string name() const;
Get locale name
Returns the name of the locale, in an implementation-specific manner.

If the locale has no name, the function returns "*".

Constructing a new locale object with the value returned by this function (if this is different from "*") creates a locale with the same properties as *this.

Parameters

none

Return value

A string with the name of the locale, or with "*" if it has no name.

Example

1
2
3
4
5
6
7
8
9
10
11
12
// locale::name example
#include <iostream>       // std::cout
#include <locale>         // std::locale

int main ()
{
  std::locale loc;        // global locale

  std::cout << "The global locale is: " << loc.name() << '\n';

  return 0;
}

Possible output:
The global locale is: C


Data races

The locale object is accessed.

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the object.

See also