Boost logo

Boost :

From: Edson Tadeu (e.tadeu_at_[hidden])
Date: 2007-12-03 15:13:13


I've also run into this problem, but using list<>.
I couldn't find anything else about this in the mailing list... (maybe I
used the wrong keywords in the search?)

Did someone find a portable solution? (i.e., without needing to recur to
ugly hacks such as using list<>::_Node)

Better yet... is there a portable way to use the "Object Usage" pool with
STL containers, instead of the static one?

  Thanks in advance
Edson

On Oct 22, 2007 5:29 PM, Michael Fawcett <michael.fawcett_at_[hidden]> wrote:

> 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