The below demo prints 21
instead of 12
. Why?
#include <iostream>
template<class... F> void callMany(F... fib){
[&](...){}(
(fib(),123)...
);
}
int main()
{
auto f1=[&](){std::cout<<"1";};
auto f2=[&](){std::cout<<"2";};
callMany(f1,f2);
}
I tested it with both vc++ and g++. Both result are the same.
Is it a standard behavior? If so, which rules, and why?
Does it depend on compiler?
There is a way to reverse it, but I think it is a bit unrelated.