I guess you can use partial specialization:
Code:
#include <boost/static_assert.hpp>
template <class T>
class X
{
BOOST_STATIC_ASSERT(sizeof(T)==0 && "non-pointer argument to X");
};
template <class T>
class X<T*>
{
};
int main()
{
X<int*> y; //OK
//X<int> x; //triggers STATIC_ASSERT
}
Another thing, if the class is meant for pointers, it might contain code that wouldn't compile anyway if the argument was not a pointer.
Also, in the case of the destroy function, the template argument is a non-pointer type:
Code:
int* p = new int;
destroy<int>(p);
If you try to pass a non-pointer you'll get an error (no matching function to call).