|
Boost : |
From: Howard Hinnant (hinnant_at_[hidden])
Date: 2002-02-19 14:39:20
On Tuesday, February 19, 2002, at 02:13 PM, Gary Powell wrote:
>>> ---------------------------------
> If the return expression includes anything else, including more than one
> auto variables, it could involve an implicit conversion.
>
> template<typename A, typename B>
> auto operator+(A a, B b)
> {
> return a + b; // posible implicit conversion here.
> }
> <<--------------------------------------------------
> Yes!
> And we don't know what that conversion is! And we can't ask the
> compiler to tell us. Instead in LL, we had to do pages of
> type deduction code that "knows" what the conversions are. And
> if you are using a user defined class that has overloaded
> operator +() you have to tell us what the return type is. Its
> arcane, and the compiler does know it. But we can't find out.
> And we don't really care what it is, other than to pass it
> along to the calling function.
>
> You wouldn't believe what a killer issue this is until you
> try it. (Jeremy S. knows that's for sure, as does Peter D.)
You could find out with typeof(a+b).
That's not a plug for auto or typeof. I was just too amused to be
quiet. :-)
-Howard
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk