This code:
std::cout << "std::cout for 2112 = " << 2112 << '\n';
std::stringstream ss;
ss << 2112;
std::cout << "std::stringstream for 2112 = " << ss.str() << '\n';
YAML::Emitter out;
out << 2112;
std::cout << "Emitter for 2112 = " << out.c_str() << '\n';
produces this output:
std::cout for 2112 = 2112
std::stringstream for 2112 = 2,112
Emitter for 2112 = 2,112
Since Emitter uses std::stringstream, it seems this is where it is coming from. So I want to imbue this with, say, std::locale{"C"}, but how can I tell yaml-cpp to do this?
I could convert the numbers (including dealing with vectors, etc., loosing yaml-cpp's convenience operator<< overloads) to a string first and send this to the Emitter, but is there a simpler way to prevent the thousands separator from being included in the yaml string?
YAML::Emitter has a constructor that takes a std::ostream as parameter, which becomes the underlying stream wrapped by the Emitter. Unfortunately, setting the locale of this underlying stream to "C" doesn't solve the problem. In fact, constructing the Emitter with a stringstream results in the Emitter failing to produce any text at all.
emitter << 2112callsEmitter::WriteIntegralTypewhich usesstd::stringstreamunder the hood. Looks like it's locale-bound after all.std::locale::global(std::locale("C"));?