Section

std::money_put

Class std::money_put encapsulates the rules for formatting monetary values as strings. The standard I/O manipulator std::put_money uses the std::money_put facet of the I/O stream’s locale.

# Declarations

template<
class CharT,
class OutputIt = std::ostreambuf_iterator<CharT>
> class money_put;

# Example

#include <iomanip>
#include <iostream>
#include <iterator>
#include <locale>
 
int main()
{
    // using the I/O manipulator
    std::cout.imbue(std::locale("en_US.UTF-8"));
    std::cout << "American locale: "
              << std::showbase << std::put_money(12345678.9) << '\n';
 
    // using the facet directly
    std::cout.imbue(std::locale("de_DE.UTF-8"));
    std::cout << "German locale: ";
    auto& f = std::use_facet<std::money_put<char>>(std::cout.getloc());
    f.put({std::cout}, false, std::cout, std::cout.fill(), 12345678.9);
    std::cout << '\n';
}

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 427C++98money_put was guaranteed to accept any CharT thatmeets the requirements for a character on whichany of the iostream components can be instantiatedonly guarantees to accept char,wchar_t and other implementation-defined character types
LWG 2392C++98only character type CharT could beguaranteed to be accepted by money_putcan guarantee to accept implementation-defined character container types

# See also