std::numpunct_byname
來自 cppreference.com
定義於標頭檔案 <locale> |
||
template< class CharT > class numpunct_byname : public std::numpunct<CharT>; |
||
std::numpunct_byname
是一個 std::numpunct 方面 (facet),它封裝了在其構造時指定的區域設定的數字標點偏好。
目錄 |
[編輯] 特化
標準庫保證提供以下特化
定義於標頭檔案
<locale> | |
std::numpunct_byname<char> | 用於窄字元 I/O 的區域設定特有 std::numpunct 方面 |
std::numpunct_byname<wchar_t> | 用於寬字元 I/O 的區域設定特有 std::numpunct 方面 |
[編輯] 巢狀型別
型別 | 定義 |
char_type
|
CharT
|
string_type
|
std::basic_string<CharT> |
[編輯] 成員函式
(建構函式) |
構造一個新的 numpunct_byname 方面(public member function) |
(解構函式) |
銷燬一個 numpunct_byname 方面(protected member function) |
std::numpunct_byname::numpunct_byname
explicit numpunct_byname( const char* name, std::size_t refs = 0 ); |
||
explicit numpunct_byname( const std::string& name, std::size_t refs = 0 ); |
(C++11 起) | |
為具有 name 的區域設定構造一個新的 std::numpunct_byname
方面。
refs 用於資源管理:如果 refs == 0,則當最後一個持有它的 std::locale 物件被銷燬時,實現會銷燬該方面。否則,物件不會被銷燬。
引數
name | - | 區域設定的名稱 |
refs | - | 連結到 facet 的引用計數 |
std::numpunct_byname::~numpunct_byname
protected: ~numpunct_byname(); |
||
銷燬 facet。
繼承自 std::numpunct
巢狀型別
型別 | 定義 |
char_type
|
CharT
|
string_type
|
std::basic_string<CharT> |
[編輯] 資料成員
成員 | 描述 |
std::locale::id id [static] |
facet 的識別符號 |
成員函式
呼叫 do_decimal_point ( std::numpunct<CharT> 的 public 成員函式) | |
呼叫 do_thousands_sep ( std::numpunct<CharT> 的 public 成員函式) | |
呼叫 do_grouping ( std::numpunct<CharT> 的 public 成員函式) | |
呼叫 do_truename 或 do_falsename ( std::numpunct<CharT> 的 public 成員函式) |
受保護的成員函式
[virtual] |
提供用作小數點的字元 ( std::numpunct<CharT> 的虛 protected 成員函式) |
[virtual] |
提供用作千位分隔符的字元 ( std::numpunct<CharT> 的虛 protected 成員函式) |
[virtual] |
提供每對千位分隔符之間的數字個數 ( std::numpunct<CharT> 的虛 protected 成員函式) |
[virtual] |
提供用作布林值 true 和 false 名稱的字串 ( std::numpunct<CharT> 的虛 protected 成員函式) |
[編輯] 示例
此示例演示瞭如何在不更改區域設定的其餘部分的情況下應用其他語言的數字標點規則。
執行此程式碼
#include <iostream> #include <locale> int main() { const double number = 1000.25; std::wcout << L"default locale: " << number << L'\n'; std::wcout.imbue(std::locale(std::wcout.getloc(), new std::numpunct_byname<wchar_t>("ru_RU.UTF8"))); std::wcout << L"default locale with russian numpunct: " << number << L'\n'; }
輸出
default locale: 1000.25 default locale with russian numpunct: 1 000,25
[編輯] 參閱
定義數字標點規則 (類模板) |