vendredi 25 septembre 2015

A type trait for std::array

I am trying to define a type trait that I can use with static_assert to control that one of my template classes is instantiated only with std::array<T,n>. Here is my 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 I get the following warning from clang:

warning: class template partial specialization contains a template parameter
that cannot be deduced; this partial specialization will never be used
non-deductible template parameter 'T'

Why is 'T' not deductible? How do I fix that?

Aucun commentaire:

Enregistrer un commentaire