dimanche 21 avril 2019

How to group different static classes?

I have a templated static class with different specialisations, like this:

template<typename Parameter >
class MyClass
{};

 template<>
class MyClass<Parameter1>
{
public:
     static constexpr Integer myarray[]={0};
     static constexpr Integer myarraysize=1;    
 };

  template<>
class MyClass<Parameter2>
{
public:
     static constexpr Integer myarray[]={0,1};
     static constexpr Integer myarraysize=2;    
 };

Now I would like to group somehow these informations in a new class

template<typename MyClass1, typename MyClasses... >
class MyGroupClass{
//do something...}

where I could give as variadic template parameters the different classes and then I could access the different static methods. For example, I would like to to something as MyGroupClass[n]:: myarraysize to access myarraysize related to n-th MyClass. I imagine I could create a tuple (so having std::get()), but it is not very clear to me how to do this, since I have no constructors for such single static classes. After all, the classes are static.

Is it possible to achieve what I want? If so, could you please enlighten me? Thank you.

Aucun commentaire:

Enregistrer un commentaire