//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// template<class Y> explicit shared_ptr(Y* p);
#include<memory>#include<new>#include<cstdlib>#include<cassert>structA{staticintcount;A(){++count;}A(constA&){++count;}~A(){--count;}};intA::count=0;boolthrow_next=false;void*operatornew(std::size_ts)throw(std::bad_alloc){if(throw_next)throwstd::bad_alloc();returnstd::malloc(s);}voidoperatordelete(void*p)throw(){std::free(p);}intmain(){{A*ptr=newA;throw_next=true;assert(A::count==1);try{std::shared_ptr<A>p(ptr);assert(false);}catch(std::bad_alloc&){assert(A::count==0);}}}