"Peter Dimov" <[EMAIL PROTECTED]> writes:

> From: "David Abrahams" <[EMAIL PROTECTED]>
>>
>> Here's what I think might be a correct implementation:
>>
>>      template <class T, class U> T implicit_cast(U const& x) { return x; }
>>      template <class T, class U> T implicit_cast(U& x) { return x; }
>
> The correct implementation IIRC is
>
> template<class T> T implicit_cast(typename identity<T>::type x) { return
> x; }


Now I have to put on my inference hat.

...so the use of identity<> assures that we have a non-deduced
context, which causes the explicit template parameter to be required?

...I suppose that T has to be copyable for any of these to work, so
there's no problem with taking T by-value.

OK, I like this implementation. I'm going to add it to cast.hpp unless
there are objections.

-- 
                       David Abrahams
   [EMAIL PROTECTED] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to