std::numpunct<CharT>::decimal_point, do_decimal_point
来自 cppreference.cn
定义于头文件 <locale> |
||
public: char_type decimal_point() const; |
(1) | |
protected: virtual char_type do_decimal_point() const; |
(2) | |
1) 公有成员函数,调用最派生类的成员函数
do_decimal_point
。2) 返回用作整数部分与小数部分之间的小数分隔符的字符。
[edit] 返回值
用作小数分隔符的 char_type
类型的值。 std::numpunct
的标准特化返回 '.' 和 L'.'。
[edit] 示例
运行此代码
#include <iostream> #include <locale> struct slash : std::numpunct<char> { char do_decimal_point() const { return '/'; } // separate with slash }; int main() { std::cout.precision(10); std::cout << "default locale: " << 1234.5678 << '\n'; std::cout.imbue(std::locale(std::cout.getloc(), new slash)); std::cout << "locale with modified numpunct: " << 1234.5678 << '\n'; }
输出
default locale: 1234.5678 locale with modified numpunct: 1234/5678