Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
has_facet.cpp
Go to the documentation of this file.
1
29#include <ios> // for boolalpha
30#include <iostream> // for cout
31#include <locale> // for ctype, has_facet(), locale
32
33#include <examples.h>
34
35
36// dummy facet, must derive from locale::facet
37// and define a static member of type locale::id
38struct MyFacet: public std::locale::facet
39{
40 static std::locale::id id;
41};
42
43std::locale::id MyFacet::id;
44
45
46int main ()
47{
48 // create a copy of the locale imbued in cout
49 const std::locale loc (std::cout.getloc ());
50
51 std::cout << std::boolalpha
52 << "std::has_facet<std::ctype<char> >(std::cout.getloc ()) = ";
53
54 // see if ctype<char> is installed in the locale (expect true)
55 std::cout << std::has_facet<std::ctype<char> >(loc) << '\n';
56
57 std::cout << "std::has_facet<MyFacet>(std::cout.getloc ()) = ";
58
59 // see if MyFacet is installed in the locale (expect false)
60 std::cout << std::has_facet<MyFacet>(loc) << '\n';
61
62 return 0;
63}
#define loc
Definition 17.names.cpp:492
int main()
Definition has_facet.cpp:46
static std::locale::id id
Definition has_facet.cpp:40