@zbigg:
That pack expansion occurs when it is an argument of another function that you are calling (see Slide 8/34 where the pack expansion of Ts and vs occurs on std::forward when calling the gun function).
Here's another example:
#include <iostream>
template < typename TYPE >
inline TYPE g ( TYPE value ) {
return value;
}
inline void f () {
//
}
template < typename HEAD_TYPE, typename ... TAIL_TYPE_PACK >
inline void f ( HEAD_TYPE head_value, TAIL_TYPE_PACK ... tail_value_pack ) {
std::cout << head_value << '\n';
f( g( tail_value_pack ) ... );
}
int main () {
f( 1.0, "2", 3, "four" );
return 0;
}The code (I believe) you are interested in is the line ...
f( g( tail_value_pack ) ... );... in the templated f function. The first time through the templated f function, you could think of the tail_value_pack as being { "2", 3, "four" } and the f( g( tail_value_pack ) ... ) call as expanding to
f( g( "2" ), g( 3 ), g( "four" ) );. Similarly for the recursive-looking overloaded calls to the templated f function. Once the tail_value_pack is empty, then you could think of the tail_value_pack as being { } and the f( g( tail_value_pack ) ... ) call as expanding to
f( );... hence, the empty regular f function before the templated f function in the code above.
Using MinGW's g++ version 4.6.2, you can compile and run this using:
g++ -o main.exe -std=c++0x -march=native -O3 -Wall -Wextra -Werror main.cpp && ./main.exe
The following is the output of the code above:
1 2 3 four
I believe this is covered in section 14.5.3 point 5 ... it seems to be listed in the exampe as:
f(const_cast<const Args*>(&args)...); // OK: “Args” and “args” are expanded. I don't have the ISO standard, but this was page 346 of N3291 (released April 5th of 2011).
Hope This Helps,
Joshua Burkholder