Personal tools
has_facet
Click on the banner to return to the class reference home page.
has_facet
Locale Function
Summary
A function template used to determine if a locale has a given facet.
Data Type and Member Function Indexes
(exclusive of constructors and destructors)
None
Synopsis
#include <locale> template <class Facet> bool has_facet(const locale&) throw();
Description
has_facet returns true if the requested facet is available in the locale, otherwise it returns false. You specify the facet type by explicitly providing the template parameter. (See the example below.)
Note that if your compiler cannot overload function templates on return type then you'll need to use an alternative has_facet template. The alternative template takes an additional argument that's a pointer to the type of facet you want to check on. The declaration looks like this:
template <class Facet> const bool has_facet(const locale&, Facet*) throw();
The example below shows the use of both variations of has_facet.
Example
// // hasfacet.cpp // #include <iostream> int main () { using namespace std; locale loc; #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE cout << has_facet<ctype<char> >(loc) << endl; #else cout << has_facet(loc,(ctype<char>*)0) << endl; #endif return 0; }
See Also
©Copyright 1996, Rogue Wave Software, Inc.