1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <memory> 11 12// template <class X> class auto_ptr; 13 14// void reset(X* p=0) throw(); 15 16#include <memory> 17#include <cassert> 18 19#include "../A.h" 20 21void 22test() 23{ 24 { 25 A* p = new A(1); 26 std::auto_ptr<A> ap(p); 27 ap.reset(); 28 assert(ap.get() == 0); 29 assert(A::count == 0); 30 } 31 assert(A::count == 0); 32 { 33 A* p = new A(1); 34 std::auto_ptr<A> ap(p); 35 ap.reset(p); 36 assert(ap.get() == p); 37 assert(A::count == 1); 38 } 39 assert(A::count == 0); 40 { 41 A* p = new A(1); 42 std::auto_ptr<A> ap(p); 43 A* p2 = new A(2); 44 ap.reset(p2); 45 assert(ap.get() == p2); 46 assert(A::count == 1); 47 } 48 assert(A::count == 0); 49} 50 51int main() 52{ 53 test(); 54} 55