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 Y> explicit shared_ptr(Y* p);
12 
13 #include <memory>
14 #include <cassert>
15 
16 struct A
17 {
18     static int count;
19 
20     A() {++count;}
21     A(const A&) {++count;}
22     ~A() {--count;}
23 };
24 
25 int A::count = 0;
26 
27 int main()
28 {
29     {
30     A* ptr = new A;
31     std::shared_ptr<A> p(ptr);
32     assert(A::count == 1);
33     assert(p.use_count() == 1);
34     assert(p.get() == ptr);
35     }
36     assert(A::count == 0);
37     {
38     A* ptr = new A;
39     std::shared_ptr<void> p(ptr);
40     assert(A::count == 1);
41     assert(p.use_count() == 1);
42     assert(p.get() == ptr);
43     }
44     assert(A::count == 0);
45 }
46