• 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 // unique_ptr
13 
14 // test reset
15 
16 #include <memory>
17 #include <cassert>
18 
19 #include "unique_ptr_test_helper.h"
20 
main()21 int main() {
22   {
23     std::unique_ptr<A> p(new A);
24     assert(A::count == 1);
25     assert(B::count == 0);
26     A* i = p.get();
27     assert(i != nullptr);
28     p.reset(new B);
29     assert(A::count == 1);
30     assert(B::count == 1);
31   }
32   assert(A::count == 0);
33   assert(B::count == 0);
34   {
35     std::unique_ptr<A> p(new B);
36     assert(A::count == 1);
37     assert(B::count == 1);
38     A* i = p.get();
39     assert(i != nullptr);
40     p.reset(new B);
41     assert(A::count == 1);
42     assert(B::count == 1);
43   }
44   assert(A::count == 0);
45   assert(B::count == 0);
46 }
47