You may use: https://ideone.com/wR2dLX
template<template<class> class T, class U>
struct isDerivedFrom
{
private:
template<class V>
static decltype(static_cast<const T<V>&>(std::declval<U>()), std::true_type{})
test(const T<V>&);
static std::false_type test(...);
public:
static constexpr bool value = decltype(isDerivedFrom::test(std::declval<U>()))::value;
};
As private inheritance is not visible, the trait returns false
in the last case (for struct Derived : private Base<int> {};
).