Boost logo

Boost :

From: Simon Buchan (simon_at_[hidden])
Date: 2005-09-25 19:07:05

Graeme Prentice wrote:
<snipped big header>
>>#include <boost/call_traits.hpp>
>>template < typename P1 >
>>void foo ( typename ::boost::call_traits < P1 >::param_type p1 )
>>int main ( )
>> foo ( 42 ); // error here
>> return 0;
> This is the infamous non-deduced context. A nested name specifier
> (call_traits) is a non-deduced context so P1 cannot be deduced. You have to
> write foo<int>(42). This is like an invisible cast, so you have to remember
> to change all the explicit type specifiers if you change the type of an
> argument being passed in such a function.

You mean:
     template <class T>
     void foo( typename bar<T>::baz froble) {...}
is fine, but:
     template <class T>
     void foo( typename bling::bar<T>::baz froble) {...}
isn't? That sounds like a language flaw!

>>(Background info: I would like to use this technique to generate
>>optimized forwarding functions that do not know anything about the
>>function being forwarded to. Overloads taking any number of params
>>would be generated with the boost preprocessor library.)
> It might be better to write specializations for foo rather than specify the
> types at the point of call.
> Graeme

Doesn't that defeat the point of a forwarding function? I agree that
it's better than most of the alternatives, though.

Boost list run by bdawes at, gregod at, cpdaniel at, john at