From 531761d77331915b3e6495d10e03191ba10c04d2 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 10 Apr 2007 00:26:26 +0000 Subject: david - wow... that seems a little kludgy... see the constsptr test for details, but basically i had to make the members of sptr mutable to get this to work the way it seems it should... maybe i'm missing something... --- src/sptr.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/sptr.h') diff --git a/src/sptr.h b/src/sptr.h index 0ea8bca..9a6a2d6 100644 --- a/src/sptr.h +++ b/src/sptr.h @@ -40,7 +40,7 @@ public: (*pRefCnt) = 1; } - int32_t count() + int32_t count() const { return *pRefCnt; } @@ -65,7 +65,17 @@ public: return *this; } - bool operator==( const SPtr &src ) + const SPtr operator=( const SPtr &src ) const + { + decCount(); + pRefCnt = src.pRefCnt; + pData = src.pData; + (*pRefCnt) += 1; + + return *this; + } + + bool operator==( const SPtr &src ) const { return pData == src.pData; } @@ -81,7 +91,7 @@ public: } private: - void decCount() + void decCount() const { if( pRefCnt ) { @@ -97,8 +107,8 @@ private: } } - int32_t *pRefCnt; - T *pData; + mutable int32_t *pRefCnt; + mutable T *pData; }; template< typename Tb, typename Ta > SPtr SPtrCast( SPtr src ) -- cgit v1.2.3