From 1d71c6b80f224b6c131b548bbd7667e7cfef1d31 Mon Sep 17 00:00:00 2001 From: rich_sposato Date: Tue, 20 Sep 2011 17:51:46 +0000 Subject: [PATCH] Added ability for StrongPtr to handle arrays. git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@1105 7ec92016-0320-0410-acc4-a06ded1c099a --- src/StrongPtr.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/StrongPtr.cpp b/src/StrongPtr.cpp index 1f3b5c5..cdabcb0 100644 --- a/src/StrongPtr.cpp +++ b/src/StrongPtr.cpp @@ -15,6 +15,9 @@ #include +#include +#include + #include #ifdef DO_EXTRA_LOKI_TESTS #include @@ -38,6 +41,45 @@ namespace Private // ---------------------------------------------------------------------------- +void DeleteArrayBase::Swap( DeleteArrayBase & rhs ) +{ + assert( NULL != this ); + + const size_t temp = m_itemCount; + m_itemCount = rhs.m_itemCount; + rhs.m_itemCount = temp; +} + +// ---------------------------------------------------------------------------- + +void DeleteArrayBase::OnInit( const void * p ) const +{ + assert( NULL != this ); + if ( NULL == p ) + { + assert( 0 == m_itemCount ); + } + else + { + assert( 0 < m_itemCount ); + } +} + +// ---------------------------------------------------------------------------- + +void DeleteArrayBase::OnCheckRange( size_t index ) const +{ + assert( NULL != this ); + + if ( index < m_itemCount ) + return; + + const ::std::string message( "index out of range in ::Loki::DeleteArrayBase::OnCheckRange" ); + throw ::std::out_of_range( message ); +} + +// ---------------------------------------------------------------------------- + OneOwnerRefCountInfo::OneOwnerRefCountInfo( SingleOwnerRefCount * ptr ) : m_pointer( NULL ) , m_strongPtr( ptr )