ctor_char16_t.pass.cpp revision bc8d3f97eb5c958007f2713238472e0c1c8fe02c
1//===----------------------------------------------------------------------===//
2//
3// ��������������������The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <locale>
11
12// template <> class codecvt<char16_t, char, mbstate_t>
13
14// explicit codecvt(size_t refs = 0);
15
16#include <locale>
17#include <cassert>
18
19//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
20
21typedef std::codecvt<char16_t, char, std::mbstate_t> F;
22
23class my_facet
24    : public F
25{
26public:
27    static int count;
28
29    explicit my_facet(std::size_t refs = 0)
30        : F(refs) {++count;}
31
32    ~my_facet() {--count;}
33};
34
35int my_facet::count = 0;
36
37//#endif
38
39int main()
40{
41//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
42    {
43        std::locale l(std::locale::classic(), new my_facet);
44        assert(my_facet::count == 1);
45    }
46    assert(my_facet::count == 0);
47    {
48        my_facet f(1);
49        assert(my_facet::count == 1);
50        {
51            std::locale l(std::locale::classic(), &f);
52            assert(my_facet::count == 1);
53        }
54        assert(my_facet::count == 1);
55    }
56    assert(my_facet::count == 0);
57//#endif
58}
59