EntityComponentMetaSystem
An implementation of an EntityComponent System with template meta-programming.
Loading...
Searching...
No Matches
Matching.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_MATCHING_HPP
8#define EC_META_MATCHING_HPP
9
10#include "TypeList.hpp"
11#include "Contains.hpp"
12
13namespace EC
14{
15 namespace Meta
16 {
17 template <typename TTypeListA, typename TTypeListB>
19 {
20 using type = TypeList<>;
21 };
22
23 template <typename TTypeListA, typename TTypeListB,
24 typename... Matching>
26 {
27 };
28
29 template <typename TTypeListA, typename TTypeListB,
30 typename... Matching>
32 TTypeListA, TTypeListB, TypeList<Matching...> >
33 {
34 using type = TypeList<Matching...>;
35 };
36
37 template <
38 template <typename...> class TTypeListA,
39 typename TTypeListB,
40 typename Type,
41 typename... Types,
42 typename... Matching>
44 TTypeListA<Type, Types...>,
45 TTypeListB,
46 TypeList<Matching...> > :
47 std::conditional<
48 Contains<Type, TTypeListB>::value,
49 MatchingHelperHelper<
50 TTypeListA<Types...>,
51 TTypeListB,
52 TypeList<Matching..., Type> >,
53 MatchingHelperHelper<
54 TTypeListA<Types...>,
55 TTypeListB,
56 TypeList<Matching...> >
57 >::type
58 {
59 };
60
61 template <
62 template <typename...> class TTypeListA,
63 typename TTypeListB,
64 typename Type,
65 typename... Types>
66 struct MatchingHelper<TTypeListA<Type, Types...>, TTypeListB> :
67 std::conditional<
68 Contains<Type, TTypeListB>::value,
69 MatchingHelperHelper<
70 TTypeListA<Types...>, TTypeListB, TypeList<Type> >,
71 MatchingHelper<TTypeListA<Types...>, TTypeListB>
72 >::type
73 {
74 };
75
76 template <typename TTypeListA, typename TTypeListB>
78 }
79}
80
81#endif
82
Definition Matching.hpp:26
Definition Matching.hpp:19
Definition TypeList.hpp:16