I am trying to use C ++ templates to do the following:
I have a function like this:
template<typename... Args>
void f1(const std::tuple<Args...>& t1);
Inside this function, I would like to create another tuple t2 such that all elements of t1 will be copied to t2 at the same position, except for elements of type A, for which t2 must create an object of type B.
However, the constructor Brefers to the type object as Awell as the second type argument C&. An instance Cis created before the conversion and should be passed as a second argument to the constructor Bwhen an object of type is encountered A.
Something like this, only fully generalized:
std::tuple<int, B, double, B> Convert(std::tuple<int, A, double, A> tpl, C& c)
{
return std::tuple<int, B, double, B>(
std::get<0>(tpl),
B(std::get<1>(tpl), c),
std::get<2>(tpl),
B(std::get<3>(tpl), c),
);
}