The program below is intended to take advantage of the stdcxx extension whereby two unnamed locales compare equal when they represent the exact same object (i.e., when all their facets are exactly same). The program passes the first assertion but aborts in the second one:
$ cat t.cpp && make t && ./t
#include <cassert>
#include <cstdio>
#include <locale>
struct A: std::num_put<char, char*> { A (): std::num_put<char, char*>(1) { } };
struct B: std::num_put<char, char*> { B (): std::num_put<char, char*>(1) { } };
int main ()
{
const std::locale en ("en_US");
const A* const a = new A;
const B* const b = new B;
{
const std::locale usr1 (std::locale (en, a), b);
const std::locale usr2 (std::locale (en, a), b);
std::printf ("\"%s\" == \"%s\"\n",
usr1.name ().c_str (), usr2.name ().c_str ());
assert (usr1 == usr2);
}
{
const std::locale usr1 (std::locale (en, a), b);
const std::locale usr2 (std::locale (en, b), a);
std::printf ("\"%s\" == \"%s\"\n",
usr1.name ().c_str (), usr2.name ().c_str ());
assert (usr1 == usr2);
}
}
icc -c -I/home/sebor/stdcxx/include/ansi -D_RWSTDDEBUG -D_REENTRANT -I/home/sebor/stdcxx/include -I/build/sebor/stdcxx-icc-10.0.025-15S/include -I/home/sebor/stdcxx/examples/include -cxxlib-nostd -g -w1 t.cpp
icc t.o -o t -cxxlib-nostd -lpthread -L/build/sebor/stdcxx-icc-10.0.025-15S/lib -lstd15S -lcxaguard -lsupc++ -lm
"" == ""
"" == ""
t: t.cpp:32: int main(): Assertion `usr1 == usr2' failed.
Aborted