Given the following:
constexpr auto t = std::make_tuple(3, 2, 1);
template<auto x>
auto InnerF() {return -x;}
auto OuterF(auto... args) {return (args + ...);}
I can use the elements of t as parameters to InnerF directly:
InnerF<std::get<0>(t)>();
But I want to be able to write
std::apply([](auto... arg) { return OuterF(InnerF<arg>()...); }, t);
But this does not work, I get
<source>:29:44: error: no matching function for call to 'InnerF'
std::apply([](auto... arg) { return OuterF(InnerF<arg>()...) ;}, t);
.
.
.
<source>:29:44: error: no matching function for call to 'InnerF'
std::apply([](auto... arg) { return OuterF(InnerF<arg>()...) ;}, t);
^~~~~~~~~~~
<source>:23:6: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'x'
auto InnerF() {return -x;}
I don't understand why the arg is considered invalid, I tried modifying the syntax a number of ways and reimplementing apply myself, but couldn't crack it - is there any way to make this work?