std::num_put
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody>| Déclaré dans l'en-tête <locale>
|
||
template< class CharT, class OutputIt = std::ostreambuf_iterator<CharT> > class num_put; |
||
Classe
std::num_put encapsule les règles pour les valeurs de mise en forme de type bool, long, unsigned long, long long, unsigned long long, double, long double, void*, et de tous les types implicitement convertibles en ceux-ci (tels que int ou float), sous forme de chaînes. Les opérateurs standard de sortie de mise en forme (comme cout << n;) utiliser la facette std::num_put de la localisation du flux d'E / S à générer représentation textuelle d'un nombre .Original:
Class
std::num_put encapsulates the rules for formatting values of type bool, long, unsigned long, long long, unsigned long long, double, long double, void*, and of all types implicitly convertible to these (such as int or float), as strings. The standard formatting output operators (such as cout << n;) use the std::num_put facet of the I/O stream's locale to generate text representation of numbers.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Inheritance diagram
Sommaire
Exigences de type
-OutputIt must meet the requirements of OutputIterator.
|
Spécialisations
Deux spécialisations et deux spécialisations partielles sont fournies par la bibliothèque standard et sont mises en œuvre par tous les objets créés dans un environnement linguistique programme C + +:
Original:
Two specializations and two partial specializations are provided by the standard library and are implemented by all locale objects created in a C++ program:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Defined in header
<locale> | |
std::num_put<char>
|
crée une chaine de caractères étroits de nombres
Original: creates narrow string representations of numbers The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
std::num_put<wchar_t>
|
crée une chaine de caractères larges de nombres
Original: creates wide string representations of numbers The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
std::num_put<char, OutputIt>
|
crée une chaine de caractères étroits de nombres à l'aide itérateur de sortie personnalisé
Original: creates narrow string representations of numbers using custom output iterator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
std::num_put<wchar_t, OutputIt>
|
crée une chaine de caractères larges chiffres à l'aide itérateur de sortie personnalisé
Original: creates wide string representations of numbers using custom output iterator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Types de membres
| Type du membre | Définition |
char_type
|
CharT
|
iter_type
|
OutputIt
|
Fonctions membres
construit un nouveau num_put facette Original: constructs a new num_put facet The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) | |
Détruit une facette num_put Original: destructs a num_put facet The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre protégée) | |
Invoque do_put Original: invokes do_put The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) |
Protégé fonctions membres
[ virtuel ]Original: virtual The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Formate un nombre et écrit dans le flux de sortie Original: formats a number and writes to output stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre virtuelle protégée) |
Objets membres
static std::locale::id id |
Id de la localisation Original: id of the locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (objet membre public) |
Exemple
#include <iostream>
#include <locale>
#include <string>
#include <iterator>
int main()
{
double n = 1234567.89;
std::cout.imbue(std::locale("de_DE"));
std::cout << "Direct conversion to string:\n"
<< std::to_string(n) << '\n'
<< "Output using a german locale:\n"
<< std::fixed << n << '\n'
<< "Output using an american locale:\n";
// use the facet directly
std::cout.imbue(std::locale("en_US.UTF-8"));
auto& f = std::use_facet<std::num_put<char>>(std::cout.getloc());
f.put(std::ostreambuf_iterator<char>(std::cout), std::cout, ' ', n);
std::cout << '\n';
}
Résultat :
Direct conversion to string:
1234567.890000
Output using a german locale:
1.234.567,890000
Output using an american locale:
1,234,567.890000
Voir aussi
définit les règles de ponctuation numériques Original: defines numeric punctuation rules The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe générique) | |
analyse des valeurs numériques à partir d'une séquence de caractères d'entrée Original: parses numeric values from an input character sequence The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe générique) | |
(C++11) |
convertit une valeur entière ou réelle en string (fonction) |
(C++11) |
convertit une valeur de point intégrée ou flottante wstring Original: converts an integral or floating point value to wstring The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction) |