I have a template class MemoryPool<T>.
MemoryPool has a private member AbstractFactory<T> named _factory
In MemoryPool's constructor, I use _factory
Here's the code (I stripped out everything but the following):
MemoryPool.h
Code: Select all
template <typename T>
class MemoryPool
{
typedef std::shared_ptr< MemoryItem<T> > MemoryItemSharedPointer;
public:
MemoryPool(const size_t itemsToInitNow, const size_t maxItems) : _maxItemsInMemoryPool(maxItems)
{
// initialize itemsToInitNowitems immediately
for(size_t i = 0; i < itemsToInitNow; ++i) {
_factory.CreateItem(); // this fails :( // just an example of how to trigger the failure
_container.push_back(MemoryItemSharedPointer(new MemoryItem<T>(_factory.CreateItem()))); // this fails (and it is what I really want to do)
}
}
private:
// private data members
AbstractFactory<T> _factory;
Code: Select all
MemoryPool<ParticleShape> mp;
My thoughts were that the _factory would be instantiated with the same type T that MemoryPool was instantiated with, but it says that it couldn't deduce the template type for _factory. I really just want _factory's type to be the same type that MemoryPool<T> is.System::Abstract<T>::CreateItem<void> : could not deduce template argument for T
Thanks to anyone who has any clue