Debian Codegraph @

yo/advancedtemplates/examples/listsearch.h

raw
1 #include "typelist.h"
2
3 //LISTSEARCH
4 template <typename ...Types>
5 struct ListSearch
6 {
7 ListSearch(ListSearch const &) = delete;
8 };
9 //=
10
11 //EMPTY
12 template <typename SearchType>
13 struct ListSearch<SearchType, TypeList<>>
14 {
15 ListSearch(ListSearch const &) = delete;
16 enum { index = -1 };
17 };
18 //=
19
20 //TAIL
21 template <typename SearchType, typename ...Tail>
22 struct ListSearch<SearchType, TypeList<SearchType, Tail...>>
23 {
24 ListSearch(ListSearch const &) = delete;
25 enum { index = 0 };
26 };
27 //=
28
29 //FULL
30 template <typename SearchType, typename Head, typename ...Tail>
31 struct ListSearch<SearchType, TypeList<Head, Tail...> >
32 {
33 ListSearch(ListSearch const &) = delete;
34 enum {tmp = ListSearch<SearchType, TypeList<Tail...>>::index};
35 enum {index = tmp == -1 ? -1 : 1 + tmp};
36 };
37 //=