开发者

map of boost pools?

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::开发者_如何学JAVApool<>(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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜