Calling std::make_tuple with lambdas in a variadic template - is this supposed to work in C++11?
c++, c++11, lambda, tuples, variadic-templates
Solution
This is a known bug in gcc: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41933 (the initial example is a different pattern covering capture of parameter packs, but the issue underlying that and the merged bugs is that gcc simply hasn't implemented the intersection of lambdas and variadics).
As far as the standard is concerned it's perfectly acceptable code.
Problem
in C++11 a lambda function is an object, and it should be possible to call make_tuple with it, right? ``` void foobar() { auto t = std::make_tuple([](){ std::make_shared<int>(); }); } ``` This code works for me. Now what happens if we add a variadic template: ``` #include <tuple> #include <memory> template <class... T> void foobar() { auto t = std::make_tuple([](){ std::make_shared<T>(); }...); } int main(int, char**) { foobar<int, float, double>(); return 0; } ``` This one fails to compile in GCC 4.7.2 ``` main.cpp: In lambda function: main.cpp:6:54: error: parameter packs not expanded with '...': main.cpp:6:54: note: 'T' main.cpp: In function 'void foobar()': main.cpp:6:57: error: expansion pattern '#'lambda_expr' not supported by dump_expr#<expression error>' contains no argument packs main.cpp: In instantiation of 'void foobar() [with T = {int, float, double}]': main.cpp:11:29: required from here ``` I wonder, is this code correct by the Standard ?