在变量模板中使用lambdas调用std :: make_tuple - 这应该适用于C++ 11吗?

Gar*_*art 3 c++ lambda tuples variadic-templates c++11

在C++ 11中,lambda函数是一个对象,应该可以用它来调用make_tuple,对吗?

void foobar() {
    auto t = std::make_tuple([](){ std::make_shared<int>(); });
}
Run Code Online (Sandbox Code Playgroud)

这段代码适合我.

现在,如果我们添加一个可变参数模板会发生什么:

#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;
}
Run Code Online (Sandbox Code Playgroud)

这个无法在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
Run Code Online (Sandbox Code Playgroud)

我想知道,这个代码是否符合标准?

eca*_*mur 6

这是gcc中的一个已知错误:http://gcc.gnu.org/bugzilla/show_bug.cgi? id = 41933(最初的示例是一个不同的模式,涵盖参数包的捕获,但问题是基础和合并的错误是gcc根本没有实现lambdas和variadics的交集.

就标准而言,它是完全可以接受的代码.