在线文档教程
C++
本土化 | Localizations

std::numpunct_byname

性传播疾病:无刺[医]名名

Defined in header
template< class CharT > class numpunct_byname : public std::numpunct<CharT>;

std::numpunct_bynamestd::numpunctfacet,它封装在构造时指定的区域设置的数字标点符号首选项。

标准库提供了两个专门化。

在标头中定义<locale>

*。

性传播疾病:无刺[医]名名<char>特定于地区的STD::窄字符I/O的

性传播疾病:无刺[医]名<wchar[医]特定于地区的STD::宽字符I/O的

成员类型

Member typeDefinition
char_typeCharT
string_typestd::basic_string<CharT>

成员函数

(constructor)constructs a new numpunct_byname facet (public member function)
(destructor)destroys a numpunct_byname facet (protected member function)

性传播疾病:无刺[医]名称::[医]名名

explicit numpunct_byname( const char* name, std::size_t refs = 0
explicit numpunct_byname( const std::string& name, std::size_t refs = 0 (since C++11)

构造一个新的std::numpunct_byname区域设置的方面name...

refs用于资源管理:如果refs == 0时,该实现破坏了面。std::locale保存它的对象被销毁。否则,该对象不会被销毁。

参数

name-the name of the locale
refs-the number of references that link to the facet

性传播疾病:无刺[医]名称::[医]名名

protected: ~numpunct_byname(

摧毁了这个面。

继承自性传播疾病:无刺

成员类型

Member typeDefinition
char_typecharT
string_typestd::basic_string<charT>

成员函数

decimal_pointinvokes do_decimal_point (public member function of std::numpunct)
thousands_sepinvokes do_thousands_sep (public member function of std::numpunct)
groupinginvokes do_grouping (public member function of std::numpunct)
truenamefalsenameinvokes do_truename or do_falsename (public member function of std::numpunct)

受保护成员函数

do_decimal_point virtualprovides the character to use as decimal point (virtual protected member function of std::numpunct)
do_thousands_sep virtualprovides the character to use as thousands separator (virtual protected member function of std::numpunct)
do_grouping virtualprovides the numbers of digits between each pair of thousands separators (virtual protected member function of std::numpunct)
do_truenamedo_falsename virtualprovides the string to use as the name of the boolean true and false (virtual protected member function of std::numpunct)

成员对象

static std::locale::id idid of the locale (public member object)

此示例演示如何应用另一种语言的数字标点符号规则,而不更改其馀的区域设置。

二次

#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

二次

另见

numpunctdefines numeric punctuation rules (class template)

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/locale/num点[医]名名