lundi 1 octobre 2018

accessing all elements of std::tuple created using variadic template [duplicate]

This question already has an answer here:

Let say we have a variadic templated class

template <typename... Ts>
class Foo {
  public:
    void process_x(){
       //some code goes here
    }
  private:
    std::tuple<Ts...> x;
}

Is there a way for me to access all the elements of x through member function process_x() in order to invoke the same function foo() in the templated classes? For example if I have instantiated the Foo class with 3 parameters in its template (Foo<someclassA, someclassB, someclassC>) is there a way to access every single element of x and invoke the same foo() function in each of the elements? (i.e., in the case of the above example to do std::get<0>(x).foo(), std::get<1>(x).foo(), std::get<2>(x).foo() )

Aucun commentaire:

Enregistrer un commentaire