Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
has_facet

has_facet

Tests if a particular facet is stored in a specified locale.

template<class Facet> 
   bool has_facet( 
      const locale& _Loc 
   );

_Loc

The locale to be tested for the presence of a facet.

true if the locale has the facet tested for; false if it does not.

The template function is useful for checking whether nonmandatory facets are listed in a locale before use_facet is called to avoid the exception that would be thrown if it were not present.

// locale_has_facet.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
using namespace std;

int main( )
{
   locale loc ( "German_Germany" );
   bool result = has_facet <ctype<char> > ( loc );
   cout << result << endl;
}
1

Header: <locale>

Namespace: std

Show:
© 2015 Microsoft