//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// weak_ptr
// weak_ptr(const weak_ptr& r);
#include<memory>#include<type_traits>#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;structC{staticintcount;C(){++count;}C(constC&){++count;}virtual~C(){--count;}};intC::count=0;intmain(){{conststd::shared_ptr<A>ps(newA);conststd::weak_ptr<A>pA(ps);assert(pA.use_count()==1);assert(B::count==1);assert(A::count==1);{std::weak_ptr<A>pB(pA);assert(B::count==1);assert(A::count==1);assert(pB.use_count()==1);assert(pA.use_count()==1);}assert(pA.use_count()==1);assert(B::count==1);assert(A::count==1);}assert(B::count==0);assert(A::count==0);{std::weak_ptr<A>pA;assert(pA.use_count()==0);assert(B::count==0);assert(A::count==0);{std::weak_ptr<A>pB(pA);assert(B::count==0);assert(A::count==0);assert(pB.use_count()==0);assert(pA.use_count()==0);}assert(pA.use_count()==0);assert(B::count==0);assert(A::count==0);}assert(B::count==0);assert(A::count==0);}