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 // <memory>
11 
12 // default_delete
13 
14 #include <memory>
15 #include <cassert>
16 
17 struct A
18 {
19     static int count;
AA20     A() {++count;}
AA21     A(const A&) {++count;}
~AA22     virtual ~A() {--count;}
23 };
24 
25 int A::count = 0;
26 
27 struct B
28     : public A
29 {
30     static int count;
BB31     B() {++count;}
BB32     B(const B&) {++count;}
~BB33     virtual ~B() {--count;}
34 };
35 
36 int B::count = 0;
37 
main()38 int main()
39 {
40     std::default_delete<B> d2;
41     std::default_delete<A> d1 = d2;
42     A* p = new B;
43     assert(A::count == 1);
44     assert(B::count == 1);
45     d1(p);
46     assert(A::count == 0);
47     assert(B::count == 0);
48 }
49