|
Boost : |
Subject: Re: [boost] [GSoC][MPL11] Post C++Now update
From: Zach Laine (whatwasthataddress_at_[hidden])
Date: 2014-05-20 16:48:01
I've seen function template vs. metafunction template instantiations
profiled before, and I did it myself a few years ago. Function templates
have been slower in every profile I've seen. In my profilings, they were
~20% slower.
The linked article appears to get better results not by using constexpr
alone, but by using it to do numeric computations that allow it to reduce
template instantiations. When the instantiations are close to the same in
number, constexpr is slower. In your attachment, it appears that you are
iterating over types, and so constexpr and metafunction approaches should
involve the same number of template instantiations.
Zach
On Tue, May 20, 2014 at 3:20 PM, Larry Evans <cppljevans_at_[hidden]>wrote:
> On 05/20/14 13:59, Larry Evans wrote:
>
>> On 05/18/14 15:41, Louis Dionne wrote:
>>
> [snip]
>
> Request for guinea pigs
>>> -----------------------
>>> I am looking for people with hardcore C++1y metaprogramming needs who
>>> will
>>> be willing to test the library I come up with (MPL11 or MPL + Fusion
>>> merge).
>>> I also need to see use cases for the library, so please reply even if you
>>> are not willing to test.
>>>
>>>
>> As mentioned in this post:
>>
>> https://groups.google.com/forum/?hl=en#!msg/comp.std.c++
>> /_-6X_xZlKlA/-HhvKh5ccEAJ
>>
>>
>> One use case is:
>>
>> > 3) A guaranteed non-recursive way to access elements of parameter
>> > packs
>>
>> and Doug Gregor (quoting from above post) says:
>>
>> This is probably the most-requested feature for variadic templates,
>> and it never it made it because we never found a good, unambiguous
>> syntax.
>>
>> The attached seems to do that. What about adding something
>> like this to the library?
>>
>> -regards,
>> Larry
>>
>> I should clarify something from my previous post.
>
> The at_c.cpp attachment to my previous post *did* use recursion;
> however, it was template function recursion, not
> template metafunction recursion.
>
> According to:
>
> http://cpptruths.blogspot.com/2011/07/want-speed-use-constexpr-meta.html
>
> template function recursion *should* compile faster than template
> metafunction recursion. Although the above web page uses constexpr,
> there's no need for that in the at_c.cpp attachment because only
> the types are used, not the values (hence, the functions don't need
> to be defined).
>
> Sorry for being unclear.
>
> -regards,
> Larry
>
>
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/
> mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk