1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/boost/ptr_container/clone_allocator.hpp Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,80 @@
1.4 +//
1.5 +// Boost.Pointer Container
1.6 +//
1.7 +// Copyright Thorsten Ottosen 2003-2005. Use, modification and
1.8 +// distribution is subject to the Boost Software License, Version
1.9 +// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
1.10 +// http://www.boost.org/LICENSE_1_0.txt)
1.11 +//
1.12 +// For more information, see http://www.boost.org/libs/ptr_container/
1.13 +//
1.14 +
1.15 +#ifndef BOOST_PTR_CONTAINER_CLONE_ALLOCATOR_HPP
1.16 +#define BOOST_PTR_CONTAINER_CLONE_ALLOCATOR_HPP
1.17 +
1.18 +#include <boost/assert.hpp>
1.19 +#include <boost/checked_delete.hpp>
1.20 +#include <typeinfo>
1.21 +
1.22 +namespace boost
1.23 +{
1.24 + /////////////////////////////////////////////////////////////////////////
1.25 + // Clonable concept
1.26 + /////////////////////////////////////////////////////////////////////////
1.27 +
1.28 + template< class T >
1.29 + inline T* new_clone( const T& r )
1.30 + {
1.31 + T* res = new T( r );
1.32 + BOOST_ASSERT( typeid(r) == typeid(*res) &&
1.33 + "Default new_clone() sliced object!" );
1.34 + return res;
1.35 + }
1.36 +
1.37 + template< class T >
1.38 + inline void delete_clone( const T* r )
1.39 + {
1.40 + checked_delete( r );
1.41 + }
1.42 +
1.43 + /////////////////////////////////////////////////////////////////////////
1.44 + // CloneAllocator concept
1.45 + /////////////////////////////////////////////////////////////////////////
1.46 +
1.47 + struct heap_clone_allocator
1.48 + {
1.49 + template< class U >
1.50 + static U* allocate_clone( const U& r )
1.51 + {
1.52 + return new_clone( r );
1.53 + }
1.54 +
1.55 + template< class U >
1.56 + static void deallocate_clone( const U* r )
1.57 + {
1.58 + delete_clone( r );
1.59 + }
1.60 +
1.61 + };
1.62 +
1.63 +
1.64 +
1.65 + struct view_clone_allocator
1.66 + {
1.67 + template< class U >
1.68 + static U* allocate_clone( const U& r )
1.69 + {
1.70 + return const_cast<U*>( &r );
1.71 + }
1.72 +
1.73 + template< class U >
1.74 + static void deallocate_clone( const U* r )
1.75 + {
1.76 + // do nothing
1.77 + }
1.78 + };
1.79 +
1.80 +} // namespace 'boost'
1.81 +
1.82 +#endif
1.83 +