OSSIA
Open Scenario System for Interactive Application
mpl.hpp
1 #pragma once
2 #include <ossia/detail/config.hpp>
3 
4 #include <ossia/detail/for_each.hpp>
5 
6 #include <brigand/algorithms/for_each.hpp>
7 #include <brigand/algorithms/transform.hpp>
8 #include <brigand/sequences/make_sequence.hpp>
9 
10 #include <list>
11 #include <tuple>
12 #include <utility>
13 #include <vector>
14 
15 namespace ossia
16 {
17 template <
18  template <typename...> typename Sequence, template <typename...> typename Tuple,
19  typename... Args>
20 auto list_of_tuple_to_tuple_of_list(const Sequence<Tuple<Args...>>& lst)
21 {
22  namespace bg = brigand;
23 
24  // res_type = Tuple<Sequence<Arg1>, Sequence<Arg2>, ...>
25  using res_type = bg::transform<Tuple<Args...>, bg::bind<Sequence, bg::_1>>;
26 
27  // list of integers over which we iterate
28  using index_list = bg::make_sequence<bg::size_t<0>, sizeof...(Args)>;
29 
30  res_type res;
31  // TODO reserve sizeof...(Args)
32 
33  // copy our data
34  for(const auto& tuple : lst)
35  {
36  bg::for_each<index_list>([&](auto t) {
37  constexpr auto N = decltype(t)::type::value;
38  std::get<N>(res).push_back(std::get<N>(tuple));
39  });
40  }
41  return res;
42 }
43 }
Definition: git_info.h:7