Should non-capturing generic lambdas decay to function pointers?

▼魔方 西西 提交于 2019-12-05 05:37:53

This is a known GCC parsing bug (64095, 68071): [](auto...){} is being mistakenly parsed like [](auto, ...) {} rather than [](auto...x){}; the ellipsis is being parsed as C-style varargs rather than declaring a parameter pack (in language-lawyer terms, it's being parsed as part of the parameter-declaration-clause rather than the abstract-declarator, in violation of [dcl.fct]/17).

It should go without saying that [](auto, ...){} isn't convertible to void (*)(int).

The workaround is to give the pack a name; if you do, you'll see that the conversion compiles successfully.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!