2 // Boost.Pointer Container
4 // Copyright Thorsten Ottosen 2003-2005. Use, modification and
5 // distribution is subject to the Boost Software License, Version
6 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // For more information, see http://www.boost.org/libs/ptr_container/
12 #ifndef BOOST_PTR_CONTAINER_CLONE_ALLOCATOR_HPP
13 #define BOOST_PTR_CONTAINER_CLONE_ALLOCATOR_HPP
15 #include <boost/assert.hpp>
16 #include <boost/checked_delete.hpp>
21 /////////////////////////////////////////////////////////////////////////
23 /////////////////////////////////////////////////////////////////////////
26 inline T* new_clone( const T& r )
29 BOOST_ASSERT( typeid(r) == typeid(*res) &&
30 "Default new_clone() sliced object!" );
35 inline void delete_clone( const T* r )
40 /////////////////////////////////////////////////////////////////////////
41 // CloneAllocator concept
42 /////////////////////////////////////////////////////////////////////////
44 struct heap_clone_allocator
47 static U* allocate_clone( const U& r )
49 return new_clone( r );
53 static void deallocate_clone( const U* r )
62 struct view_clone_allocator
65 static U* allocate_clone( const U& r )
67 return const_cast<U*>( &r );
71 static void deallocate_clone( const U* r )
77 } // namespace 'boost'