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 // template <class X> class auto_ptr;
13 
14 // template<class Y> auto_ptr& operator=(auto_ptr<Y>& a) throw();
15 
16 #include <memory>
17 #include <cassert>
18 
19 #include "../AB.h"
20 
21 void
test()22 test()
23 {
24     {
25     B* p1 = new B(1);
26     const std::auto_ptr<B> ap1(p1);
27     A* p2 = new A(2);
28     std::auto_ptr<A> ap2(p2);
29     assert(A::count == 2);
30     assert(B::count == 1);
31     assert(ap1.get() == p1);
32     assert(ap2.get() == p2);
33     std::auto_ptr<A>& apr = ap2 = ap1;
34     assert(&apr == &ap2);
35     assert(A::count == 1);
36     assert(B::count == 1);
37     assert(ap1.get() == 0);
38     assert(ap2.get() == p1);
39     }
40     assert(A::count == 0);
41     assert(B::count == 0);
42 }
43 
main()44 int main()
45 {
46     test();
47 }
48