Espacios de nombres
Variantes
Acciones

std::get_money

De cppreference.com
< cpp‎ | io‎ | manip

 
 
Entrada / salida de la biblioteca
I / O manipuladores
C-estilo I / O
Buffers
Original:
Buffers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_streambuf
basic_filebuf
basic_stringbuf
strstreambuf(obsoleto)
Arroyos
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Abstracciones
Original:
Abstractions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base
basic_ios
basic_istream
basic_ostream
basic_iostream
File I / O
Original:
File I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ifstream
basic_ofstream
basic_fstream
Cadena de I / O
Original:
String I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istringstream
basic_ostringstream
basic_stringstream
Matriz I / O
Original:
Array I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
istrstream(obsoleto)
ostrstream(obsoleto)
strstream(obsoleto)
Tipos
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
streamoff
streamsize
fpos
Error interfaz categoría
Original:
Error category interface
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
iostream_category(C++11)
io_errc(C++11)
 
Entrada / salida manipuladores
De punto flotante de formato
Original:
Floating-point formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Formato Integer
Original:
Integer formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Formato booleano
Original:
Boolean formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
boolalpha
noboolalpha
Ancho de campo y de control de llenado
Original:
Field width and fill control
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Otros formatos
Original:
Other formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Los espacios en blanco de procesamiento
Original:
Whitespace processing
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Salida de lavado
Original:
Output flushing
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Indicadores de estado manipulación
Original:
Status flags manipulation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Tiempo y dinero I / O
Original:
Time and money I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
get_money(C++11)
get_time(C++11)
put_money(C++11)
put_time(C++11)
 
Defined in header <iomanip>
template< class MoneyT >
/*unspecified*/ get_money( MoneyT& mon, bool intl = false );
(desde C++11)

When used in an expression in >> get_money(mon, intl), parses the character input as a monetary value, as specified by the std::money_get facet of the locale currently imbued in in, and stores the value in mon.

This function behaves as a formatted input function.

Contenido

[editar] Parámetros

mon - variable where monetary value will be written. Can be either long double or basic_string
intl - expects to find required international currency strings if true, expects optional currency symbols otherwise

[editar] Valor de retorno

Devuelve un objeto de tipo no especificado de tal manera que si in es el nombre de un flujo de salida de std::basic_istream<CharT, Traits> tipo, entonces la expresión in >> get_money(mon, intl) comporta como si el código se ha ejecutado:
Original:
Returns an object of unspecified type such that if in is the name of an output stream of type std::basic_istream<CharT, Traits>, then the expression in >> get_money(mon, intl) behaves as if the following code was executed:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

typedef std::istreambuf_iterator<CharT, Traits> Iter;
typedef std::money_get<CharT, Iter> MoneyGet;
std::ios_base::iostate err = std::ios_base::goodbit;
const MoneyGet &mg = std::use_facet<MoneyGet>(in.getloc());
mg.get(Iter(in.rdbuf()), Iter(), intl, in, err, mon);
if (std::ios_base::goodbit != err)
    out.setstate(err);

[editar] Ejemplo

#include <iostream>
#include <sstream>
#include <locale>
#include <iomanip>
int main()
{
    std::istringstream in("$1,234.56 2.22 USD  3.33");
    long double v1, v2;
    std::string v3;
    in.imbue(std::locale("en_US.UTF-8"));
    in >> std::get_money(v1) >> std::get_money(v2) >> std::get_money(v3, true);
 
    std::cout << '"' << in.str() << "\" parsed as: "
              << v1 << ", " << v2 << ", " << v3 << '\n';
}

Output:

"$1,234.56 2.22 USD  3.33" parsed as: 123456, 222, 333

[editar] Ver también

analiza y construye un valor monetario a partir de una secuencia de caracteres de entrada
Original:
parses and constructs a monetary value 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.

(clase de plantilla) [edit]
(C++11)
formatos y salidas de un valor monetario
Original:
formats and outputs a monetary value
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(función de plantilla) [edit]