lundi 7 décembre 2015

Unpack tuple types to create array

I have following code

template <typename... Types>
struct structure1 {
   typedef std::tuple<Types...> tou;
   std::array<int, 2> get();
};
template<typaname Type0>
int fun();
template<typaname Type1, typename Type2>
struct structure2 {
  std::array<int, 2> ar1 = Type1::get();
  std::array<int, 2> ar2 = Type2::get();
  std::array<int, 2> get(){
  //something here
  }
};

I it would be called like structure2< structure1<int, double>, structure1<int, int> >::get() I want to implement get() so that it returns array of values based on types in each of structures1 (for type "W" I would call fun<W>()) and on ar1, ar2. To access to ...Types I created tuple tou. But how can I interate on tuple and arrays ar1, ar2 on the same time? How to get i-th type of ...Types in tuple?

Aucun commentaire:

Enregistrer un commentaire