//===----------------------------------------------------------------------===//
//
// 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& operator=(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;intmain(){{conststd::shared_ptr<A>ps(newA);conststd::weak_ptr<A>pA(ps);{std::weak_ptr<A>pB;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);}