GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::get_money(3) C++ Standard Libary std::get_money(3)

std::get_money - std::get_money


Defined in header <iomanip>
template< class MoneyT > (since C++11)
/*unspecified*/ get_money( MoneyT& mon, bool intl = false );


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.


The extraction operation in in >> get_money(mon, intl) behaves as a
FormattedInputFunction.


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


Returns an object of unspecified type such that if in is the name of an input stream
of type std::basic_istream<CharT, Traits>, then the expression in >> get_money(mon,
intl) behaves as if the following code was executed:


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);

// Run this code


#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);
if (in) {
std::cout << std::quoted(in.str()) << " parsed as: "
<< v1 << ", " << v2 << ", " << v3 << '\n';
} else {
std::cout << "Parse failed";
}
}


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


money_get parses and constructs a monetary value from an input character sequence
(class template)
put_money formats and outputs a monetary value
(C++11) (function template)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.