std::numpun...ecimal_point(3)
π NAME π
std::numpunct::decimal_point,do_decimal_point β bestie, this is the std::numpun...ecimal_point(3) page from the C++ Standard Libary manual, and it's literally about the tiny character that splits the integer part from the fractional part π
β¨.
β¨ Synopsis β¨
Defined in header <locale>:
public: (1)
char_type decimal_point() const;
protected: (2)
virtual char_type do_decimal_point() const;
- Public member function, calls the member function
do_decimal_pointof the most derived class. - Returns the character to be used as the decimal separator between integer and fractional parts.
So (1) is the public bestie and (2) is the protected virtual one, periodt π«Ά.
π Return value π
The value of type char_type to use as the decimal separator. The standard specializations of std::numpunct return '.' and L'.' π₯.
π¦ Example π¦
Ok so here's the code, and yes it's giving custom facet main-character energy:
// Run this code
#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';
}
πΈ Output πΈ
default locale: 1234.5678
locale with modified numpunct: 1234/5678
Source/version + date, for the record: http://cppreference.com, 2024.06.10, page std::numpun...ecimal_point(3) π«Άβ¨ Bye bestie, go separate those decimals π
π
π¦ 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