You can set the global locale:
std::locale::global(std::locale("C"));//default.
Which should affect all functions which rely on the global locale.
Note that cout (and I presume cin and cerr) are imbued with the global locale at the moment they are created. Even if the first line of your code sets the global locale, the streams may have been created earlier, so you must imbue the stream with the new locale.
If you need locale specific behavior elsewhere, but don't want your number formatting messed with by default, boost::locale solved this issue -- you can see this question:What are the tradeoffs between boost::locale and std::locale?
Here's an example of output, but parsing behavior is identical:
auto demo = [](const std::string& label)
{
float f = 1234.567890;
std::cout << label << "\n";
std::cout << "\t streamed: " << f << "\n";
std::cout << "\t to_string: " << std::to_string(f) << "\n";
};
std::locale::global(std::locale("C"));//default.
std::cout.imbue(std::locale()); // imbue cout with the global locale.
demo("c locale");
std::locale::global(std::locale("de_DE"));//default.
std::cout.imbue(std::locale()); // imbue cout with the global locale.
demo("std de locale");
boost::locale::generator gen;
std::locale::global(gen("de_DE.UTF-8"));
std::cout.imbue(std::locale()); // imbue cout with the global locale.
demo("boost de locale");
Which provides the following result:
c locale
streamed: 1234.57
to_string: 1234.567871
std de locale
streamed: 1.234,57
to_string: 1234,567871
boost de locale
streamed: 1234.57
to_string: 1234,567871