I just read the book "Practical C++ Metaprogramming" and it has the following example that I cannot compile. Can you help sort this out for me.
template <typename F>
struct make_tuple_of_params;
template <typename Ret, typename... Args>
struct make_tuple_of_params<Ret (Args...)>
{
using type = std::tuple<Args...>;
};
template <typename F>
using make_tuple_of_params_t = typename make_tuple_of_params<F>::type;
template<typename F>
void some_magic_function(F callable)
{
make_tuple_of_params_t<F> tuple;
/*
... do something with arguments in tuple...
*/
}
int main()
{
some_magic_function([] (int, double, float) {});
}
I get a compilation error saying: 'type' is not a member of any direct or indirect base class of 'make_tuple_of_params'. It seams like the SFINAE does not work as expected since the default struct is selected. How do I fix this?
auto
parameters which can obviously be perceived as templated functors. For this kind of lambdas what would you expect your tuple type look alike? – Bilharziasis