目录

global

描述 (Description)

它设置全局语言环境[静态]并返回loc的副本。

声明 (Declaration)

以下是std :: locale :: global的声明。

C++98

	
static locale global (const locale& loc);

C++11

   static locale global (const locale& loc);

参数 (Parameters)

loc - 要设置为全局区域设置的区域设置对象。

返回值 (Return Value)

它返回全局语言环境对象。

异常 (Exceptions)

Strong guarantee - 如果抛出异常,则没有任何影响。

数据竞争 (Data races)

区域设置对象已修改。

例子 (Example)

在下面的例子中解释了std :: locale :: global。

#include <iostream>
#include <locale>
int main (void) {
   std::locale foo;
   foo.global(std::locale(""));
   std::locale bar;
   std::cout << "foo and bar are ";
   std::cout << (foo==bar?"equal":"different");
   std::cout << ".\n";
   return 0;
}

让我们编译并运行上面的程序,这将产生以下结果 -

foo and bar are different.
↑回到顶部↑
WIKI教程 @2018