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::put_money(3) C++ Standard Libary std::put_money(3)

std::put_money - std::put_money


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


When used in an expression out << put_money(mon, intl), converts the monetary value
mon to its character representation as specified by the std::money_put facet of the
locale currently imbued in out.


The insertion operation in out << put_money(mon, intl) behaves as a
FormattedOutputFunction.


mon - a monetary value, either long double or std::basic_string
intl - use international currency strings if true, use currency symbols otherwise


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


typedef std::ostreambuf_iterator<CharT, Traits> Iter;
typedef std::money_put<CharT, Iter> MoneyPut;
const MoneyPut& mp = std::use_facet<MoneyPut>(out.getloc());
const Iter end = mp.put(Iter(out.rdbuf()), intl, out, out.fill(), mon);
if (end.failed())
out.setstate(std::ios::badbit);

// Run this code


#include <iostream>
#include <iomanip>


int main()
{
long double mon = 123.45; // or std::string mon = "123.45";


std::cout.imbue(std::locale("en_US.UTF-8"));
std::cout << std::showbase
<< "en_US: " << std::put_money(mon)
<< " or " << std::put_money(mon, true) << '\n';


std::cout.imbue(std::locale("ru_RU.UTF-8"));
std::cout << "ru_RU: " << std::put_money(mon)
<< " or " << std::put_money(mon, true) << '\n';


std::cout.imbue(std::locale("ja_JP.UTF-8"));
std::cout << "ja_JP: " << std::put_money(mon)
<< " or " << std::put_money(mon, true) << '\n';
}


en_US: $1.23 or USD 1.23
ru_RU: 1.23 руб or 1.23 RUB
ja_JP: ¥123 or JPY 123


money_put formats a monetary value for output as a character sequence
(class template)
get_money parses 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.