jigdo API
Last update by Admin on 2010-05-23
util/autoptr.hh
Go to the documentation of this file.00001 /* $Id: autoptr.hh,v 1.2 2003/03/03 20:47:22 richard Exp $ -*- C++ -*- 00002 __ _ 00003 |_) /| Copyright (C) 2000-2002 | richard@ 00004 | \/¯| Richard Atterer | atterer.net 00005 ¯ '` ¯ 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License, version 2. See 00008 the file COPYING for details. 00009 00010 */ 00016 #ifndef AUTOPTR_HH 00017 #define AUTOPTR_HH 00018 00021 template <class X> class ArrayAutoPtr { 00022 public: 00023 typedef X element_type; 00024 00025 explicit ArrayAutoPtr(X* p = 0) throw() : ptr(p) { } 00026 ArrayAutoPtr(ArrayAutoPtr& a) throw() : ptr(a.release()) { } 00027 template <class Y> ArrayAutoPtr(ArrayAutoPtr<Y>& a) throw() 00028 : ptr(a.release()) { } 00029 ArrayAutoPtr& operator=(ArrayAutoPtr& a) throw() { 00030 if (&a != this) { delete[] ptr; ptr = a.release(); } 00031 return *this; 00032 } 00033 template <class Y> 00034 ArrayAutoPtr& operator=(ArrayAutoPtr<Y>& a) throw() { 00035 if (a.get() != this->get()) { delete[] ptr; ptr = a.release(); } 00036 return *this; 00037 } 00038 ~ArrayAutoPtr() throw() { delete[] ptr; } 00039 00040 X& operator*() const throw() { return *ptr; } 00041 X* operator->() const throw() { return ptr; } 00042 X* get() const throw() { return ptr; } 00043 X* release() throw() { X* tmp = ptr; ptr = 0; return tmp; } 00044 void reset(X* p = 0) throw() { delete[] ptr; ptr = p; } 00045 private: 00046 X* ptr; 00047 }; 00048 00049 #endif
Generated on Tue Sep 23 14:27:41 2008 for jigdo by
