If and how is it possible to deduce the signature type from any callable in C++17? Snippet:
template <typename T>
struct MyFunction;
template <typename R, typename... Args>
struct MyFunction<R(Args...)>
{
};
template <typename Callable>
auto deduceSignature(Callable&& c)
{
// using Signature = ???;
// return MyFunction<Signature>{ ???};}
}
I would like to use use class template argument deduction in the return
statement.
In client code I want to write this then:
std::int8_t freeFunction(std::int8_t x)
{
return x;
}
auto c1 = deduceSignature(&freeFunction);
auto c2 = deduceSignature([](std::int8_t x){
return x;
});