EntityComponentMetaSystem
An implementation of an EntityComponent System with template meta-programming.
Loading...
Searching...
No Matches
TypeListGet.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_TYPE_LIST_GET_HPP
8#define EC_META_TYPE_LIST_GET_HPP
9
10#include <type_traits>
11
12#include "TypeList.hpp"
13#include "IndexOf.hpp"
14
15namespace EC
16{
17 namespace Meta
18 {
19 template <typename TTypeList, typename TTTypeList, unsigned int Index>
21 {
22 using type = TTypeList;
23 };
24
25 template <
26 typename TTypeList,
27 template <typename...> class TTTypeList,
28 unsigned int Index,
29 typename Type,
30 typename... Rest>
31 struct TypeListGetHelper<TTypeList, TTTypeList<Type, Rest...>, Index>
32 {
33 using type =
34 typename std::conditional<
36 Type,
37 typename TypeListGetHelper<
38 TTypeList, TTTypeList<Rest...>, Index>::type
39 >::type;
40 };
41
42 template <typename TTypeList, unsigned int Index>
43 using TypeListGet =
44 typename TypeListGetHelper<TTypeList, TTypeList, Index>::type;
45 }
46}
47
48#endif
49
Definition IndexOf.hpp:24
Definition TypeListGet.hpp:21