Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.