templates - Variadic functions (without arguments!) -


let's assume want in c++0x:

size_t count_int() { return 0; } template<typename t, typename... tn> size_t count_int(t a0, tn... an) {     size_t n = is_integer<t>::value ? 1 : 0;     return n + count_int(an...); } 

nice, feels unnecessary pass around arguments. unfortunately, not work:

size_t count_int() { return 0; } template<typename t, typename... tn> size_t count_int() {     size_t n = is_integer<t>::value ? 1 : 0;     return n + count_int<tn...>(); } 

gcc complains error: no matching function call 'count_int()' in next-to-last line. why , how can fixed? thanks.

this works:

template <typename t> size_t count_int() {    return is_integer<t>::value ? 1 : 0; }  template<typename t, typename t1, typename... tn> size_t count_int() {     size_t n = is_integer<t>::value ? 1 : 0;     return n + count_int<t1,tn...>(); }; 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -