Maybe you just want to overload your operator='s:
template <class T2>
Number<T>& operator=( const Number<T2*>& number )
{
// Deep Copy
}
template <class T2>
Number<T>& operator=( const Number<T2>& number )
{
// Shallow Copy
}
In probably all other cases you want std::enable_if to statically decide which copy stategy shall be used depending on the type (most likely whether it is a pointer type, therefore e.g. std::is_pointer<T2>::value). This can then very easily simplified by if constexpr (C++17):
#include <type_traits>
template <class T2>
Number<T>& operator=( const Number<T2>& number )
{
if constexpr( std::is_pointer_v<T2> ){
// Deep Copy
}
else{
// Shallow Copy
}
return *this;
}
Hope this helps!