Issue 61472
Summary [Clang] Clang cannot deduce the type of a wrapper function.
Labels new issue
Assignees
Reporter haoyang9804
    Repro file: https://godbolt.org/z/MPT6qezjs
```C++
#include <iostream>
#include <concepts>
#include <type_traits>

template<typename Fp, typename... A>
concept AcanPasstoFp = requires(Fp f, A... as) {
 f(as...);
};
template<typename R, typename Fp, typename... A>
requires AcanPasstoFp<Fp, A...>
using WrapperType = R(*)(Fp, A...);

template<typename R, typename Fp, typename... A>
void metaWrapper(WrapperType<R, Fp, A...> wrapper, Fp f, A... as) {
 wrapper(f, as...);
}

template<typename R, typename... A, typename Fp = R(*)(A...)>
void wrapper1(Fp f, A... as) {
	std::cout << "wrapper1 !!" << std::endl;
  f(as...);
}

void f1(int x) {
 std::cout << "f1" << std::endl;
}

int main() {
 metaWrapper(wrapper1, f1, 1); 
}
```

I thought Clang can easily deduce `R` of metaWrapper cause the return type of wrapper is obviously `void`. But it fails with the following error message:
```
<source>:29:3: error: no matching function for call to 'metaWrapper'
  metaWrapper(wrapper1, f1, 1); 
 ^~~~~~~~~~~
<source>:14:6: note: candidate template ignored: couldn't infer template argument 'R'
void metaWrapper(WrapperType<R, Fp, A...> wrapper, Fp f, A... as) {
     ^
1 error generated.
```

Since I am new to generic programming with C++, I cannot tell if it's my fault or Clang's problem. Could anyone explain? Thanks
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to