tags:

views:

125

answers:

1

Basically im giving a very weak shot at trying to centralize memory management. Anyways, boost::pool uses chunks of certain sizes.

My orignal idea, was to overload new and delete, pass the size into a singleton which would go to the corresponding boost pool and alloc from there.

std::map<size_t, boost::pool<> > m_MemPools;

Anyways it seems like i cannot have a map of boost pools, since it MSVC9 gives me the following error,

:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\map(173) : error C2512: 'boost::pool<>::pool' : no appropriate default constructor available

Why would this be happening?

EDIT

I solved it, i ended up just wrapping it in a shared_ptr, which resolves the issue.

Just to show something, i do not use [] anymore, and it still gives this error,

class Pooly
{
public:

    Foo()
    {
    }

    void RegisterPool(__in const size_t poolSize)
    {
        if(pools.find(poolSize) == pools.end())
            pools.insert(std::make_pair(poolSize, boost::pool<>(poolSize)));
    }
private:
    std::map<size_t, boost::pool<> > pools;
};

Im guessing it has to do with std::make_pair?

Etherway wrapping it a smart pointer works fine, shouldnt this be something that should be included in boost pool though?

+1  A: 

Are you using the [] operator to insert into the map? This requires the data_type, in this case boost::pool, to be default constructible, i.e. it must have a default constructor that takes no arguments. But boost::pool does not have a default constructor.

Charles Salvia
Yep removing the [] calls. Results in this error tho.error C2248: 'boost::simple_segregated_storage<SizeType>::simple_segregated_storage' : cannot access private member declared in class 'boost::simple_segregated_storage<SizeType>' I'll take it basically have to just try something else?
UberJumper