parameter packs not expanded with '...' ???

I tried to define this template function and the compiler generated a error saying "parameter packs not expanded with '...'."

 
template<typename T, typename ... Args> void foo(const T &t, const Args ... args) {cout << sizeof(Args) << " " << sizeof(args);}


Can someone tell me why? Thanks!
the operator sizeof expects a type or an expression. Args and args are not types or expressions, they are parameter packs.

The operator sizeof... accepts a pack, so you could compile
1
2
3
4
template<typename T, typename ... Args>
void foo(const T &t, const Args ... args) {
    cout << sizeof...(Args) << " " << sizeof...(args);
}
Oh, I was careless and overlooked the ellipsis after the sizeof on my textbook, but if Args is not a type, then what is it? I would guess it's a template class like iinitializer_list<T> , but then could sizeof be used on a class? I know that it can be used on string for sure.
Args is a type parameter pack. It's like a compile-time container holding zero or more types.
Okay, I see. Thanks for your reply!
Topic archived. No new replies allowed.