正常に動作するコードは次のとおりです。
template<typename... Args> struct count;
template<>
struct count<> {
static const int value = 0;
};
template<typename T, typename... Args>
struct count<T, Args...> {
static const int value = 1 + count<Args...>::value;
};
なぜ count クラス テンプレートを部分的に特殊化する必要があるのか疑問に思っていました。
次のようなことができますか?
template< typename... args> struct dd; // edited according to answer but now getting error redeclared with 2 template parameters which is point below with mark %%
template<>
struct dd<>{
static const int value = 0;
};
template<typename T, typename... args> //%%
struct dd{
static const int value= 1+ dd<args...>::value;
};
しかし、これは機能しませんが、なぜですか?
どんな助けでも大歓迎です:)
編集:回答に従ってソリューションを編集しました。