This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [C++ dayly bug report] const_cast to rvalue of class type



hi,


> patrick <patrick@mail.boxsoft.com> writes:
> 
> | Sometime in the late 1900s it was said:
> | 
> | OK.  I may be in the dark here too.  But afaik const_cast<T>( t )
> | will cast t to T exactly as  (T)t  would have iff T and the type
> | of t are different either in 'const' and 'volatile'.  At least that
> | is what Bjarne Stroustrup confirms (as I paraphrased from his book).
> 
> Exact citation please.


"The C++ Programming Language" 2nd Edition
Bjarne Stroustrup
ISBN 0-201-53992-6
page: 639, 3rd paragraph.

   const_cast<T>(e) casts e to a T exactly as (T)e would have done
   provided T and the type of e differ only in const and volatile
   modifiers.  Otherwise, const_cast<T>(e) is an error.  Thus,
   const_cast manipulates "constness" only and not other aspects
   of type.


I'm not sure if this is what you wanted me to provide.  I assumed
most everyone knew of Bjarne's work.


patrick@boxsoft.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]