Interface Documentation
Version: invalid
tuple_walker.hh
Go to the documentation of this file.
1 /*
2  @@@@@@@@ @@ @@@@@@ @@@@@@@@ @@
3  /@@///// /@@ @@////@@ @@////// /@@
4  /@@ /@@ @@@@@ @@ // /@@ /@@
5  /@@@@@@@ /@@ @@///@@/@@ /@@@@@@@@@/@@
6  /@@//// /@@/@@@@@@@/@@ ////////@@/@@
7  /@@ /@@/@@//// //@@ @@ /@@/@@
8  /@@ @@@//@@@@@@ //@@@@@@ @@@@@@@@ /@@
9  // /// ////// ////// //////// //
10 
11  Copyright (c) 2016, Triad National Security, LLC
12  All rights reserved.
13  */
14 #pragma once
15 
18 #include <tuple>
19 
20 namespace flecsi {
21 namespace util {
22 
33 template<typename CRTP_TYPE>
34 struct tuple_walker {
35 private:
36  template<typename T>
37  void dispatch(T & t) {
38  static_cast<CRTP_TYPE &>(*this).visit(t);
39  }
40 
41  template<typename T>
42  void dispatch() {
43  static_cast<CRTP_TYPE &>(*this).template visit_type<T>();
44  }
45 
46  template<std::size_t index = 0, typename TUPLE_TYPE>
47  void walk_impl(TUPLE_TYPE & t) {
48  if constexpr(index < std::tuple_size<TUPLE_TYPE>::value) {
49  dispatch(std::get<index>(t));
50  walk_impl<index + 1>(t);
51  }
52  }
53 
54  template<std::size_t index = 0, typename TUPLE_TYPE>
55  void walk_types_impl() {
56  if constexpr(index < std::tuple_size<TUPLE_TYPE>::value) {
58  dispatch<type>();
59  walk_types_impl<index + 1, TUPLE_TYPE>();
60  }
61  }
62 
63 public:
74  template<typename TUPLE_TYPE>
75  void walk(TUPLE_TYPE & t) {
76  walk_impl(t);
77  }
78 
87  template<typename TUPLE_TYPE>
88  void walk_types() {
89  walk_types_impl<0, TUPLE_TYPE>();
90  }
91 }; // struct tuple_walker
92 
93 } // namespace util
94 } // namespace flecsi
void walk_types()
Definition: tuple_walker.hh:88
std::string type()
Definition: demangle.hh:44
void walk(TUPLE_TYPE &t)
Definition: tuple_walker.hh:75
Definition: tuple_walker.hh:34
Definition: control.hh:31