From 33952cacabaa5fb97d03078f659d26c6cec2eafc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Kl=C3=B6fkorn?= <robertk@dune-project.org> Date: Thu, 20 Jan 2005 13:57:19 +0000 Subject: [PATCH] comment / wrong. [[Imported from SVN: r1384]] --- grid/bsgrid/myautoptr.hh | 77 ++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/grid/bsgrid/myautoptr.hh b/grid/bsgrid/myautoptr.hh index a738b1036..e3d15d9df 100644 --- a/grid/bsgrid/myautoptr.hh +++ b/grid/bsgrid/myautoptr.hh @@ -3,20 +3,20 @@ #ifndef __DUNE_BSGRID_MYAUTOPTR_HH__ #define __DUNE_BSGRID_MYAUTOPTR_HH__ -/** \brief An auto pointer class *\ - template <class Pointer> - class AutoPointer - { - //! Pointer to Object - Pointer * ptr_; +/** \brief An auto pointer class */ +template <class Pointer> +class AutoPointer +{ + //! Pointer to Object + Pointer * ptr_; - //! number of copies that exist from this Object - mutable int *refCount_; + //! number of copies that exist from this Object + mutable int *refCount_; - public: - //! if a copy is made, the refcount is increased - inline AutoPointer(const AutoPointer<Pointer> & copy) - { +public: + //! if a copy is made, the refcount is increased + inline AutoPointer(const AutoPointer<Pointer> & copy) + { ptr_ = 0; refCount_ = 0; if(copy.ptr_) @@ -25,14 +25,14 @@ refCount_ = copy.refCount_; (*refCount_)++; } - } + } - //! initialize the member variables - AutoPointer() : ptr_ (0) , refCount_ (0) {} + //! initialize the member variables + AutoPointer() : ptr_ (0) , refCount_ (0) {} - // store object pointer and create refCount - void store (Pointer * ptr) - { + // store object pointer and create refCount + void store (Pointer * ptr) + { assert(ptr_ == 0); ptr_ = ptr; if(ptr_) @@ -41,11 +41,11 @@ refCount_ = tmp; (*refCount_) = 1; } - } + } - //! set Stack free, if no more refences exist - ~AutoPointer() - { + //! set Stack free, if no more refences exist + ~AutoPointer() + { if(refCount_ && ptr_) { (*refCount_)--; @@ -55,32 +55,31 @@ if(refCount_) delete refCount_; } } - } + } - //! return object reference - Pointer & operator * () const - { + //! return object reference + Pointer & operator * () const + { assert( ptr_ != 0); return *ptr_; - } + } - //! return object pointer - Pointer * operator -> () const - { + //! return object pointer + Pointer * operator -> () const + { assert( ptr_ != 0); return ptr_; - } + } - private: - //! if copy is made than one more Reference exists - AutoPointer<Pointer> & operator = (const AutoPointer<Pointer> & copy) - { +private: + //! if copy is made than one more Reference exists + AutoPointer<Pointer> & operator = (const AutoPointer<Pointer> & copy) + { assert(false); return (*this); - } - }; + } +}; - #endif - +#endif -- GitLab