August 2012
Intermediate to advanced
976 pages
30h 17m
English
sizeof... OperatorWhen we need to know how many elements there are in a pack, we can use the sizeof... operator. Like sizeof (§ 4.9, p. 156), sizeof... returns a constant expression (§ 2.4.4, p. 65) and does not evaluate its argument:
template<typename ... Args> void g(Args ... args) { cout << sizeof...(Args) << endl; // number of type parameters cout << sizeof...(args) << endl; // number of function parameters}
Exercises Section 16.4
Exercise 16.51: Determine what sizeof...(Args) and sizeof...(rest) return for each call to foo in this section.
Exercise 16.52: Write a program to check your answer to the previous question.
Read now
Unlock full access