|
Boost : |
Subject: Re: [boost] Reimplementation of the MPL for C++11
From: Agustín K-ballo Bergé (kaballo86_at_[hidden])
Date: 2013-10-20 11:33:52
On 20/10/2013 09:04 a.m., Larry Evans wrote:
> On 10/20/13 06:23, Larry Evans wrote:
> [snip]
>> 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.
>>
> The code here:
>
> http://svn.boost.org/svn/boost/sandbox/variadic_templates/sandbox/slim/
>
> might be helpful. It was based on Chrisopher's code but had
> to be modified slightly as mentioned in the post:
>
> http://comments.gmane.org/gmane.comp.compilers.clang.devel/24145
>
> which also mentions the slow compile times when not using the
> preprocessor.
>
Compilers appear to have improved since then! I decided to take gcc4.8.1
and fusion::map for a spin, since I happen to have a variadic
implementation of map that does not use recursion. The results of this
crude exercise can be found here:
https://gist.github.com/K-ballo/a44590159133997abcdc
What I read from them is that each technique reduces compile-time and
memory usage in the order I'd expected (C++98 > C++98 preprocessed >
C++11 recursive > C++11 non-recursive), contrary to what this thread
seems to be saying. Additionally, instantiating a 255 element variadic
non-recursive map and getting to the middle of it takes only slightly
more time and just 1.3x the memory it takes doing the same for a 50
element C++03 preprocessed map.
There's lots of potential in variadics, as long as they are implemented
carefully.
Regards,
-- Agustín K-ballo Bergé.- http://talesofcpp.fusionfenix.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk