I am just asking how to make "template & lten typename> bool Function_", since the bool part is not valid in C ++ at the moment.
As far as I know, template template arguments are a completely different matter. They are intended for containers, not functions. So class , not bool .
here is an example of why I cannot pass "is_pointer" to a function
Your example does not work because add_pointer is a template function, so when you call
apply(add_pointer, t_i);
the compiler does not know which version (type T ) add_pointer use.
The solution may be explicit, as in the following simplified example.
#include <tuple> #include <iostream> template <typename T> constexpr auto add_pointer(std::tuple<T>) noexcept { std::cout << "add_pointer" << std::endl; return 0; } template <typename F, typename T> constexpr auto apply(F f, std::tuple<T> t) noexcept { return f(t); } int main(void) { std::tuple<int> t_i { 1 }; apply<int(*)(std::tuple<int>)>(add_pointer, t_i); }
but I understand that explaining int(*)(std::tuple<int>) is a big pain in the ass.
You can simplify the use of the fact that you pass T so that you can deduce the type of the argument received by the function, but (for a general solution) I donβt know how to avoid explicitly returning the type of the function (maybe this is possible, but (at this point) I do not know.
This way you can simplify the call as follows
apply<int>(add_pointer, t_i);
and below is a more general example
#include <tuple> #include <iostream> template <typename ... Ts> constexpr auto add_pointer(std::tuple<Ts...> const &) noexcept { std::cout << "add_pointer" << std::endl; return 0; } template <typename R, typename ... Ts, typename F = R(*)(std::tuple<Ts...> const &)> constexpr auto apply(F f, std::tuple<Ts...> t) noexcept { return f(t); } int main(void) { std::tuple<int> t_i { 1 }; apply<int>(add_pointer, t_i); }