EntityComponentMetaSystem
An implementation of an EntityComponent System with template meta-programming.
Loading...
Searching...
No Matches
ForEachDoubleTuple.hpp
1
2// This work derives from Vittorio Romeo's code used for cppcon 2015 licensed
3// under the Academic Free License.
4// His code is available here: https://github.com/SuperV1234/cppcon2015
5
6
7#ifndef EC_META_FOR_EACH_DOUBLE_TUPLE_HPP
8#define EC_META_FOR_EACH_DOUBLE_TUPLE_HPP
9
10#include <tuple>
11#include <utility>
12#include "Morph.hpp"
13
14namespace EC
15{
16 namespace Meta
17 {
18 template <typename Function, typename TupleFirst,
19 typename TupleSecond, std::size_t... Indices>
20 constexpr void forEachDoubleTupleHelper(
21 Function&& function, TupleFirst t0, TupleSecond t1,
22 std::index_sequence<Indices...>)
23 {
24 return (void)std::initializer_list<int>{(function(
25 std::get<Indices>(t0), std::get<Indices>(t1), Indices), 0)...};
26 }
27
28 template <typename TupleFirst, typename TupleSecond, typename Function>
29 constexpr void forEachDoubleTuple(
30 TupleFirst&& t0, TupleSecond&& t1, Function&& function)
31 {
32 using TTupleSize = std::tuple_size<TupleFirst>;
33 using IndexSeq = std::make_index_sequence<TTupleSize::value>;
34
35 return forEachDoubleTupleHelper(
36 std::forward<Function>(function),
37 std::forward<TupleFirst>(t0),
38 std::forward<TupleSecond>(t1),
39 IndexSeq{});
40 }
41 }
42}
43
44#endif
45