L4Re Operating System Framework – Interface and Usage Documentation
Loading...
Searching...
No Matches
type_list
1// vi:set ft=cpp: -*- Mode: C++ -*-
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
25namespace cxx {
26
27template< typename ...T >
28struct type_list;
29
30template<>
31struct type_list<>
32{
33 typedef false_type head;
34 typedef false_type tail;
35};
36
37template<typename HEAD, typename ...TAIL>
38struct type_list<HEAD, TAIL...>
39{
40 typedef HEAD head;
41 typedef type_list<TAIL...> tail;
42};
43
44template<typename TYPELIST, template <typename T> class PREDICATE>
45struct find_type;
46
47template<template <typename T> class PREDICATE>
48struct find_type<type_list<>, PREDICATE>
49{
50 typedef false_type type;
51};
52
53template<typename TYPELIST, template <typename T> class PREDICATE>
54struct 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
61template<typename TYPELIST, template <typename T> class PREDICATE>
62using find_type_t = typename find_type<TYPELIST, PREDICATE>::type;
63
64}
65
Our C++ library.
Definition arith:22