Gennaro Prota <[EMAIL PROTECTED]> writes:

> On Sat, 18 Jan 2003 21:55:59 -0500, David Abrahams
> <[EMAIL PROTECTED]> wrote:
>
>>Gennaro Prota <[EMAIL PROTECTED]> writes:
>
>>> I see. Can we expect an "extension" for C++0x then?
>>
>>Not unless someone makes a formal proposal.  Are you volunteering?
>
> Yes, I would be glad to write a formal proposal. But, as it has been
> repeatedly pointed out on comp.std.c++, this is not enough if you are
> not in the committee and that, de facto, there are very little chances
> for the proposal to be approved if you are not present to defend it
> and respond to questions and, above all, objections.

Anyone can show up for a meeting.  Another thing you can do is to
convince someone who will be there to represent the proposal for you.

>>> Do you remember my EXPLICIT_CAST?
>>
>>Nope.
>>
>>> #define EXPLICIT_CAST(dst_type, expr)                  \
>>>           ( static_cast<  check_helper<dst_type,       \
>>>             sizeof(implicit_cast<dst_type>(expr)) >    \
>>>             :: type>(expr)  )
>>>
>>> The intent was for it to be suitable for constant expressions. Well,
>>> as you may have noticed the check_helper<> template was there just
>>> because I couldn't do something like:
>>>
>>>
>>> template <typename T>
>>> void implicit_cast (typename identity<T>::type x) {
>>>     return x;
>>> }
>>>
>>>
>>> template <typename T>
>>> char implicit_cast (...);
>>>
>>> #define EXPLICIT_CAST(dst_type, expr)                 \
>>>           ( sizeof( implicit_cast<dst_type>(expr) )   \
>>>                      ,                                \
>>>             static_cast<dst_type>(expr)               \
>>>           )
>>>
>>>
>>> This seems natural: you use sizeof to check whether implicit
>>> conversion happens, then you discard its result. What's wrong with
>>> it?
>>
>>For one thing, it doesn't check whether an implicit conversion
>>occurs.
>
> Uh? It checks whether expr is implicitly convertible to dst_type, in
> the sense that if it is then it gives a diagnostic. What do you mean??
>
>>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?

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