Say you have a class such as:
template<typename T>
class Foo
{
public:
T value;
public:
Foo(const T& value)
{
this->value = value;
}
public:
~Foo()
{
if(std::is_pointer<T>::value) delete value;
}
}
Now, obviously the compiler will throw an error if T
isn't a pointer. Example:
Foo<int> foo(42);
Is there a way to successfully check if T
is a pointer, delete it if it is, without a compiler error?