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
|
||||
|
Défini dans l'en-tête
<locale>
|
||
|
public
:
char_type decimal_point ( ) const ; |
(1) | |
|
protected
:
virtual char_type do_decimal_point ( ) const ; |
(2) | |
1)
Fonction membre publique, appelle la fonction membre
do_decimal_point
de la classe la plus dérivée.
2)
Retourne le caractère à utiliser comme séparateur décimal entre les parties entière et fractionnaire.
Valeur de retour
La valeur de type
char_type
à utiliser comme séparateur décimal. Les spécialisations standards de
std::numpunct
renvoient
'.'
et
L
'.'
.
Exemple
Exécuter ce code
#include <iostream> #include <locale> struct slash : std::numpunct<char> { char do_decimal_point() const { return '/'; } // séparer par une barre oblique }; 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'; }
Sortie :
default locale: 1234.5678 locale with modified numpunct: 1234/5678