Boost logo

Boost :

Subject: Re: [boost] [Pool]: How to tag pool_allocator
From: Chris Newbold (Chris.Newbold_at_[hidden])
Date: 2008-10-24 08:53:30


> From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]]
> On Behalf Of VoidEx
> Sent: Thursday, October 23, 2008 1:18 PM

> But I want use one pool_allocator for some strings/vectors/lists and
> another
> for some other data, because I want destroy data separately.

One thing to keep in mind is that the singleton_pool underneath pool_allocator is differentiated not only based on the tag (which, as you observe, is fixed in the case of pool_allocator) but also on the size of elements to be allocated.

This means that under at least some circumstances, there will be multiple singleon_pools servicing a _single_ STL container; std::list being the most obvious case. This makes it difficult to interact directly with the singleton_pool(s) for a given container.

That said, there doesn't seem to be any reason why we could not expose the tag used by pool_allocator (and fast_pool_allocator) to parameterization. The result might look something like this:

        template <typename T,
                  typename UserAllocator =
                      default_user_allocator_new_delete,
                  typename Mutex = boost::mutex,
                  unsigned NextSize = 32,
                  typename Tag = pool_allocator_tag>
        class pool_allocator;

Would that do what you want?

-Chris


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