From 015b1ee8079175cace17917d375d24175311b2f8 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 9 Apr 2007 22:17:25 +0000 Subject: The SPtr is castable now. just say SPtrCast( ASPtr ); --- src/sptr.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/sptr.h') diff --git a/src/sptr.h b/src/sptr.h index 23c21dc..0ea8bca 100644 --- a/src/sptr.h +++ b/src/sptr.h @@ -4,9 +4,14 @@ #include #include +template class SPtr; +template< typename Tb, typename Ta > SPtr SPtrCast( SPtr src ); + template class SPtr { + template + friend SPtr SPtrCast( SPtr pt ); public: SPtr() : pRefCnt( NULL ), @@ -96,4 +101,14 @@ private: T *pData; }; +template< typename Tb, typename Ta > SPtr SPtrCast( SPtr src ) +{ + SPtr ret; + ret.pRefCnt = src.pRefCnt; + ret.pData = dynamic_cast(src.pData); + if( ret.pRefCnt ) + (*(ret.pRefCnt)) += 1; + return ret; +} + #endif -- cgit v1.2.3