[RFC] Implementing addressof for C++0x

Peter Dimov pdimov@pdimov.com
Thu May 20 11:49:00 GMT 2010

> On 05/20/2010 01:10 PM, Paolo Carlini wrote:
>> ... for reference, it would be something like this (in my recollections,
>> it was even uglier ;)
>> template<typename _Tp>
>>   _Tp*
>>   addressof(_Tp& __v)
>>   {
>>     return reinterpret_cast<_Tp*>
>>       (&const_cast<char&>(reinterpret_cast<const volatile char&>(__v)));
>>   }

It's uglier because the code above doesn't work for functions, and because 
of compiler bugs.

> By the way, Peter (I think you are the author of the current boost
> implementation, which I looked at yesterday), in case we end up having
> something like the above, temporarily at least, which kind of
> acknowledgment would you be Ok with? Is it enough your name in the
> ChangeLog?

Any kind of acknowledgment is fine with me, including none at all. Whichever 
you prefer. :-)

More information about the Gcc mailing list