I write a compare function in C++ that should dereference only when T is of pointer type:
template<class T> bool compare(const T& left, const T& right)
{
if (is_pointer<T>::value)
return *left <= *right;
return left <= right;
}
But it tries to dereference when T is int:
invalid type argument of unary ‘*’ (have ‘int’)