C++ ostream的标准默认本地化是什么?

C++ ostream的标准默认本地化是什么?,c++,localization,c++-standard-library,C++,Localization,C++ Standard Library,我使用的是CLang 8.0,给出了以下代码示例: #include <locale> #include <sstream> #include <iostream> struct slash : std::numpunct<char> { char do_decimal_point() const { return '/'; } // separate with slash }; int main() { std::ost

我使用的是CLang 8.0,给出了以下代码示例:

#include <locale>
#include <sstream>
#include <iostream>

struct slash : std::numpunct<char> {
    char do_decimal_point()   const { return '/'; }  // separate with slash
};

int main()
{
    std::ostringstream oss;

    auto slash_locale = std::locale(std::cout.getloc(), new slash);
    std::locale::global( slash_locale );

    oss << 4.5;
    std::cout << oss.str();
}
#包括
#包括
#包括
结构斜杠:std::numpunct{
char do_decimal_point()常量{return'/'}//用斜杠分隔
};
int main()
{
std::ostringstream oss;
自动斜杠_locale=std::locale(std::cout.getloc(),新斜杠);
std::locale::global(斜线\区域设置);

oss标准定义了在构建
basic\u stream
对象的
base对象时,将使用当前全局语言环境的副本初始化该对象,并且在调用成员
imbue
之前,使用该语言环境的结果将一直有效

30.6.3.1基本\u streambuf构造函数[streambuf.cons]
basic_streambuf();

1效果:构造类
basic\u streambuf
的对象并初始化:
(1.1)其所有指针成员对象都指向空指针,
(1.2)在构建时,将
getloc()
成员复制到全局区域设置
locale()

2备注:初始化
getloc()
成员后,可以安全地缓存调用区域设置成员函数的结果以及由此获得的facet成员的结果,直到下次调用成员imbue为止

因此,在这种情况下,只有在更改发生后创建了
oss
,才能看到全局语言环境更改的影响