AFAIK, a template class with template argument <Type> is completely distinct from <const Type>.
template<typename T>
struct Wrapper
{
T obj = T{};
//other code
};
Now I can't pass Wrapper<int>& to a function that needs Wrapper<const int>&.
void someFunc(Wrapper<const int>& wrapper);
//...
Wrapper<int> wrapper;
someFunc(wrapper); //error
What can go wrong by reinterpret_cast'ing it to its const version?
operator Wrapper<const T>&() { return *(reinterpret_cast<Wrapper<const T>*>(this)); }
Adding the above line to Wrapper makes it work without having to create a new <const int> object. obj can't be accessed inside the function, so it should not matter if the passed parameter is actually <const Type> or <Type>.
Provided there is no template specialization, can anything go wrong here (as far as standard goes vs in practice)?