// if you don't have a boost library, download it here: http://www.boost.org
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include <boost/static_assert.hpp>
struct B{};
struct D:B{};
struct X{};
// declarative way
template<typename T,typename Enable = void>
struct C;
template<typename T>
struct C<T,typename boost::enable_if<boost::is_base_of<B,T> >::type >
{
// do your business here!
};
// imperative way
template<typename T>
struct C1
{
private:
BOOST_STATIC_ASSERT( (boost::is_base_of<B,T>::value) );
public:
// do your business here!
};