This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ dayly bug report] const_cast to rvalue of class type
Yep, didn't notice the '&' there at first. I guess I can't disagree
with your interpretation of the text. It does seem vauge in this area. I
wonder why they didn't explicitly mention a limitation of only
const_cast'ing pointers and references like they did for dynamic_cast if
that was their intent. I still don't believe that it was their intent to
limit the const_cast as you say at all. Can you tell me why this
limitation would be meaningful? I don't see anything gained by it.
thanx & later,
Ben Scherrey
Gabriel Dos_Reis wrote:
> 5.2.11/4 states exactly:
>
> ---
> An lvalue of type T1 can be explicitly converted to an lvalue of
> type T2 using the cast const_cast<T2&> (whete T1 and T2 are object
> ^
> types) if a pointer to T1 can be explicitly converted to the type
> pointer T2 using const_cast. The result of a reference const_cast
> refers to the original object.
> ---
>
> Notice 'T2&' in the syntax.
>
> the remaining of 5.2.11 doesn't mention any case where const_cast<T2>
> is allowed when T2 is class type.