Question
Is it well defined to cast to an identical layout with const members?
Consider the following type:
template<typename T> struct View
{
T* data;
size_t size;
};
Is it valid to cast from: View<T>&
To View<const T>&
?
Does it invoke undefined behaviour?
I suspect the cast will work as intended on all compilers but will be technically undefined behaviour according to the standard due to the strict aliasing rule.