i trying define type trait can use static_assert
control 1 of template classes instantiated std::array<t,n>
. here attempt:
template <typename t> struct is_std_array : public false_type {}; template <template <typename, size_t> class t, typename v, size_t n> struct is_std_array<std::array<v, n>> : public true_type {};
but following warning clang:
warning: class template partial specialization contains template parameter cannot deduced; partial specialization never used non-deductible template parameter 't'
why 't' not deductible? how fix that?
your syntax on specializing wrong:
template <template <typename, size_t> class t, typename v, size_t n>
you're introducing three template parameters here: first of template template parameter named t
, takes 2 parameters: type , size_t
. since t
not referenced anywhere in specialization clause:
struct is_std_array<std::array<v, n>> // <== no t
it's non-deduced context. think of equivalently written function:
template <template <typename, size_t> class t, typename v, size_t n> void foo(std::array<v, n> );
here, also, t
non-deduced context , have specified explicitly. however, don't need t
@ all! v
, n
. mean introduce 2 relevant parameters directly:
template <typename v, size_t n> struct is_std_array<std::array<v, n>> : public true_type {};
Comments
Post a Comment