[RFC] Implementing addressof for C++0x

Paolo Carlini paolo.carlini@oracle.com
Thu May 20 11:55:00 GMT 2010

>>> ... 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,
Ah, ok, it will be a little bigger then, I missed testing functions,
thanks. I will post the complete patch, in case.
> and because of compiler bugs.
Luckily we don't need that.
> Any kind of acknowledgment is fine with me, including none at all.
> Whichever you prefer. :-)
You are very kind, thanks. After all, we should still be below, say, 20
lines of code, thus, if you are ok with that, we are not going to need a
Copyright assignment, etc.


More information about the Gcc mailing list