Library: Localization
Function
A template function used to obtain a facet from a specific locale
#include <locale> namespace std { template<class Facet> const Facet& use_facet(const locale&); }
use_facet() returns a reference to the corresponding facet contained in the locale argument. You specify the facet type by explicitly including the template parameter (see the example below). If that facet is not present, then use_facet() throws bad_cast. Otherwise, the reference remains valid for as long as any copy of the locale exists.
// // usefacet.cpp // #include <iostream> int main () { std::locale loc; // Get a ctype facet const std::ctype<char>& ct = std::use_facet<std::ctype<char> >(loc); std::cout << 'a' << ct.toupper('c') << std::endl; return 0; } Program Output:
aC
ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 22.1.1