Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:51

0001 #ifndef GENERS_COLLECTTUPLENAMES_HH_
0002 #define GENERS_COLLECTTUPLENAMES_HH_
0003 
0004 #include <cassert>
0005 #include <string>
0006 #include <utility>
0007 #include <vector>
0008 
0009 namespace gs {
0010     namespace Private 
0011     {
0012         template<typename Tuple, int N>
0013         struct TupleNameCycler
0014         {
0015             inline static void collect(const Tuple& t,
0016                                        std::vector<std::string>* n)
0017             {
0018                 TupleNameCycler<Tuple, N-1>::collect(t, n);
0019                 n->push_back((std::get<N-1>(t)).name());
0020             }
0021         };
0022 
0023         template<typename Tuple>
0024         struct TupleNameCycler<Tuple, 0>
0025         {
0026             inline static void collect(const Tuple&,
0027                                        std::vector<std::string>* s)
0028                 {assert(s); s->clear();}
0029         };
0030     }
0031 
0032     template<typename Pack>
0033     std::vector<std::string> collectTupleNames(const Pack& pack)
0034     {
0035         std::vector<std::string> v;
0036         Private::TupleNameCycler<Pack,std::tuple_size<Pack>::value>::collect(
0037             pack, &v);
0038         return v;
0039     }
0040 }
0041 
0042 #endif // GENERS_COLLECTTUPLENAMES_HH_
0043