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

do_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作为数千分隔符使用。在普通的美国地区,这是’,’L’,’...

二次

代码语言:javascript
复制
#include <locale>
#include <iostream>
#include <iomanip>
#include <iterator>
struct space_out : std::moneypunct<char> {
    pattern do_pos_format()      const { return { {value, none, none, none} };}
    int do_frac_digits()         const { return 0; }
    char_type do_thousands_sep() const { return ' ';}
    string_type do_grouping()    const { return "\002";}
};
int main()
{
    std::cout.imbue(std::locale("en_US.UTF-8"));
    std::cout << "american locale: " << std::showbase
              << std::put_money(12345678.0)<< '\n';
 
    std::cout.imbue(std::locale(std::cout.getloc(), new space_out));
    std::cout << "locale with modified moneypunct: "
              << std::put_money(12345678.0)<< '\n';
}

二次

产出:

二次

代码语言:javascript
复制
american locale: $123,456.78
locale with modified moneypunct: 12 34 56 78

二次

另见

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。

扫码关注腾讯云开发者

领取腾讯云代金券