Boost logo

Boost :

Subject: Re: [boost] Reimplementation of the MPL for C++11
From: Larry Evans (cppljevans_at_[hidden])
Date: 2013-10-20 07:23:40


On 10/19/13 12:49, Louis Dionne wrote:
> pfultz2 <pfultz2 <at> yahoo.com> writes:
>
> [...]
>
>> Then we have O(1) lookup using decltype:
>>
>> template<class Vector, class Index>
>> struct at
>> {
>> typedef decltype(Vector::item_(Index())) type;
>> };
>>
>> I haven't tested this code yet, but the Boost.MPL works in a similiar way
>> for compilers that suppor typeof. Of course generating the `item_` overloads
>
> [...]
>
> That's how the map is currently implemented, but I don't use the preprocessor
> to generate overloads.
>
> See the top of [1] for details, it's pretty simple.
>
> Regards,
>
>
> Louis Dionne
>
> [1]: github.com/ldionne/mpl11/blob/master/include/boost/mpl11/container/map.hpp
>
>
>
Hi Dionne,

I tried variadic templates several years ago.
The code is here:

http://svn.boost.org/svn/boost/sandbox/variadic_templates/boost/mpl/

Unfortunately, as Eric and Mathias already hinted, the compile
times are much slower than with the existing mpl. The existing
mpl uses the preprocessor to lessen compile times, a method
mentioned by Eric in his (b) item:

   (b) using the preprocessor and living with arbitrary limits.

Christopher Schmidt used the preprocessor to implement
a variadic fusion using the help of the preprocessor to lessen
compile times but, IIUC, he used some method (I'll call it
"chunking") so that the preprocessor didn't have arbitrary
limits:

   http://lists.boost.org/Archives/boost/2012/03/191091.php

NOTE: I tried the link in that post to Christopher's code
and it no longer works :( However, I'm sure Christopher
(if you can find his email address) would be able to
supply an update location for the code. You might could
use the chunking method to minimize the compile times.

HTH.
-regards,
Larry


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