|
Boost : |
Subject: Re: [boost] [GSoC][MPL11] Post C++Now update
From: Larry Evans (cppljevans_at_[hidden])
Date: 2014-05-31 17:54:18
On 05/20/14 15:48, Zach Laine wrote:
> 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.
AFAICT, the number of template function instantiations in the linked
article are the same as the number of template class instantiations.
When I run the attached, 1st with:
defined(CONSTEXPR)
then with:
!defined(COnSTEXPR)
the same values appear in the:
(yesno,recurs)
output, indicating the same number of instantiations.
Am I missing something?
BTW, I've asked a similar question on the linked page.
> 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:
[snip]
>> According to:
>>
>> http://cpptruths.blogspot.com/2011/07/want-speed-use-constexpr-meta.html
>>
>> template function recursion *should* compile faster than template
>> metafunction recursion.
[snip]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk