Boost logo

Boost :

Subject: Re: [boost] Adding polymorphic_value to boost
From: Thorsten Ottosen (tottosen_at_[hidden])
Date: 2017-11-23 15:24:07

Den 23-11-2017 kl. 00:31 skrev Phil Endecott via Boost:

> There's another way of implementing this, though; rather than
> pointing to the object in the heap you can store it in-place
> by allocating enough space for the largest possible derived
> subclass:


> That's just a sketch; many details omitted!  There are some obvious
> advantages and disadvantages of each approach and I'm definitely not
> saying this is better than the pointer-to-heap design.

That's going to use way too much space, make swap/move slow and possibly
noexcept(false), give poor reference stability. For that case of not
heap-allocating each object in isolation, boost::poly_collection seems
much better. So I would stick to the allocate on the heap approach.

kind regards


Boost list run by bdawes at, gregod at, cpdaniel at, john at