I’m working with some code today, and I saw:
extern std::locale g_classicLocale;
class StringStream : public virtual std::ostringstream
{
public:
StringStream() { imbue(g_classicLocale); }
virtual ~StringStream() {};
};
Then I came in face of imbue. What is the purpose of the imbue function in C++? What does it do? Are there any potential problems in using imbue (non-thread safe, memory allocation)?
imbueis inherited bystd::ostringstreamfromstd::ios_baseand it sets the locale of the stream to the specified locale.This affects the way the stream prints (and reads) certain things; for instance, setting a French locale will cause the decimal point
.to be replaced by,.