• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // <codecvt>
11 
12 // template <class Elem, unsigned long Maxcode = 0x10ffff,
13 //           codecvt_mode Mode = (codecvt_mode)0>
14 // class codecvt_utf8
15 //     : public codecvt<Elem, char, mbstate_t>
16 // {
17 //     // unspecified
18 // };
19 
20 // Not a portable test
21 
22 #include <codecvt>
23 #include <cstdlib>
24 #include <cassert>
25 
26 int outstanding_news = 0;
27 
operator new(std::size_t s)28 void* operator new(std::size_t s) throw(std::bad_alloc)
29 {
30     ++outstanding_news;
31     return std::malloc(s);
32 }
33 
operator delete(void * p)34 void  operator delete(void* p) throw()
35 {
36     if (p)
37     {
38         --outstanding_news;
39         std::free(p);
40     }
41 }
42 
main()43 int main()
44 {
45     assert(outstanding_news == 0);
46     {
47         typedef std::codecvt_utf8<wchar_t> C;
48         C c;
49         assert(outstanding_news == 0);
50     }
51     {
52         typedef std::codecvt_utf8<wchar_t> C;
53         std::locale loc(std::locale::classic(), new C);
54         assert(outstanding_news != 0);
55     }
56     assert(outstanding_news == 0);
57 }
58