换个能编译的例子:
#include <concepts>
struct Callback{};
template<typename... Args, std::invocable<Args..., Callback> Func> void reg(Func)
{
// need to forward<Args>
}
int main()
{
// good
reg<double, char>([](double, char, Callback) -> void
{
});
// bad
reg([](double, char, Callback)
{
});
return 0;
}
出错:
/usr/include/c++/11/concepts: In substitution of ‘template<class ... Args, class Func> requires invocable<Func, Args ..., Callback> void reg(Func) [with Args = {}; Func = main()::<lambda(double, char, Callback)>]’
如果不显式提供,那第一个Args推断成{}, 为啥不是{double,char}?
--
修改:allegro FROM 158.140.1.*
FROM 158.140.1.*