std::numpunct<CharT>:: decimal_point, do_decimal_point
From cppreference.net
C++
Text processing library
| 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 | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
Localization library
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::numpunct
| Member functions | ||||
|
numpunct::decimal_point
numpunct::do_decimal_point
|
||||
|
Definiert im Header
<locale>
|
||
|
public
:
char_type decimal_point ( ) const ; |
(1) | |
|
protected
:
virtual char_type do_decimal_point ( ) const ; |
(2) | |
1)
Öffentliche Memberfunktion, ruft die Memberfunktion
do_decimal_point
der am stärksten abgeleiteten Klasse auf.
2)
Gibt das Zeichen zurück, das als Dezimaltrennzeichen zwischen ganzzahligen und gebrochenen Teilen verwendet werden soll.
Rückgabewert
Der Wert vom Typ
char_type
, der als Dezimaltrennzeichen verwendet werden soll. Die Standard-Spezialisierungen von
std::numpunct
geben
'.'
und
L
'.'
zurück.
Beispiel
Diesen Code ausführen
#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'; }
Ausgabe:
default locale: 1234.5678 locale with modified numpunct: 1234/5678