mardi 30 décembre 2014

'template argument deduction/substitution failed' after addition of an argument

I need template function which will call other function with arguments taken from std::tuple. I had written some code, which compiles properly:



#include <tuple>

template<typename ...ARGS1, typename ...ARGS2>
void foo(const std::tuple<ARGS1...> &, const std::tuple<ARGS2...> &)
{
//call function
}

int main()
{
std::tuple<int, bool> tuple1(0, false);
std::tuple<double, void*, float> tuple2(0.0, nullptr, 0.0f);
foo(tuple1, tuple2);
return 0;
}


Now I need add one more argument which is pointer to function:



#include <tuple>

template<typename ...ARGS1, typename ...ARGS2>
void foo(const std::tuple<ARGS1...> &, const std::tuple<ARGS2...> &, void (*)(ARGS1..., ARGS2...))
{
//call function
}

void bar(int, bool, double, void*, float)
{
}

int main()
{
std::tuple<int, bool> tuple1(0, false);
std::tuple<double, void*, float> tuple2(0.0, nullptr, 0.0f);
foo(tuple1, tuple2, &bar);
return 0;
}


I tried to do it in many different ways but compiler always returns template argument deduction/substitution failed and inconsistent parameter pack deduction with '' and ''. I don't understand, what's wrong with my code. There is not any helpful information in compiler output.


Could somebody help me write this properly?


Aucun commentaire:

Enregistrer un commentaire