vendredi 29 juillet 2016

Replacing a type within a tuple in C++11

I'm trying to use templates in C++ 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 every elements of t1 is copied into t2 at the same position, except for elements of type A, for which t2 should create an object of type B (the constructor of B takes a reference to an object of type A).

Example: from the std::tuple containing 42, a1, 3.3, a3 (where a1 and a3 are instances of A) I want to build the std::tuple containing 42, b1, 3.3, b3 where b1 has been built from a1 and b3 from a3.

How can I do that? Thanks

Aucun commentaire:

Enregistrer un commentaire