Boost logo

Boost :

From: Michael Fawcett (michael.fawcett_at_[hidden])
Date: 2007-10-22 15:29:40


On 10/22/07, Scott <cheesy4poofs_at_[hidden]> wrote:
> I have a map, declared as:
>
> typedef std::pair<int, HintPage *> PageCachePair;
> typedef boost::fast_pool_allocator<PageCachePair> PageCacheAllocator;
> typedef std::map<int, HintPage *, std::less<int>, PageCacheAllocator>
> PageCache;
>
> The problem is when I try to call:
>
> boost::singleton_pool<boost::fast_pool_allocator_tag,
> sizeof(PageCachePair)>::purge_memory();
>
> This always returns false. The real problem (of course) is that
> sizeof(PageCachePair) is incorrect. The real size is determined by the
> rebind mechanism for the actual map node struct. However, I have no idea
> how to portably determine that size.
>
> Is it even possible to do this?

I've ran into this before, and there are some old posts on the Mailing
List about this. I can't remember the solution off the top of my
head, so you may want to do a search, but I'm pretty sure there's no
portable way around this.

The big problem is that PageCache::allocator_type will still be
identical to your typedef, and get_allocator won't help because you
won't know the correct type to cast to.

--Michael Fawcett


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk