std::numpunct<CharT>:: decimal_point, do_decimal_point
From cppreference.com
C++
Localization library
Character conversions | ||||
String and stream conversions | ||||
(
C++11/17/26*
)
|
||||
(
C++11/17/26*
)
|
Text encoding identifications | |||||
|
|||||
Unicode conversion facets | |||||
(
C++11/17/26*
)
|
|||||
(
C++11/17/26*
)
|
|||||
(
C++11/17/26*
)
|
|||||
(
C++11/17/26*
)
|
std::numpunct
Member functions | ||||
numpunct::decimal_point
numpunct::do_decimal_point
|
||||
Defined in header
<locale>
|
||
public
:
char_type decimal_point ( ) const ; |
(1) | |
protected
:
virtual char_type do_decimal_point ( ) const ; |
(2) | |
1)
Public member function, calls the member function
do_decimal_point
of the most derived class.
2)
Returns the character to be used as the decimal separator between integer and fractional parts.
Return value
The value of type
char_type
to use as the decimal separator. The standard specializations of
std::numpunct
return
'.'
and
L
'.'
.
Example
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
Retrieved from "
https://en.cppreference.com/mwiki/index.php?title=cpp/locale/numpunct/decimal_point&oldid=160190
"