You can do this in several ways. As another answer points out you can do it with a static_assert (preferably from C++11/Boost although you can roll your own), although I'd recommend checking if it is actually a pointer and not just relying on the size. You can either roll your own or use an existing trait (available in C++11 too) depending on what system you're using:
template <typename T> struct is_pointer { enum { value = 0 }; }; template <typename T> struct is_pointer<T*> { enum { value = 1 }; }; template <typename T> struct container { static_assert(is_pointer<T>::value, "T must be a pointer"); void push(const T&); T pop(); }; struct foo {}; int main() { container<foo*> good; container<foo> fail; }
But that raises a bigger point. If your requirement is that you only ever point to things, why not interpret the template parameter like that to begin with? E.g. make your container:
template <typename T> struct container { void push(const T*); T *pop(); };
instead of allowing people to specify non-pointer types in the first place?
Finally if you don't want to go down the static_assert road you can just specialise the container for pointer types only and not implement it for non-pointers, e.g.:
template <typename T> struct container; template <typename T> struct container<T*> { void push(const T*); T *pop(); }; struct foo {}; int main() { container<foo*> good; container<foo> fail; }
This still requires explicitly making the type a pointer, still causes compile time failure for non-pointer types, but doesn't need a static_assert or way of determining if a type is a pointer.