std::numpun...housands_sep(3)
okay bestie, you're on the std::numpunct::thousands_sep / do_thousands_sep page from the C++ Standard Library β the manual name in the header literally says C++ Standard Libary (typo preserved, we don't gatekeep spelling π
), and the header title is the truncated std::numpun...housands_sep(3), iykyk. This is your thousands-separator manual page, and she is lowkey iconic.
β¨ NAME β¨
std::numpunct::thousands_sep,do_thousands_sep β yep, the whole name is std::numpunct::thousands_sep,do_thousands_sep. No cap, that's the title.
πΈ Synopsis πΈ
Defined in header <locale>, bestie:
Defined in header <locale>
public: (1)
char_type thousands_sep() const;
protected: (2)
virtual char_type do_thousands_sep() const;
1)β public member function, calls the member functiondo_thousands_sepof the most derived class.2)β returns the character to be used as the separator between digit groups when parsing or formatting integers and integral parts of floating-point values.
π Return value π
The object of type char_type to use as the thousands separator. The standard specializations of std::numpunct return ',' and L','.
π Example π
Run this code, bestie:
#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';
}
β Output β
default locale: 12345678
locale with modified numpunct: 1 2 3 4 5 6 7 8
π¦ Defect reports π¦
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
- DR:
LWG 20β Applied to:C++98β Behavior as published: the return type wasstring_typeβ Correct behavior: changed tochar_type.
π See also π
do_groupingβ provides the numbers of digits between each pair of thousands separators. Marked[virtual]; it's a (virtual protected member function).
kisses, bestie π this glowing little page comes from http://cppreference.com, dated 2024.06.10, and the footer tag is std::numpun...housands_sep(3). β¨ππ¦
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms