Home | History | Annotate | Download | only in locale.global.templates
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // <locale>
     11 
     12 // template <class Facet> bool has_facet(const locale& loc) throw();
     13 
     14 #include <locale>
     15 #include <cassert>
     16 
     17 struct my_facet
     18     : public std::locale::facet
     19 {
     20     static std::locale::id id;
     21 };
     22 
     23 std::locale::id my_facet::id;
     24 
     25 int main()
     26 {
     27     std::locale loc;
     28     assert(std::has_facet<std::ctype<char> >(loc));
     29     assert(!std::has_facet<my_facet>(loc));
     30     std::locale loc2(loc, new my_facet);
     31     assert(std::has_facet<my_facet>(loc2));
     32 }
     33