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(auto_ptr& a) throw();
14 
15 #include <memory>
16 #include <cassert>
17 
18 #include "../AB.h"
19 
20 void
test()21 test()
22 {
23     {
24     B* p = new B(1);
25     const std::auto_ptr<B> ap1(p);
26     std::auto_ptr<A> ap2(ap1);
27     assert(ap1.get() == 0);
28     assert(ap2.get() == p);
29     assert(A::count == 1);
30     assert(B::count == 1);
31     }
32     assert(A::count == 0);
33     assert(B::count == 0);
34 }
35 
main(int,char **)36 int main(int, char**)
37 {
38     test();
39 
40   return 0;
41 }
42