]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/localization/locale.categories/category.time/locale.time.put/ctor.pass.cpp
Vendor import of libc++ trunk r351319 (just before the release_80
[FreeBSD/FreeBSD.git] / test / std / localization / locale.categories / category.time / locale.time.put / ctor.pass.cpp
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_put<charT, OutputIterator>
13
14 // explicit time_put(size_t refs = 0);
15
16 #include <locale>
17 #include <cassert>
18
19 typedef std::time_put<char, char*> F;
20
21 class my_facet
22     : public F
23 {
24 public:
25     static int count;
26
27     explicit my_facet(std::size_t refs = 0)
28         : F(refs) {++count;}
29
30     ~my_facet() {--count;}
31 };
32
33 int my_facet::count = 0;
34
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 }