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)               \
            )


Genny.

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

Reply via email to