Tuesday, April 11, 2023

Digest for comp.lang.c++@googlegroups.com - 2 updates in 1 topic

quanzhou <anhonghe@gmail.com>: Apr 11 10:03AM -0700

#include <concepts>
 

struct Callback{};

template<typename... Args, std::invocable<Args..., Callback> Func> void reg(Func)
{
}

int main()
{
// good
reg<double, char>([](double, char, Callback) -> void
{
});

// bad
reg([](double, char, Callback)
{
});

return 0;
}
 
Tried g++-11, error as following:
 
/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)>]'
 
See Args get as {} while Func is correct.
What I would like is Args to be {double, char}, why I need to explicitly provide it?
 
Thanks all you experts.
quanzhou <anhonghe@gmail.com>: Apr 11 10:18AM -0700

I need this Args... type deduction in reg() function because I'm gonna forward it.

 
在 2023年4月11日星期二 UTC-7 10:03:21,<quanzhou> 写道:
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: