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 codecvt<char32_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 21 typedef std::codecvt<char32_t, char, std::mbstate_t> F; 22 23 class my_facet 24 : public F 25 { 26 public: 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 35 int my_facet::count = 0; 36 37 //#endif 38 39 int 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