From: "Gennaro Prota" <[EMAIL PROTECTED]> > On Fri, 29 Nov 2002 21:20:14 +0200, "Peter Dimov" <[EMAIL PROTECTED]> > wrote: > > >From: "David Abrahams" <[EMAIL PROTECTED]> > > >> 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. > > > >The main reason to prefer this implementation is that it works in contexts > >where the conversion is accessible at the point of the implicit_cast call, > >but not accessible to the definition of implicit_cast. > > Yes, that's the reason for doing conversion directly "on the > argument". But I think David was asking why not: > > template<class T> > T implicit_cast(T x) { return x; }
Dave answered his own questions above. :-) I just supplied another "..." item. > The identity<> trick avoids this possible oversight (well, you must > explicitly specify 'Base' instead of 'Base&' as destination type to > make that error! :-). Maybe there are other reasons too, I asked this > to you in another post. Are there? No, the only reason is to make T nondeducible. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost