C++ 本地化庫 - 建構函式



描述

這是一個本地化建構函式。

宣告

以下是 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);

引數

  • x − 複製的本地化物件。

  • std_name − 標準的 C 本地化名稱。

  • cats − 包含從第二個引數指定的本地化中使用的類別集。

  • p &minusl; 指向一個方面物件的指標。

  • y − 一個本地化物件,從中使用 cats 中指定的方面。

返回值

它返回之前的全域性本地化物件。

異常

強保證 − 如果丟擲異常,則沒有效果。

示例

以下示例演示了 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.
locale.htm
廣告

© . All rights reserved.