1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
14 // template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);
19 #include "test_macros.h"
26 B(const B&) {++count;}
27 virtual ~B() {--count;}
38 A(const A&) {++count;}
46 #ifndef TEST_HAS_NO_EXCEPTIONS
51 std::shared_ptr<A> sp(wp);
54 catch (std::bad_weak_ptr&)
57 assert(A::count == 0);
61 std::shared_ptr<A> sp0(new A);
62 std::weak_ptr<A> wp(sp0);
63 std::shared_ptr<A> sp(wp);
64 assert(sp.use_count() == 2);
65 assert(sp.get() == sp0.get());
66 assert(A::count == 1);
68 assert(A::count == 0);
69 #ifndef TEST_HAS_NO_EXCEPTIONS
71 std::shared_ptr<A> sp0(new A);
72 std::weak_ptr<A> wp(sp0);
76 std::shared_ptr<A> sp(wp);
79 catch (std::bad_weak_ptr&)
83 assert(A::count == 0);