Boost logo

Boost :

Subject: Re: [boost] [cpo-proposal] presentation of the idea
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2013-08-28 11:50:51

On Wed, Aug 28, 2013 at 2:57 AM, Thorsten Ottosen <
thorsten.ottosen_at_[hidden]> wrote:

> On 28-08-2013 06:51, Gottlob Frege wrote:
>> We put the ItemHandler<Triangle> in a map<RTTI, BaseItemHandler*>.
> [Thorsten:]
> This is a bad idea IMO. The point of such a container is to provide
> as little fragmentation of the heap as possible, to get better
> locality of data (when the data consists of polymorphic objetcs).
> With
> std::vector<int>
> we get great locality. We don't yet have such an alternative for
> polymorphic objects.
> kind regards
> -Thorsten
Well I think there are trade offs. Is locality the number one feature?

It might be better to store the size (and type) of each object right beside
the object inside the data vector then. So at least iterating is local.

I would still use Type Handlers for copy/move. I think it is OK if
copy/move is slightly less local.

You could also probably track whether any of the Items have non-trivial
copy/move operators. ie in push_back<Item>() increment a nonTrivalCounter.
If nonTrivialCounter == 0 on copy/move, then do a memcpy, otherwise use the
Handlers to copy.

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