• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <locale>
10 
11 // template <class Facet> bool has_facet(const locale& loc) throw();
12 
13 #include <locale>
14 #include <cassert>
15 
16 #include "test_macros.h"
17 
18 struct my_facet
19     : public std::locale::facet
20 {
21     static std::locale::id id;
22 };
23 
24 std::locale::id my_facet::id;
25 
main(int,char **)26 int main(int, char**)
27 {
28     std::locale loc;
29     assert(std::has_facet<std::ctype<char> >(loc));
30     assert(!std::has_facet<my_facet>(loc));
31     std::locale loc2(loc, new my_facet);
32     assert(std::has_facet<my_facet>(loc2));
33 
34   return 0;
35 }
36