GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::has_facet(3) C++ Standard Libary std::has_facet(3)

std::has_facet - std::has_facet


Defined in header <locale>
template< class Facet > (until C++11)
bool has_facet( const locale& loc ) throw();
template< class Facet > (since C++11)
bool has_facet( const locale& loc ) noexcept;


Checks if the locale loc implements the facet Facet.


loc - the locale object to query


Returns true if the facet Facet was installed in the locale loc, false otherwise.

// Run this code


#include <iostream>
#include <locale>


// minimal custom facet
struct myfacet : public std::locale::facet {
static std::locale::id id;
};


std::locale::id myfacet::id;


int main()
{
// loc is a "C" locale with myfacet added
std::locale loc(std::locale::classic(), new myfacet);
std::cout << std::boolalpha
<< "Can loc classify chars? "
<< std::has_facet<std::ctype<char>>(loc) << '\n'
<< "Can loc classify char32_t? "
<< std::has_facet<std::ctype<char32_t>>(loc) << '\n'
<< "Does loc implement myfacet? "
<< std::has_facet<myfacet>(loc) << '\n';
}


Can loc classify chars? true
Can loc classify char32_t? false
Does loc implement myfacet? true


locale set of polymorphic facets that encapsulate cultural differences
(class)
use_facet obtains a facet from a locale
(function template)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.