mardi 3 septembre 2019

Is there any way to strip a tuple of pairs to variadic template types or instantiat something with variadic types?

I have a tuple of pairs in which, each pair has a fixed type and a variant type. What I want is a list of the variant types or defining an object (which definitely constructs with a variadic template pack) with these types.

According to How do I strip a tuple<> back into a variadic template list of types?, it is possible to instantiate something with constituent types of the tuple. But in this case, I don't know whether it is even possible and if possible, how to do it.

Imagine I have something like this

struct MyFixedType
{ ... };


std::tuple<std::pair<MyFixedType, int> std::pair<MyFixedType, double>, std::pair<MyFixedType, std::string>>

And I have this class:

template <typename Ts...>
class MyClass
{
};

What I want is to declare an object of MyClass with <int, double, std::string>

Note: Although this case can be handled using a pre-processor or some MACROs but I'm not allowed to use MACROs

Aucun commentaire:

Enregistrer un commentaire