std::moneypunct<CharT,International>::curr_symbol, do_curr_symbol
来自cppreference.com
| 在标头 <locale> 定义
|
||
| |
(1) | |
| |
(2) | |
1) 公开成员函数,调用最终派生类的成员函数
do_curr_symbol。2) 返回此本地环境用作通货标识符的字符串。如果
International(std::moneypunct 的第二模板形参)是 false,那么此标识符通常为单个(宽)字符,例如 "¥" 或 "$"。如果 International 是 true,那么标识符通常是保有三个 ISO 4217 通货代码,后随空格的四字符字符串("JPY " 或 "USD ")。返回值
保有通货符号或代码的 string_type 类型对象。
示例
运行此代码
#include <iostream>
#include <locale>
void show_ccy(const char* locname)
{
std::locale loc(locname);
std::cout << locname << " 的通货符号是 "
<< std::use_facet<std::moneypunct<char, true>>(loc).curr_symbol()
<< "或简写为 " << std::use_facet<std::moneypunct<char>>(loc).curr_symbol()
<< "\n";
}
int main()
{
show_ccy("en_US.utf8");
show_ccy("ja_JP.utf8");
show_ccy("sv_SE.utf8");
show_ccy("ru_RU.utf8");
show_ccy("vi_VN.utf8");
}
输出:
en_US.utf8 的通货符号是 USD 或简写为 $
ja_JP.utf8 的通货符号是 JPY 或简写为 ¥
sv_SE.utf8 的通货符号是 SEK 或简写为 kr
ru_RU.utf8 的通货符号是 RUB 或简写为 руб
vi_VN.utf8 的通货符号是 VND 或简写为 ₫
缺陷报告
下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。
| 缺陷报告 | 应用于 | 出版时的行为 | 正确行为 |
|---|---|---|---|
| LWG 666 | C++98 | 标识符字符串在 International 是 true 时要求长度为 4
|
不要求长度 |
参阅
| 提供通货值的格式化模式 (虚受保护成员函数) |