You may do the following:
template class C, typename...Ts>
std::true_type is_base_of_template_impl(const C*);
template class C>
std::false_type is_base_of_template_impl(...);
template class C>
using is_base_of_template = decltype(is_base_of_template_impl(std::declval()));
Live Demo
but will fail with multiple inheritance or private inheritance from A
.
With Visual Studio 2017 this will fail when the base class template has more than one template parameter, and it is unable to deduce Ts...
Demo
VS Bug Report
Refactoring solves the problem for VS.
template < template class base,typename derived>
struct is_base_of_template_impl
{
template
static constexpr std::true_type test(const base *);
static constexpr std::false_type test(...);
using type = decltype(test(std::declval()));
};
template < template class base,typename derived>
using is_base_of_template = typename is_base_of_template_impl ::type;
Live Demo