Boost logo

Boost :

Subject: Re: [boost] [MPL][vector] Is there interest in mpl::vector using variadic templates?
From: Bruno Dutra (brunocodutra_at_[hidden])
Date: 2017-03-03 17:21:47


On Mar 3, 2017 17:58, "Peter Dimov via Boost" <boost_at_[hidden]> wrote:

Bruno Dutra wrote:

OTOH the void* trick requires that a pack of M void pointers be
> instantiated when the element at position M is retrieved from a list, so,
> for a list of N elements, the compiler must instantiate N *distinct* packs
> of void pointers, because each of these packs have a different size and is
> thus a distinct type.
>

Not just that, but the helper function that is required to obtain the Mth
element is a template instantiation as well.

Saying that we shouldn't use map_from_list because it consumes memory for
the instantiation is misleading; the alternatives consume memory for
instantiations as well. Except for __type_pack_element, of course.

Right, the trick is usually to figure out what consumes less memory, i.e.
what leads to the least amount of distinct template instantiations. Alias
templates help a lot with that, since they are not actually instantiated,
but there is only so much one can do with alias templates alone.

Bruno


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