目录

(constructor)

描述 (Description)

它是一个语言环境构造函数。

声明 (Declaration)

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

C++98

	
   locale() throw();
   locale (const locale& x) throw();
   explicit locale (const char* std_name);	
   locale (const locale& x, const char* std_name, category cats);
   template <class Facet>
   locale (const locale& x, const locale& y, category cats);
   locale (const locale& x, Facet* f);

C++11

   locale() noexcept;	
   locale (const locale& x) noexcept;
explicit locale (const char* std_name);
explicit locale (const string& std_name); 	
   locale (const locale& x, const char* std_name, category cats);
   locale (const locale& x, const string& std_name, category cats);
   template <class Facet>
   locale (const locale& x, const locale& y, category cats);	
   locale (const locale& x, Facet* f);

参数 (Parameters)

  • x - 它复制了语言环境。

  • std_name - 它是标准的C语言环境名称。

  • cats - 它包含从指定为第二个参数的语言环境中使用的一组类别。

  • p &minusl; 它是指向构面对象的指针。

  • y - 它是一个区域设置对象,使用其中指定的facet。

返回值 (Return Value)

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

异常 (Exceptions)

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

例子 (Example)

在下面的示例中,std :: locale :: locale。

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

样本输出应该是这样的 -

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