https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93154
Bug ID: 93154
Summary: can't constrain captured functions to be invocable
with lambda arg - unknown "constraints not satisfied"
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: db0451 at gmail dot com
Target Milestone: ---
Surely the below should work? I'm currently trying to go overboard with
declaring constraints, and that `requires` clause - while perhaps a bit
superfluous - seems totally correct... right?
However, it doesn't compile, citing "constraints not satisfied" - and yet
notably not bothering to mention WHICH constraint supposedly has the problem!
g++-10 (Debian 10-20191217-1) 10.0.0 20191217 (experimental) [trunk revision
279456]
```
#include <concepts>
void f1(int) {}
template <typename... Fs> requires (sizeof...(Fs) > 0)
auto
make_lambda(Fs... fs)
{
return [fs...]
<typename Arg>
requires (std::invocable<Fs, Arg> && ...)
(Arg a)
{
(fs(a), ...);
};
}
auto
main() -> int
{
auto const lambda = make_lambda(&f1);
lambda(42);
return 0;
}
```
...results in the error:
>>>
test5.cpp: In function ‘int main()’:
test5.cpp:22:11: error: no match for call to ‘(const make_lambda(Fs ...) [with
Fs = {void (*)(int)}]::<lambda(Arg)>) (int)’
22 | lambda(42);
| ^
test5.cpp:9:9: note: candidate: ‘make_lambda(Fs ...) [with Fs = {void
(*)(int)}]::<lambda(Arg)> [with Arg = int]’
9 | return [fs...]
| ^
test5.cpp:9:9: note: constraints not satisfied
>>>
preprocessed source: