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

std::numpunct::thousands_sep

Defined in header <locale>

?

?

public: char_type thousands_sep() const;

(1)

?

protected: virtual char_type do_thousands_sep() const;

(2)

?

1%29公共成员函数,调用成员函数do_thousands_sep最派生的类。

2%29返回在解析或格式化整数和浮点值的整体部分时用作数字组之间分隔符的字符。

返回值

类型对象char_type作为数千分隔符使用。标准专业std::numpunct回归','L','...

二次

代码语言:javascript
复制
#include <iostream>
#include <locale>
 
struct space_out : std::numpunct<char> {
    char do_thousands_sep()   const { return ' '; }  // separate with spaces
    std::string do_grouping() const { return "\1"; } // groups of 1 digit
};
 
int main()
{
    std::cout << "default locale: " << 12345678 << '\n';
    std::cout.imbue(std::locale(std::cout.getloc(), new space_out));
    std::cout << "locale with modified numpunct: " << 12345678 << '\n';
}

二次

产出:

二次

代码语言:javascript
复制
default locale: 12345678
locale with modified numpunct: 1 2 3 4 5 6 7 8

二次

另见

do_grouping virtual

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

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

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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com