Namespaces
Variants
Views
Actions

Talk:cpp/memory/addressof

From cppreference.com

The "possible implementation" suffers by comparison with Boost's.

See http://ideone.com/7aGun5 for an example of a class for which this code will not return the address. The issue is that the C-style cast `(char&)` will call `T::operator char &` if it exists.

good catch, I guess the whole const_cast<char&> + reinterpret_cast<const volatile char&> dance found in stdlibc++ is unavoidable. --Cubbi 07:08, 7 December 2012 (PST)
Thanks for doing the edit. FYI, it came up on StackOverflow [1]. 81.110.180.57 06:51, 8 December 2012 (PST)