Suppose you want to do this 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, but you don't need to get around the arguments. Unfortunately this does 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 about the error: there is no corresponding function to call the count_int () function on the next line. Why and how can this be fixed? Thank.
source
share