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 // class time_get<charT, InputIterator>
13 
14 // explicit time_get(size_t refs = 0);
15 
16 #include <locale>
17 #include <cassert>
18 
19 typedef std::time_get<char, const char*> F;
20 
21 class my_facet
22     : public F
23 {
24 public:
25     static int count;
26 
my_facet(std::size_t refs=0)27     explicit my_facet(std::size_t refs = 0)
28         : F(refs) {++count;}
29 
~my_facet()30     ~my_facet() {--count;}
31 };
32 
33 int my_facet::count = 0;
34 
main()35 int main()
36 {
37     {
38         std::locale l(std::locale::classic(), new my_facet);
39         assert(my_facet::count == 1);
40     }
41     assert(my_facet::count == 0);
42     {
43         my_facet f(1);
44         assert(my_facet::count == 1);
45         {
46             std::locale l(std::locale::classic(), &f);
47             assert(my_facet::count == 1);
48         }
49         assert(my_facet::count == 1);
50     }
51     assert(my_facet::count == 0);
52 }
53