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)
- libc++ version is more cutted: return (T*)&reinterpret_cast<const volatile char&>(x); Ruslo 14:10, 17 August 2013 (PDT)
The example results in the same address for both cases/calls. If you add a dummy member to class Ptr before member 'data' then each case/call will print a different address. I think it will be clearer in this way. 22.214.171.124 14:35, 18 June 2013 (PDT)
Yep, noticed it's too. Add a pad to example. Ruslo 14:10, 17 August 2013 (PDT)