5 void Heap::DeleterImpl(
void * ptr )
7 delete reinterpret_cast< T *
>( ptr );
10 template<
class T,
class ... CArgs >
13 T * t =
new T( cargs ... );
14 this->items.push_back( Item( Heap::identity_cast( t ), &DeleterImpl< T > ) );
18 template<
class T, std::enable_if_t< std::is_polymorphic_v< T >,
int > >
19 void * Heap::identity_cast( T * ptr )
21 return dynamic_cast< void *
>( ptr );
24 template<
class T, std::enable_if_t< !std::is_polymorphic_v< T >,
int > >
25 void * Heap::identity_cast( T * ptr )
27 return static_cast< void *
>( ptr );
30 template<
class T,
class ... CArgs >
33 return this->create< I< T > >( name, this->inst, cargs ... );
36 template<
class T,
class ... CArgs >
39 auto client = this->create< T >( this->inst, cargs ... );
40 this->cm->
owns( client->cm );
47 void * identity = Heap::identity_cast( ptr );
49 auto it = std::find_if( this->items.begin(), this->items.end(), [ identity ]( Item
const & item ){ return item.identity == identity; } );
51 if( it == this->items.end() )
53 auto error =
"Given object can not be destroyed by this Heap because it was not created by it.";
63 this->items.erase( it );
64 item.deleter( item.identity );