Template tuple - calling a function on each element

后端 未结 7 2065
猫巷女王i
猫巷女王i 2020-11-27 02:28

My question is in the code:

template
struct TupleOfVectors {
  std::tuple...> tuple;

  void do_something_t         


        
相关标签:
7条回答
  • 2020-11-27 03:32

    Boost mp11 has this functionality:

    #include <iostream>
    #include <string>
    #include <boost/mp11.hpp>
    
    using namespace std;
    using boost::mp11::tuple_for_each;
    
    std::tuple t{string("abc"), 47 };
    
    int main(){
        tuple_for_each(t,[](const auto& x){
            cout << x + x << endl;
        });
    }
    
    0 讨论(0)
提交回复
热议问题