Espaces de noms
Variantes
Affichages
Actions

std::num_put::put, std::num_put::do_put

De cppreference.com
< cpp‎ | locale‎ | num put

 
 
Bibliothèque localisations
Locales et facettes
Original:
Locales and facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
locale
Classification des caractères
Original:
Character classification
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Conversions
Original:
Conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Classes de facettes catégorie de base
Original:
Facet category base classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Catégories de facettes
Original:
Facet categories
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Spécifique aux paramètres régionaux facettes
Original:
Locale-specific facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Facettes de conversion de code
Original:
Code conversion facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
codecvt_utf8 (C++11)
codecvt_utf16 (C++11)
C locale
Original:
C locale
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
Les fonctions membres
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
num_put::num_put
num_put::~num_put
num_put::put
num_put::do_put
 
Defined in header <locale>
public:

iter_type put( iter_type out, std::ios_base& str, char_type fill, bool v) const;
iter_type put( iter_type out, std::ios_base& str, char_type fill, long v) const;
iter_type put( iter_type out, std::ios_base& str, char_type fill, long long v) const;
iter_type put( iter_type out, std::ios_base& str, char_type fill, unsigned long v) const;
iter_type put( iter_type out, std::ios_base& str, char_type fill, unsigned long long v) const;
iter_type put( iter_type out, std::ios_base& str, char_type fill, double v) const;
iter_type put( iter_type out, std::ios_base& str, char_type fill, long double v) const;

iter_type put( iter_type out, std::ios_base& str, char_type fill, const void* v) const;
(1)
protected:

iter_type do_put( iter_type out, std::ios_base& str, char_type fill, bool v) const;
iter_type do_put( iter_type out, std::ios_base& str, char_type fill, long v) const;
iter_type do_put( iter_type out, std::ios_base& str, char_type fill, long long v) const;
iter_type do_put( iter_type out, std::ios_base& str, char_type fill, unsigned long) const;
iter_type do_put( iter_type out, std::ios_base& str, char_type fill, unsigned long long) const;
iter_type do_put( iter_type out, std::ios_base& str, char_type fill, double v) const;
iter_type do_put( iter_type out, std::ios_base& str, char_type fill, long double v) const;

iter_type do_put( iter_type out, std::ios_base& str, char_type fill, const void* v) const;
(2)
1)
fonction de membre du public, appelle le protégé do_put virtuelle fonction membre de la classe la plus dérivée .
Original:
public member function, calls the protected virtual member function do_put of the most derived class.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
écrit des caractères à l'out séquence de sortie qui représente la valeur de v, formaté comme demandé par les codes de formatage str.flags() et les facettes std::numpunct et std::ctype de la locale imprégnée dans le str flux. Cette fonction est appelée par tous les opérateurs format de flux de sortie, tels que std::cout << n; .
Original:
writes characters to the output sequence out which represent the value of v, formatted as requested by the formatting flags str.flags() and the std::numpunct and std::ctype facets of the locale imbued in the stream str. This function is called by all formatted output stream operators, such as std::cout << n;.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Conversion a lieu en quatre étapes
Original:
Conversion occurs in four stages
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Sommaire

[modifier] Étape 1: spécificateur de conversion de sélection

  • I / O indicateurs de format sont obtenus, comme par
    Original:
    I/O format flags are obtained, as if by
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
fmtflags basefield = (str.flags() & std::ios_base::basefield);
fmtflags uppercase = (str.flags() & std::ios_base::uppercase);
fmtflags floatfield = (str.flags() & std::ios_base::floatfield);
fmtflags showpos = (str.flags() & std::ios_base::showpos);
fmtflags showbase = (str.flags() & std::ios_base::showbase);
  • Si le type de v est bool
    Original:
    If the type of v is bool
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • * Si boolalpha == 0, puis convertit v de taper int et effectue de sortie entier .
    Original:
    * If boolalpha == 0, then converts v to type int and performs integer output.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • * Si boolalpha != 0 obtient std::use_facet<std::numpunct<charT>>(str.getloc()).truename() si v == true ou std::use_facet<std::numpunct<charT>>(str.getloc()).falsename() si v == false, et émet chaque c caractère successif de cette chaîne à out avec *out++ = c. Aucun autre traitement est fait dans ce cas, la fonction retourne out .
    Original:
    * If boolalpha != 0 obtains std::use_facet<std::numpunct<charT>>(str.getloc()).truename() if v == true or std::use_facet<std::numpunct<charT>>(str.getloc()).falsename() if v == false, and outputs each successive character c of that string to out with *out++ = c. No further processing is done in this case, the function returns out.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Si le type de v est un type entier, le choix du premier lieu des cinq suivantes est sélectionnée:
    Original:
    If the type of v is an integer type, the the first applicable choice of the following five is selected:
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
Si basefield == oct, utilisera spécificateur de conversion %o
Original:
If basefield == oct, will use conversion specifier %o
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si basefield == hex && !uppercase, utilisera spécificateur de conversion %x
Original:
If basefield == hex && !uppercase, will use conversion specifier %x
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si basefield == hex, utilisera spécificateur de conversion %X
Original:
If basefield == hex, will use conversion specifier %X
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si le type de v est signé, va utiliser spécificateur de conversion %d
Original:
If the type of v is signed, will use conversion specifier %d
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si le type de v n'est pas signé, utilisera spécificateur de conversion %u
Original:
If the type of v is unsigned, will use conversion specifier %u
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • Pour les types entiers, modificateur de longueur est ajoutée à la spécification de conversion si nécessaire: l pour long et unsigned long, ll pour long long et unsigned long long .
    Original:
    For integer types, length modifier is added to the conversion specification if necessary: l for long and unsigned long, ll for long long and unsigned long long.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Si le type de v est un type à virgule flottante, le choix du premier objet de la cinq suivants est sélectionné:
    Original:
    If the type of v is a floating-point type, the the first applicable choice of the following five is selected:
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
Si floatfield == std::ios_base::fixed, utilisera spécificateur de conversion %f
Original:
If floatfield == std::ios_base::fixed, will use conversion specifier %f
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si floatfield == std::ios_base::scientific && !uppercase, utilisera spécificateur de conversion %e
Original:
If floatfield == std::ios_base::scientific && !uppercase, will use conversion specifier %e
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si floatfield == std::ios_base::scientific, utilisera spécificateur de conversion %E
Original:
If floatfield == std::ios_base::scientific, will use conversion specifier %E
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si floatfield == (std::ios_base::fixed | std::ios_base::scientific) && !uppercase, utilisera spécificateur de conversion %a (depuis C++11)
Original:
If floatfield == (std::ios_base::fixed | std::ios_base::scientific) && !uppercase, will use conversion specifier %a (depuis C++11)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si floatfield == std::ios_base::fixed | std::ios_base::scientific, utilisera spécificateur de conversion %A (depuis C++11)
Original:
If floatfield == std::ios_base::fixed | std::ios_base::scientific, will use conversion specifier %A (depuis C++11)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si !uppercase, utilisera spécificateur de conversion %g
Original:
If !uppercase, will use conversion specifier %g
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
sinon, va utiliser spécificateur de conversion %G
Original:
otherwise, will use conversion specifier %G
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • * Si le type de v est long double, le L modificateur de longueur est ajoutée à la spécificateur de conversion .
    Original:
    * If the type of v is long double, the length modifier L is added to the conversion specifier.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • * De plus, si floatfield != (ios_base::fixed | ios_base::scientific), puis modificateur de précision est ajouté, mis à str.precision()
    Original:
    * Additionally, if floatfield != (ios_base::fixed | ios_base::scientific), then precision modifier is added, set to str.precision()
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Pour les types de deux entiers et en virgule flottante, si showbase est défini, le # modificateur est ajouté. Si showpos est défini, le + modificateur est ajouté .
    Original:
    For both integer and floating-point types, if showbase is set, the modifier # is prepended. If showpos is set, the modifier + is prepended.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Si le type de v est void*, utilisera spécificateur de conversion %p
    Original:
    If the type of v is void*, will use conversion specifier %p
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Une chaîne de caractères étroit est créé comme si par un appel à std::printf(spec, v) dans la localisation "C", où spec est le spécificateur de conversion choisi .
    Original:
    A narrow character string is created as if by a call to std::printf(spec, v) in the "C" locale, where spec is the chosen conversion specifier.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[modifier] Étape 2: spécifique à la localisation de conversion

  • Chaque personnage c obtenu au stade 1, autre que le '.' point décimal, est converti en CharT en appelant std::use_facet<std::ctype<CharT>>(str.getloc()).widen(c) .
    Original:
    Every character c obtained in Stage 1, other than the decimal point '.', is converted to CharT by calling std::use_facet<std::ctype<CharT>>(str.getloc()).widen(c).
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Pour les types arithmétiques, le caractère séparateur de milliers, obtenu à partir de std::use_facet<std::numpunct<CharT>>(str.getloc()).thousands_sep(), est inséré dans la séquence en fonction des règles de regroupement fournies par std::use_facet<std::numpunct<CharT>>(str.getloc()).grouping()
    Original:
    For arithmetic types, the thousands separator character, obtained from std::use_facet<std::numpunct<CharT>>(str.getloc()).thousands_sep(), is inserted into the sequence according to the grouping rules provided by std::use_facet<std::numpunct<CharT>>(str.getloc()).grouping()
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Le séparateur décimal ('.') sont remplacés par std::use_facet<std::numpunct<CharT>>(str.getloc()).decimal_point()
    Original:
    Decimal point characters ('.') are replaced by std::use_facet<std::numpunct<CharT>>(str.getloc()).decimal_point()
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[modifier] Étape 3: rembourrage

  • Le drapeau réglage est obtenu comme par std::fmtflags adjustfield = (flags & (std::ios_base::adjustfield)) et examinés pour identifier l'emplacement de rembourrage, comme suit
    Original:
    The adjustment flag is obtained as if by std::fmtflags adjustfield = (flags & (std::ios_base::adjustfield)) and examined to identify padding location, as follows
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
Si adjustfield == std::ios_base::left, va tampon après
Original:
If adjustfield == std::ios_base::left, will pad after
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si adjustfield == std::ios_base::right, sera pavé avant
Original:
If adjustfield == std::ios_base::right, will pad before
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si adjustfield == std::ios_base::internal et un caractère de signe se produit dans la représentation, va tampon après le signe
Original:
If adjustfield == std::ios_base::internal and a sign character occurs in the representation, will pad after the sign
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si adjustfield == std::ios_base::internal et la phase 1 a commencé avec la représentation 0x ou 0X, sera pavé après le x ou X
Original:
If adjustfield == std::ios_base::internal and Stage 1 representation began with 0x or 0X, will pad after the x or X
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
autrement, sera pavé avant
Original:
otherwise, will pad before
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • Si str.width() est non nul (std::setw par exemple, vient d'être utilisé) et le numéro de carte après l'étape 2 est inférieure à str.width(), des copies du caractère fill sont insérés à la position indiquée par un rembourrage pour amener la longueur de la séquence à str.width().
    Original:
    If str.width() is non-zero (e.g. std::setw was just used) and the number of CharT's after Stage 2 is less than str.width(), then copies of the fill character are inserted at the position indicated by padding to bring the length of the sequence to str.width().
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[modifier] Etape 4: sortie

Chaque c caractère successif de la séquence du graphe de la phase 3 est sortie comme par *out++ = c .
Original:
Every successive character c from the sequence of CharT's from Stage 3 is output as if by *out++ = c.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifier] Paramètres

out -
itérateur pointant sur le premier caractère d'être écrasés
Original:
iterator pointing to the first character to be overwritten
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
str -
diffuser de récupérer les informations de mise en forme à partir
Original:
stream to retrieve the formatting information from
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
fill -
caractère de remplissage utilisé lorsque les résultats doit être complétée à la largeur du champ
Original:
padding character used when the results needs to be padded to the field width
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
v -
Valeur à convertir en chaîne et de sortie
Original:
value to convert to string and output
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifier] Retourne la valeur

out

[modifier] Notes

Le zéro initial généré par la spécification de conversion #o (résultant de la combinaison de std::showbase et std::oct par exemple) n'est pas compté comme un caractère de remplissage .
Original:
The leading zero generated by the conversion specification #o (resulting from the combination of std::showbase and std::oct for example) is not counted as a padding character.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifier] Exemple

Émettre un numéro à l'aide locale mondial
Original:
Output a number using global locale
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <iostream>
#include <locale>
 
int main()
{
    auto &facet = std::use_facet<std::num_put<char>>(std::locale());
    facet.put(std::cout, std::cout, '0', 2.71);
    std::cout << '\n';
}

Résultat :

2,71

[modifier] Voir aussi

inserts en forme des données
Original:
inserts formatted data
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 de std::basic_ostream) [edit]