
26 Jun
2012
26 Jun
'12
5:48 p.m.
On Fri, May 4, 2012 at 2:14 PM, Robert Dailey <rcdailey.lists@gmail.com>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 malloc/new. -- Cory Nelson http://int64.org