Subject: Re: [boost] [pool] Objects of varying sizes
From: Cory Nelson (phrosty_at_[hidden])
Date: 2012-06-26 13:48:18
On Fri, May 4, 2012 at 2:14 PM, Robert Dailey <rcdailey.lists_at_[hidden]>wrote:
> Is it possible to create a pool for polymorphic types? For example:
> class A;
> class B : public A;
> class C : public A;
> I want to create a pool of type A, but the allocation can be for B or C at
> any time. Will this work?
For performance reasons, you'll only be able to allocate objects of a fixed
size. You might try a pool of variant<B,C> instead.
For a variable-sized pool, as an implementation detail most runtime
environments do implement a variable-sized pool behind the scenes for
-- Cory Nelson http://int64.org
Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk