| Localization library | |||||||||||||||||||||||||
| Regular expressions library(C++11) | |||||||||||||||||||||||||
| Formatting library(C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
numpunct::thousands_sepnumpunct::do_thousands_sep | ||||
Defined in header <locale> | ||
public: char_type thousands_sep()const; | (1) | |
protected: virtual char_type do_thousands_sep()const; | (2) | |
do_thousands_sep of the most derived class.Contents |
The object of typechar_type to use as the thousands separator. The standard specializations ofstd::numpunct return',' andL','.
#include <iostream>#include <locale> struct space_out:std::numpunct<char>{char do_thousands_sep()const{return' ';}// separate with spacesstd::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';}
Output:
default locale: 12345678locale with modified numpunct: 1 2 3 4 5 6 7 8
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 20 | C++98 | the return type wasstring_type | changed tochar_type |
[virtual] | provides the numbers of digits between each pair of thousands separators (virtual protected member function)[edit] |