close
Espacios de nombres
Variantes

std::num_put

De cppreference.com
 
 
 
std::num_put
Las funciones miembro
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.
 
<tbody> </tbody>
Definido en el archivo de encabezado <locale>
template< class CharT, class OutputIt = std::ostreambuf_iterator<CharT> > class num_put;
Clase std::num_put encapsula las reglas para los valores de formato de tipo bool, long, unsigned long, long long, unsigned long long, double, long double, void*, y de todos los tipos implícitamente convertibles en ellas (como int o float), como cadenas. Los operadores de formato de salida estándar (como cout << n;) utilizan la faceta std::num_put de la configuración regional del flujo de I / O para generar la representación de texto de los números .
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.
Imagecpp/locale/locale/facet

Inheritance diagram

Tipo de requisitos

-
OutputIt debe reunir los requerimientos de OutputIterator.

Especializaciones

Dos especializaciones y dos especializaciones parciales son proporcionados por la biblioteca estándar y son aplicadas por todos los objetos creados en un entorno nacional C + + programa:
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.
Definido en el archivo de encabezado <locale>
std::num_put<char>
crea representaciones estrechas cadenas de números
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>
crea representaciones de ancho de cadena de números
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>
crea representaciones estrechas cadena de números usando iterador de salida personalizado
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>
crea representaciones de ancho de cadena de números con iterador de salida personalizado
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.

Tipos de miembros

Miembro de tipo
Original:
Member type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Definition
char_type CharT
iter_type OutputIt

Las funciones miembro

construye una nueva faceta num_put
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.

(función miembro pública)
destructs una faceta 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.

(función miembro protegida)
Invoca 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.

(función miembro pública)

Protegido funciones miembro

[virtual]
da formato a un número y escribe a la corriente de salida
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.

(función miembro virtual protegida)

Objetos miembros

static std::locale::id id
Identificador de la configuración regional
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.

(objeto miembro público)

Ejemplo

#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';
}

Salida:

Direct conversion to string:
1234567.890000
Output using a german locale:
1.234.567,890000
Output using an american locale:
1,234,567.890000

Ver también

Define las reglas numéricas de puntuación.
(plantilla de clase) [editar]
Analiza valores numéricos a partir de una secuencia de caracteres de entrada.
(plantilla de clase) [editar]
(C++11)
Convierte un valor de punto flotante o entero a una cadena string.
(función) [editar]
Convierte un valor de punto flotante o entero a una cadena wstring.
(función) [editar]