mardi 4 octobre 2016

C++ - inherting std::tuple from something adding virtual functions to it

First is it possible to inherit a std::tuple from something?

I have a

std::tuple<A, B> // (common base event data)

std::tuple<C, D, E> someObj;

So if I construct the second tuple, the first base class (or something like that) should also be involved.

Secondly, and I suppose more importantly, at runtime I want to choose the correct virtual function based on my type.

So for example if

std::tuple<A,B> { virtual void Serialize(); }

I'd like to be able to special the child class's Specialize method but using templates so it can be expanded at compile-time but I can choose the method at runtime.

I'm thinking of different to structure the problem in code so that I can achieve this, but if not I'll have to resort to hand-written boilerplate code for each tuple.

Aucun commentaire:

Enregistrer un commentaire