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