fart/util/refptr.cc
Josh Holtrop d34242252a added util/refptr module
git-svn-id: svn://anubis/fart/trunk@90 7f9b0f55-74a9-4bce-be96-3c2cd072584d
2009-02-09 23:31:15 +00:00

28 lines
512 B
C++

#include "refptr.h"
template <typename T> refptr<T>::refptr(const T * ptr)
{
m_ptr = ptr;
refCount = new int;
*refCount = 1;
}
template <typename T> refptr<T>::refptr(const refptr<T> & orig)
{
cloneFrom(orig);
}
template <typename T> refptr<T> & refptr<T>::operator=(const refptr<T> & orig)
{
cloneFrom(orig);
return *this;
}
template <typename T> void refptr<T>::cloneFrom(const refptr<T> & orig)
{
this->ptr = orig.ptr;
this->refCount = orig.refCount;
(*refCount)++;
}