function template
<locale>

std::use_facet

template <class Facet> const Facet& use_facet (const locale& loc);
Access facet of locale
Returns a reference to facet Facet of locale loc.

If the facet is not present in the locale, the function throws a bad_cast exception.

The function has_facet can be used to check if a locale has a particular facet present before attempting to use it with this function.

Parameters

loc
locale object.

The template parameter Facet shall be a facet type.
A facet type is a type publicly derived (directly or indirectly) from locale::facet with a static member id of type locale::id, such as the standard facets collate, codecvt, ctype, messages, moneypunct, money_get, money_put, numpunct, num_get, num_put, time_get and time_put.

Return type

A const-qualified reference to the facet object.

Data races

Argument loc is accessed, and the returned object may be used to access facet object.

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in loc.

See also