This could be a duplicate[link] but, the answer is rather short and not very clear. In a possible implementation like this:
template <class T>
T * addressof(T & v)
{
return reinterpret_cast<T *>(& const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
}
why is the const_cast
needed?