Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
typelist-util.hpp
Go to the documentation of this file.
1/*
2 TYPELIST-UTIL.hpp - simple helpers for working with lists-of-types
3
4 Copyright (C)
5 2008, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
14
36#ifndef LIB_META_TYPELIST_UTIL_H
37#define LIB_META_TYPELIST_UTIL_H
38
39
40
41#include "lib/meta/typelist.hpp"
42#include "lib/meta/util.hpp"
43
44#include <algorithm>
45
46namespace lib {
47namespace meta {
48
49
56 template<class... TYPES>
57 struct count;
58 template<>
59 struct count<Nil>
60 : SizConst<0>
61 { };
62 template<class TY, class TYPES>
63 struct count<Node<TY,TYPES>>
64 : SizConst<1 + count<TYPES>()>
65 { };
66
67
71 template<class TYPES>
72 struct maxSize;
73 template<>
74 struct maxSize<Nil>
75 : SizConst<0>
76 { };
77 template<class TY, class TYPES>
79 : SizConst<std::max (sizeof(TY), maxSize<TYPES>::value)>
80 { };
81
82
86 template<class TYPES>
87 struct maxAlign;
88 template<>
89 struct maxAlign<Nil>
90 : SizConst<0>
91 { };
92 template<class TY, class TYPES>
94 : SizConst<std::max (alignof(TY), maxAlign<TYPES>::value)>
95 { };
96
97
102 template<typename TY, typename TYPES>
103 struct isInList
104 : std::false_type
105 { };
106
107 template<typename TY, typename TYPES>
109 : std::true_type
110 { };
111
112 template<typename TY, typename XX, typename TYPES>
113 struct isInList<TY, Node<XX,TYPES>>
114 : std::bool_constant<isInList<TY,TYPES>::value>
115 { };
116
117
118
122 template<typename TYPES>
123 struct ConstAll;
124
125 template<>
126 struct ConstAll<Nil>
127 {
128 using List = Nil;
129 };
130
131 template<typename TY, typename TYPES>
136
137
138
139}} // namespace lib::meta
140#endif
Simple and lightweight helpers for metaprogramming and type detection.
enable_if_c< Cond::value, T >::type enable_if
SFINAE helper to control the visibility of specialisations and overloads.
Definition meta/util.hpp:87
Node< std::add_const_t< TY >, typename ConstAll< TYPES >::List > List
std::integral_constant< size_t, siz > SizConst
Definition meta/util.hpp:56
Build a list of const types from a given typelist.
»Empty« mark
Definition typelist.hpp:82
Type list with head and tail; T ≡ Nil marks list end.
Definition typelist.hpp:90
Metafunction " max( alignof(T) ) for T in TYPES ".
Metafunction " max( sizeof(T) ) for T in TYPES ".
Implementation namespace for support and library code.
Metafunction counting the number of Types in the collection.
Metafunction to check if a specific type is contained in a given typelist.
A template metaprogramming technique for manipulating collections of types.