ctor.pass.cpp revision f5256e16dfc425c1d466f6308d4026d529ce9e0b
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// class time_get<charT, InputIterator> 13 14// explicit time_get(size_t refs = 0); 15 16#include <locale> 17#include <cassert> 18 19typedef std::time_get<char, const char*> F; 20 21class my_facet 22 : public F 23{ 24public: 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 33int my_facet::count = 0; 34 35int 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