EntityComponentMetaSystem
An implementation of an EntityComponent System with template meta-programming.
Loading...
Searching...
No Matches
IndexOf.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/*
8 Returns the index of a type in a type list.
9 If the type does not exist in the type list,
10 returns the size of the type list.
11*/
12
13#ifndef EC_META_INDEX_OF_HPP
14#define EC_META_INDEX_OF_HPP
15
16#include "TypeList.hpp"
17
18namespace EC
19{
20 namespace Meta
21 {
22 template <typename T, typename... Types>
23 struct IndexOf : std::integral_constant<std::size_t, 0>
24 {
25 };
26
27 template <
28 typename T,
29 template <typename...> class TTypeList,
30 typename... Types>
31 struct IndexOf<T, TTypeList<T, Types...> > :
32 std::integral_constant<std::size_t, 0>
33 {
34 };
35
36 template <
37 typename T,
38 template <typename...> class TTypeList,
39 typename Type,
40 typename... Types>
41 struct IndexOf<T, TTypeList<Type, Types...> > :
42 std::integral_constant<std::size_t, 1 +
43 IndexOf<T, TTypeList<Types...> >::value
44 >
45 {
46 };
47 }
48}
49
50#endif
51
Definition IndexOf.hpp:24