See the following:
struct A
{
std::string* get() const
{
//return const_cast<std::string*>(&m_pObj);
return &const_cast<A*>(this)->m_pObj;
}
std::string m_pObj;
};
Is dereferencing const_cast
of this
UB? Is there any time dereferencing the result from const_cast
ing the constness of a pointer away doesn't invoke UB?
(I know the above example is bad practice, bad design, and could be solved with mutable - that's not the point)