• 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 // <memory>
11 
12 // template <class X> class auto_ptr;
13 
14 // void reset(X* p=0) throw();
15 
16 #include <memory>
17 #include <cassert>
18 
19 // REQUIRES: c++98 || c++03 || c++11 || c++14
20 
21 #include "../A.h"
22 
23 void
test()24 test()
25 {
26     {
27     A* p = new A(1);
28     std::auto_ptr<A> ap(p);
29     ap.reset();
30     assert(ap.get() == 0);
31     assert(A::count == 0);
32     }
33     assert(A::count == 0);
34     {
35     A* p = new A(1);
36     std::auto_ptr<A> ap(p);
37     ap.reset(p);
38     assert(ap.get() == p);
39     assert(A::count == 1);
40     }
41     assert(A::count == 0);
42     {
43     A* p = new A(1);
44     std::auto_ptr<A> ap(p);
45     A* p2 = new A(2);
46     ap.reset(p2);
47     assert(ap.get() == p2);
48     assert(A::count == 1);
49     }
50     assert(A::count == 0);
51 }
52 
main()53 int main()
54 {
55     test();
56 }
57