首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::numpunct_byname

Defined in header <locale>

template< class CharT > class numpunct_byname : public std::numpunct<CharT>;

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

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

在标头中定义<locale>

*。

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

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

成员类型

Member type

Definition

char_type

CharT

string_type

std::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 type

Definition

char_type

charT

string_type

std::basic_string<charT>

成员函数

decimal_point

invokes do_decimal_point (public member function of std::numpunct)

thousands_sep

invokes do_thousands_sep (public member function of std::numpunct)

grouping

invokes do_grouping (public member function of std::numpunct)

truenamefalsename

invokes do_truename or do_falsename (public member function of std::numpunct)

受保护成员函数

do_decimal_point virtual

provides the character to use as decimal point (virtual protected member function of std::numpunct)

do_thousands_sep virtual

provides the character to use as thousands separator (virtual protected member function of std::numpunct)

do_grouping virtual

provides the numbers of digits between each pair of thousands separators (virtual protected member function of std::numpunct)

do_truenamedo_falsename virtual

provides the string to use as the name of the boolean true and false (virtual protected member function of std::numpunct)

成员对象

static std::locale::id id

id of the locale (public member object)

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

二次

代码语言:javascript
复制
#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';
}

二次

产出:

二次

代码语言:javascript
复制
default locale: 1000.25
default locale with russian numpunct: 1 000,25

二次

另见

numpunct

defines numeric punctuation rules (class template)

代码语言:txt
复制
 © cppreference.com

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

扫码关注腾讯云开发者

领取腾讯云代金券