1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <memory>
10 
11 // template <class X> class auto_ptr;
12 
13 // auto_ptr& operator=(auto_ptr& a) throw();
14 
15 #include <memory>
16 #include <cassert>
17 
18 #include "../A.h"
19 
20 void
test()21 test()
22 {
23     {
24     A* p1 = new A(1);
25     const std::auto_ptr<A> ap1(p1);
26     A* p2 = new A(2);
27     std::auto_ptr<A> ap2(p2);
28     assert(A::count == 2);
29     assert(ap1.get() == p1);
30     assert(ap2.get() == p2);
31     std::auto_ptr<A>& apr = ap2 = ap1;
32     assert(&apr == &ap2);
33     assert(A::count == 1);
34     assert(ap1.get() == 0);
35     assert(ap2.get() == p1);
36     }
37     assert(A::count == 0);
38 }
39 
main(int,char **)40 int main(int, char**)
41 {
42     test();
43 
44   return 0;
45 }
46