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