//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// shared_ptr
// template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);
#include<memory>#include<cassert>structB{staticintcount;B(){++count;}B(constB&){++count;}virtual~B(){--count;}};intB::count=0;structA:publicB{staticintcount;A(){++count;}A(constA&){++count;}~A(){--count;}};intA::count=0;intmain(){{std::weak_ptr<A>wp;try{std::shared_ptr<A>sp(wp);assert(false);}catch(std::bad_weak_ptr&){}assert(A::count==0);}{std::shared_ptr<A>sp0(newA);std::weak_ptr<A>wp(sp0);std::shared_ptr<A>sp(wp);assert(sp.use_count()==2);assert(sp.get()==sp0.get());assert(A::count==1);}assert(A::count==0);{std::shared_ptr<A>sp0(newA);std::weak_ptr<A>wp(sp0);sp0.reset();try{std::shared_ptr<A>sp(wp);assert(false);}catch(std::bad_weak_ptr&){}}assert(A::count==0);}