public member function
<locale>

std::moneypunct::thousands_sep

char_type thousands_sep() const;
返回千位分隔符字符
do_grouping指定了数字分组模式时,返回用于货币表达式的数字分组分隔符字符。

内部,此函数仅调用虚拟受保护成员 do_thousands_sep,对于标准特化版本,它返回正确的字符。

参数



返回值

用作货币表达式中数字分组分隔符的字符。
成员类型 char_type 是分面字符类型(定义为 moneypunct 的第一个模板参数 charT 的别名)。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// moneypunct example
#include <iostream>       // std::cout
#include <locale>         // std::locale, std::moneypunct, std::use_facet

// overload inserter to print patterns:
std::ostream& operator<< (std::ostream& os, std::moneypunct<char>::pattern p)
{
  for (int i=0; i<4; i++)
    switch (p.field[i]) {
      case std::moneypunct<char>::none: std::cout << "none "; break;
      case std::moneypunct<char>::space: std::cout << "space "; break;
      case std::moneypunct<char>::symbol: std::cout << "symbol "; break;
      case std::moneypunct<char>::sign: std::cout << "sign "; break;
      case std::moneypunct<char>::value: std::cout << "value "; break;
    }
  return os;
}

int main ()
{
  std::locale mylocale;
  const std::moneypunct<char>& mp = std::use_facet<std::moneypunct<char> >(mylocale);

  std::cout << "moneypunct in locale \"" << mylocale.name() << "\":\n";

  std::cout << "decimal_point: " << mp.decimal_point() << '\n';
  std::cout << "thousands_sep: " << mp.thousands_sep() << '\n';
  std::cout << "grouping: " << mp.grouping() << '\n';
  std::cout << "curr_symbol: " << mp.curr_symbol() << '\n';
  std::cout << "positive_sign: " << mp.positive_sign() << '\n';
  std::cout << "negative_sign: " << mp.negative_sign() << '\n';
  std::cout << "frac_digits: " << mp.frac_digits() << '\n';
  std::cout << "pos_format: " << mp.pos_format() << '\n';
  std::cout << "neg_format: " << mp.neg_format() << '\n';
  
  return 0;
}

可能的输出

moneypunct in locale "C":
decimal_point:
thousands_sep:
grouping:
curr_symbol:
positive_sign:
negative_sign: -
frac_digits: 0
pos_format: symbol sign none value
neg_format: symbol sign none value


数据竞争

访问此分面。

异常安全

强异常保证: 如果抛出异常,则没有副作用。

另见