Gennaro Prota <[EMAIL PROTECTED]> writes: > On Sun, 19 Jan 2003 09:42:51 -0500, David Abrahams > <[EMAIL PROTECTED]> wrote: > >>>>For another thing, it would be a compile-error if the >>>>expression *can* be implicitly converted to the destination type, >>>>which makes no sense to me. >>> >>> Isn't this the intent? >> >>I don't know what the intent is; you never explained that to me. What >>this does is to static_cast only when it must be forced (often in the >>"unsafe" direction); it was hard to see how that could be useful. >>Maybe just as a way of stating and checking that you know what you're >>doing? > > Well, actually I did it just for the fun of it. The original thread > was about implicit_cast, not explicit, and I added some thoughts. In > any case the comment I've made here about the comma operator applies > to the implicit piece as well: > > template <typename T> > char implicit_cast (typename identity<T>::type x) { > return x; > } > > // incomplete return type now is here > template <typename T> > void implicit_cast (...); > > #define IMPLICIT_CAST(dst_type, expr) \ > ( sizeof( implicit_cast<dst_type>(expr) ) \ > , \ > static_cast<dst_type>(expr) \ > )
Why wouldn't you just write implicit_cast<dst_type>(expr) in this case? Are you trying to save copies? (You might think I'm not interested in the comma operator issue. I guess you'd be right. It would be good to do something about it, but I don't feel strongly. If you do, you will have to champion it). -- 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