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