public member function
<locale>

std::locale::operator==

bool operator== (const locale& x) const;
Compare locales
Compares the locale against x.
Returns true if both locales are the same object, or if one is a copy of the other, or if each has a name and the names are identical.
Returns false in any other case.

Parameters

x
locale object to compare.

Return value

true if both locales are the same object, or one is a copy of the other, or each has a name and the names are identical.
false otherwise.

Example

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

int main ()
{
  if (std::cout.getloc() == std::locale("C"))
    std::cout << "cout is using the C locale.\n";
  else
    std::cout << "cout is not using the C locale.\n";

  return 0;
}

Possible output:
cout is using the C locale.


Data races

Both locale objects, x and *this are accessed.

Exception safety

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

See also