[英]Why can't I convert [](auto&&…){} into a std::function<void()>?
When I try to compile this: 当我尝试编译时:
#include <functional>
void f(std::function<void()> f)
{
}
void g()
{
f([](auto&&...){});
}
on gcc 7.3, I get the following error: 在gcc 7.3上,出现以下错误:
[x86-64 gcc 7.3 #1] error: could not convert '
<lambda closure object>g()::<lambda(auto:1&&, ...)>{}
' from 'g()::<lambda(auto:1&&, ...)>
' to 'std::function<void()>
' [x86-64 gcc 7.3#1]错误:无法将'<lambda closure object>g()::<lambda(auto:1&&, ...)>{}
'从'g()::<lambda(auto:1&&, ...)>
'到'std::function<void()>
'
Can someone explain why this is invalid c++? 有人可以解释为什么这是无效的c ++吗? Or should I submit a bug report? 还是应该提交错误报告? (MSVC 14 accepts and compiles it to what I expect.) (MSVC 14接受并将其编译为我所期望的。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.