samedi 5 décembre 2015

How to count number of specific template parameters?

I've got class with template.

template <typename T1, typename... T> struct st {};

I want to count number of specific parameter in T1 and T. I tried

template <typename T1, typename... T> 
struct st {
template<typename TT, typename TTT>
    static constexpr size_t count_num() {
      return std::is_same<TT, TTT>::value ? 1 : 0;
    }

    template<typename TT, typename TTT, typename ... TE>
    static constexpr size_t count_num() {
      return (std::is_same<TT, TTT>::value ? 1 : 0) +
      count_num<TT, TE...>();  
    }
    template <typename Kind>
    static constexpr size_t count() { 
        return count_num<Kind, T1, T...>();
    }};

but compiles says "call to 'count_num' is ambiguous". How to gain my goal?

Aucun commentaire:

Enregistrer un commentaire