The Monetary Category

There are five standard money classes:

The first of these (money_base) is not a facet, but the remaining four are. The money_base class is responsible only for specifying pattern components that will be used to specify how monetary values are parsed and formatted (currency symbol first or last, etc.).

The facets money_get and money_put are responsible for parsing and formatting respectively. Though their behavior is made up of virtual methods, and thus can be overridden via derivation, it will be exceedingly rare for you to feel the need to do so. Like the numeric facets, the real customization capability comes with the "punct" classes: moneypunct and moneypunct_byname.

A user-defined Money class (there will be an example later on) can use money_get and money_put in defining its I/O, and remain completely ignorant of whether it is dealing with francs or pounds. Instead clients of Money will imbue a stream with a locale that specifies this information. On I/O the facets money_get and money_put query moneypunct (or moneypunct_byname) for the appropriate locale-specific data. The Money class can remain blissfully ignorant of cultural specifics, and at the same time, serve all cultures!