public member function
template <class Facet> locale combine (const locale& x) const;
Construct copy of locale modifying one facet
Returns a locale object constructed from a copy of
*this, except for the facet specified by template parameter Facet, which is taken from x.
Throws runtime_error if x does not have the facet specified by Facet defined.
The resulting locale has no name.
- A locale objects whose facet Facet is used by the new locale.
The resulting locale object, which has no name.
// locale::combine example
#include <iostream> // std::cout
#include <locale> // std::locale, std::num_put
int main ()
std::locale loc(""); // initialized to environment's locale
// combine loc with the "C" locale for num_put
loc = loc.combine< std::num_put<char> > (std::locale::classic());
std::cout << 3.14159 << '\n';
Output (no matter the environment's locale):
The locale object is modified.
Basic guarantee: if an exception is thrown, the object is in a valid state.
It throws an exception of type runtime_error if x is not a locale with Facet defined.