|
Boost : |
From: Eric Niebler (eric_at_[hidden])
Date: 2008-07-01 16:42:41
David Abrahams wrote:
> Eric Niebler wrote:
>> David Abrahams wrote:
>>> Eric Niebler wrote:
>>>> David Abrahams wrote:
>>>>> Eric Niebler wrote:
>>>>>
>>>>> -- snip 2^10 overloads --
>>>>>
>>>>> Yeah, that's probably too much, but I'm not sure we have to support
>>>>> forwarding for that many arguments. The only thing rvalue forwarding
>>>>> buys you (and it can be a big win) is the ability for the wrapped thing
>>>>> to make certain optimizations. It's a good idea when you can do
>>>>> it. If
>>>>> you can't do it, you can fall back to lvalues and in C++03 you've still
>>>>> done a credible job.
>>>> Even 2^3 overloads has a *very* noticeable effect on compile times.
>>> 8 overloads hurts compile times?
>> Yes, because for each function invocation you have to calculate the
>> return type 8x in 8 different ways.
>
> Hmm. Why? Seems to me that only one specialization of the wrapped
> class template needs to be instantiated per invocation.
Take the simple case with 1 arg:
template<typename T>
typename result_of<F(T &)>::type
fun( T & t );
template<typename T>
typename result_of<F(T const &)>::type
fun( T const & t );
Now I invoke fun(x). The compiler has to do overload resolution. First
it has to determine function signatures. In so doing, it computes the
return type for both overloads. For 3 arguments there are 8 overloads
and the return type needs to be calculated 8x in 8 different ways, even
though only one will ever be used.
<snip the rest, which I need to think more about>
-- 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