#include <type_traits>
#include <utility>
struct B { };
struct D : B { };
template <typename T>
struct S {
typedef typename std::enable_if<std::is_base_of<B, T>::value>::type check;
};
int main()
{
S<B> x; // Ok!
S<D> y; // Ok!
S<int> z; // Not ok!
}
Утилита enable_if
и черта типа is_base_of
являются частью стандартной библиотеки C ++ 0x, но обе доступны и в Boost.