Added array handling to SmartPtr.
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@1109 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
419efb2c20
commit
80a07d19e8
2 changed files with 153 additions and 7 deletions
|
@ -21,6 +21,9 @@
|
|||
|
||||
#include <cassert>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
//#define DO_EXTRA_LOKI_TESTS
|
||||
#ifdef DO_EXTRA_LOKI_TESTS
|
||||
#include <iostream>
|
||||
|
@ -37,6 +40,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 );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
RefLinkedBase::RefLinkedBase( const RefLinkedBase & rhs ) :
|
||||
prev_( &rhs ),
|
||||
next_( rhs.next_ )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue