Boost logo

Boost :

Subject: Re: [boost] Interesting article on stack-based TMP
From: Eric Niebler (eric_at_[hidden])
Date: 2012-10-23 12:05:07


(dropping the boost-users list...)

On 10/23/2012 7:27 AM, Thorsten Ottosen wrote:
> On 23-10-2012 15:05, Larry Evans wrote:
>> However, using variadic templates may cause a slowdown in the
>> compile times. IIRC, a variadic template version of proto was
>> developed but was abandoned in favor of using:
>>
>> http://www.boost.org/doc/libs/1_51_0/libs/preprocessor/doc/index.html
>>
>> because of large compile times.
>
> Hm.
>
> This is really sad if variadic templates can't be used for the thing
> they were created for. Is this an inherent problem for large-scale use
> of variadic templates?

I don't want the results of my early experimentation with variadic
templates to be used to draw conclusions about the feature. What Larry
says is true, but in part it was due to my own naivete. Variadic
templates are very good for *some* things, like perfect forwarding.
Other things can be done in very tricky ways of which I was not aware at
the time, like getting O(1) access to the back of a template parameter
pack. And yeah, sometimes preprocessing can still improve compile-times.
Without random access into a parameter pack, a data structure like
std::tuple is a massive, bloated TMP hog.

A fully variadic Proto *is* possible, and would probably compile faster
than the non-variadic one. Creating such a library is a non-trivial
undertaking, but you can see my progress thus far at:

https://github.com/ericniebler/proto-0x

I have only needed preprocessing to partly unroll proto::expr, which is
a tuple-like data structure. I imagine that a fully variadic mpl::vector
will also be problematic.

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com

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