カスタム コンテナーを使用しようとしていますが、そのコンテナーのコンストラクターでメモリ プール アロケーターを渡します。全体は次のように始まります。
AllocatorFactory alloc_fac;
//Creates a CPool allocator instance with the size of the Object class
IAllocator* object_alloc = alloc_fac.GetAllocator<CPool>(1000,sizeof(Object));
//Creates a CPool allocator instance with the size of the BList<Object> class
IAllocator* list_alloc = alloc_fac.GetAllocator<CPool>(10,sizeof(BList<Object>));
//Same logic in here as well
IAllocator* node_alloc = alloc_fac.GetAllocator<CPool>(1000,sizeof(BListNode<Object>));
IAllocator クラスは次のようになります。
class IAllocator
{
public:
virtual void* allocate( size_t bytes ) = 0;
virtual void deallocate( void* ptr ) = 0;
template <typename T>
T* make_new()
{ return new ( allocate( sizeof(T) ) ) T (); }
template <typename T, typename Arg0>
T* make_new( Arg0& arg0 )
{ return new ( allocate( sizeof(T) ) ) T ( arg0 ); }
.......
}
コンテナ クラスのコンストラクタは次のようになります。
template <class T>
class BList {
......
public:
/**
*@brief Constructor
*/
BList(Allocators::IAllocator& alloc){
_alloc = alloc;
reset();
}
/**
*@brief Constructor
*@param inOther the original list
*/
BList(const BList<T>& inOther){
reset();
append(inOther);
}
.....
}
そして、私がこれを行うとき:
BList<Object> *list = list_alloc->make_new<BList<Object>>(node_alloc);
コンパイラはこれについて不平を言います:
エラー 1 エラー C2664: 'Containers::BList::BList(Allocators::IAllocator &)' : パラメーター 1 を 'Allocators::IAllocator *' から 'Allocators::IAllocator &' に変換できません c:\licenta\licenta-transfer_ro -02may-430722\licenta\framework\framework\iallocator.h 21 フレームワーク
私はこれで私の頭を超えたと思います....