C ++中的目的是什么? [英] What the purpose of imbue in C++?

查看:189
本文介绍了C ++中的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在使用一些代码,我看到:

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() {};
};

然后我面对 imbue 。 C ++中的 imbue 函数的目的是什么?它有什么作用?使用 imbue (非线程安全的内存分配)有任何潜在的问题吗?

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)?

推荐答案

imbue std :: ostringstream std :: ios_base ,并将流的区域设置设置为指定的区域设置。

imbue is inherited by std::ostringstream from std::ios_base and 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 ,.

这篇关于C ++中的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆