]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/cxx/lib/tl/include/type_list
Update
[l4.git] / l4 / pkg / l4re-core / cxx / lib / tl / include / type_list
1 // vi:ft=cpp
2 #pragma once
3
4 /*
5  * (c) 2012 Alexander Warg <warg@os.inf.tu-dresden.de>,
6  *     economic rights: Technische Universität Dresden (Germany)
7  *
8  * This file is part of TUD:OS and distributed under the terms of the
9  * GNU General Public License 2.
10  * Please see the COPYING-GPL-2 file for details.
11  *
12  * As a special exception, you may use this file as part of a free software
13  * library without restriction.  Specifically, if other files instantiate
14  * templates or use macros or inline functions from this file, or you compile
15  * this file and link it with other files to produce an executable, this
16  * file does not by itself cause the resulting executable to be covered by
17  * the GNU General Public License.  This exception does not however
18  * invalidate any other reasons why the executable file might be covered by
19  * the GNU General Public License.
20  */
21
22
23 #include "type_traits"
24
25 namespace cxx {
26
27 template< typename ...T >
28 struct type_list;
29
30 template<>
31 struct type_list<>
32 {
33   typedef false_type head;
34   typedef false_type tail;
35 };
36
37 template<typename HEAD, typename ...TAIL>
38 struct type_list<HEAD, TAIL...>
39 {
40   typedef HEAD head;
41   typedef type_list<TAIL...> tail;
42 };
43
44 template<typename TYPELIST, template <typename T> class PREDICATE>
45 struct find_type;
46
47 template<template <typename T> class PREDICATE>
48 struct find_type<type_list<>, PREDICATE>
49 {
50   typedef false_type type;
51 };
52
53 template<typename TYPELIST, template <typename T> class PREDICATE>
54 struct find_type
55 {
56   typedef typename conditional<PREDICATE<typename TYPELIST::head>::value,
57                                typename TYPELIST::head,
58                                typename find_type<typename TYPELIST::tail, PREDICATE>::type>::type type;
59 };
60
61 }
62