| I/O manipulators | ||||
| Print functions(C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++20) | ||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
| Synchronized Output | ||||
(C++20) | ||||
| Types | ||||
| Error category interface | ||||
(C++11) | ||||
(C++11) |
| Floating-point formatting | |||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
| Integer formatting | |||||||||||||||||||||||||||||||
| Boolean formatting | |||||||||||||||||||||||||||||||
| Field width and fill control | |||||||||||||||||||||||||||||||
| Other formatting | |||||||||||||||||||||||||||||||
| Whitespace processing | |||||||||||||||||||||||||||||||
| Output flushing | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
| Status flags manipulation | |||||||||||||||||||||||||||||||
| Time and money I/O | |||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
| Quoted manipulator | |||||||||||||||||||||||||||||||
(C++14) | |||||||||||||||||||||||||||||||
Defined in header <iomanip> | ||
template<class MoneyT> /*unspecified*/ put_money(const MoneyT& mon,bool intl=false); | (since C++11) | |
When used in an expressionout<< put_money(mon, intl), converts the monetary valuemon to its character representation as specified by thestd::money_put facet of the locale currently imbued inout.
The insertion operation inout<< put_money(mon, intl) behaves as aFormattedOutputFunction.
Contents |
| mon | - | a monetary value, eitherlongdouble orstd::basic_string |
| intl | - | use international currency strings iftrue, use currency symbols otherwise |
An object of unspecified type such that
where the functionf is defined as:
template<class CharT,class Traits,class MoneyT>void f(std::basic_ios<CharT, Traits>& str,const MoneyT& mon,bool intl){using Iter=std::ostreambuf_iterator<CharT, Traits>;using MoneyPut=std::money_put<CharT, Iter>; const MoneyPut& mp=std::use_facet<MoneyPut>(str.getloc());const Iter end= mp.put(Iter(str.rdbuf()), intl, str, str.fill(), mon); if(end.failed()) str.setstate(std::ios_base::badbit);}
#include <iomanip>#include <iostream> int main(){longdouble 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';}
Possible output:
en_US: $1.23 or USD 1.23ru_RU: 1.23 руб or 1.23 RUB ja_JP: ¥123 or JPY 123
| formats a monetary value for output as a character sequence (class template)[edit] | |
(C++11) | parses a monetary value (function template)[edit] |