This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of TC1 status.

137. Do use_facet and has_facet look in the global locale?

Section: 25.3.1 [locale] Status: TC1 Submitter: Angelika Langer Opened: 1999-03-17 Last modified: 2017-02-03

Priority: Not Prioritized

View all other issues in [locale].

View all issues with TC1 status.


Section 25.3.1 [locale] says:

-4- In the call to use_facet<Facet>(loc), the type argument chooses a facet, making available all members of the named type. If Facet is not present in a locale (or, failing that, in the global locale), it throws the standard exception bad_cast. A C++ program can check if a locale implements a particular facet with the template function has_facet<Facet>().

This contradicts the specification given in section 25.3.2 []:

template <class  Facet> const  Facet& use_facet(const locale&  loc);

-1- Get a reference to a facet of a locale.
-2- Returns: a reference to the corresponding facet of loc, if present.
-3- Throws: bad_cast if has_facet<Facet>(loc) is false.
-4- Notes: The reference returned remains valid at least as long as any copy of loc exists

Proposed resolution:

Remove the phrase "(or, failing that, in the global locale)" from section 22.1.1.


Needed for consistency with the way locales are handled elsewhere in the standard.