Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
typelist-manip.hpp
Go to the documentation of this file.
1/*
2 TYPELIST-MANIP.hpp - Utils 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
50#ifndef LIB_META_TYPELIST_MANIP_H
51#define LIB_META_TYPELIST_MANIP_H
52
53
54
55#include "lib/meta/typelist.hpp"
56
57#include <sys/types.h>
58
59namespace lib {
60namespace meta {
61
62
64 template<class TYPES, size_t i>
65 struct Pick
66 {
67 using Type = Nil;
68 };
69 template<class TY, class TYPES>
70 struct Pick<Node<TY,TYPES>, 0>
71 {
72 using Type = TY;
73 };
74 template<class TY, class TYPES, size_t i>
75 struct Pick<Node<TY,TYPES>, i>
76 {
77 using Type = Pick<TYPES, i-1>::Type;
78 };
79
80
81
82
84 template<class TY, template<class> class _TRANS_>
85 struct Apply { using List = TY; };
86
87 template< class TY, class TYPES
88 , template<class> class _TRANS_
89 >
92 >;};
93
94
96 template<bool, class T, class TAIL>
97 struct CondNode { using Next = TAIL; };
98
99 template<class T, class TAIL>
100 struct CondNode<true, T, TAIL> { using Next = Node<T,TAIL>; };
101
103 template< class TYPES
104 , template<class> class _P_
105 >
106 struct Filter;
107
108 template<template<class> class _P_>
109 struct Filter<Nil,_P_> { using List = Nil; };
110
111 template< class TY, class TYPES
112 , template<class> class _P_
113 >
115 , TY
116 , typename Filter<TYPES,_P_>::List
117 >::Next
118 ; };
119
120
122 template<class TY1, class TY2>
124
125 template< class TY, class TYPES
126 , class TAIL
127 >
129
130 template<class TY, class TYPES>
131 struct Append<Nil, Node<TY,TYPES>> { using List = Node<TY,TYPES>; };
132
133 template<class TY, class TYPES>
134 struct Append<Node<TY,TYPES>, Nil> { using List = Node<TY,TYPES>; };
135
136 template<class TY1>
137 struct Append<TY1,Nil> { using List = Node<TY1,Nil>; };
138
139 template<class TY2>
140 struct Append<Nil,TY2> { using List = Node<TY2,Nil>; };
141
142 template<>
143 struct Append<Nil,Nil> { using List = Nil; };
144
145
146
147
149 template<class TYPES>
150 struct PickLast;
151
152 template<>
153 struct PickLast<Nil> { using Type = Nil;
154 using List = Nil; };
155 template<class TY>
156 struct PickLast<Node<TY,Nil>> { using Type = TY;
157 using List = Nil; };
158
159 template<class TY, class TYPES>
161 using List = Append< TY
162 , typename PickLast<TYPES>::List
163 >::List
164 ; };
165
166
167
178 template<class BASE, class OVERLAY, uint i=0>
179 struct Splice;
180
181 template<class B, class BS,
182 class OVERLAY,
183 uint i>
184 struct Splice<Node<B,BS>, OVERLAY, i> { using List = Node<B, typename Splice<BS, OVERLAY, i-1>::List>;
185 using Front = Node<B, typename Splice<BS, OVERLAY, i-1>::Front>;
186 using Back = typename Splice<BS, OVERLAY, i-1>::Back; };
187
188 template<class B, class BS,
189 class O, class OS >
191 using Front = Nil;
192 using Back = typename Splice<BS,OS, 0>::Back; };
193
194 template<class B, class BS>
195 struct Splice<Node<B,BS>, Nil, 0> { using List = Node<B, BS>;
196 using Front = Nil;
197 using Back = Node<B, BS>; };
198
199 template<class XX, uint i>
200 struct Splice<Nil, XX, i> { using List = Nil;
201 using Front = Nil;
202 using Back = Nil; };
203
205 template<class LI, uint l>
207
209 template<class LI, uint p>
211
212
213
214
219 template<class TYPES>
220 struct Dissect;
221
222 template<class T, class TYPES>
233
234 template<>
235 struct Dissect<Nil>
236 {
237 using List = Nil;
238 using Head = Nil;
239 using First = Nil;
240 using Tail = Nil;
241 using Prefix = Nil;
242 using End = Nil;
243 using Last = Nil;
244 };
245
246
247
248
253 template<class T, class TY>
255
256 template<class T>
257 struct PrefixAll<T, Nil> { using List = Nil; };
258
259 template<class T>
261
262 template< class T
263 , class TY, class TYPES
264 >
266 , typename PrefixAll<T,TYPES>::List
267 >;};
268
269
270
271
278 template<class TY1,class TY2>
280
281 template<class TY>
282 struct Distribute<Nil,TY> { using List = Nil; };
283
284 template< class TY, class TYPES
285 , class TAIL
286 >
289 >::List
290 ; };
291
292
293
307 template< class X
308 , template<class> class _ENUM_>
310 , NilNode
311 >::List; };
312 template< template<class> class _ENUM_>
313 struct Combine<Nil, _ENUM_ > { using List = NilNode; };
314
315 template< class TY, class TYPES
316 , template<class> class _ENUM_>
319 >::List; };
320
325 template<class F>
327 {
329 };
330
331
334 template<class FLAGS>
339
340
341
342
343}} // namespace lib::meta
344#endif
unsigned int uint
Definition integral.hpp:29
Append< TY, typename PickLast< TYPES >::List >::List List
Distribute< typename _ENUM_< X >::List, NilNode >::List List
Node< O, typename Splice< BS, OS, 0 >::List > List
Node< End, Nil > Last
a list containing the last element
Node< typename _TRANS_< TY >::Type, typename Apply< TYPES, _TRANS_ >::List > List
PickLast< List >::List Prefix
all of the list, up to but excluding the last element
CondNode< _P_< TY >::value, TY, typename Filter< TYPES, _P_ >::List >::Next List
Node< B, typename Splice< BS, OVERLAY, i-1 >::List > List
Node< T, Nil > First
a list containing the first element
PrefixAll< TY1, TY2 >::List List
Splice< LI, Nil, l >::Front Prefix
extract prefix of given length
enable_if_c< Cond::value, T >::type enable_if
SFINAE helper to control the visibility of specialisations and overloads.
Definition meta/util.hpp:87
Append< typename PrefixAll< TY, TAIL >::List, typename Distribute< TYPES, TAIL >::List >::List List
Node< Nil, Nil > NilNode
Definition typelist.hpp:96
Node< typename Append< T, TY >::List, Nil > List
TYPES Tail
remainder of the list starting with the second elm.
Node< typename Append< T, NilNode >::List, Nil > List
Node< TY1, typename Append< TY2, Nil >::List > List
PickLast< List >::Type End
the last element
typename Splice< BS, OVERLAY, i-1 >::Back Back
Combine< FLAGS, FlagOnOff >::List List
Node< TY, typename Append< TYPES, TAIL >::List > List
Distribute< typename _ENUM_< TY >::List, typename Combine< TYPES, _ENUM_ >::List >::List List
Node< T, TYPES > List
the complete list
Splice< LI, Nil, p >::Back Suffix
extract suffix starting at given pos
Node< F, NilNode > List
Node< typename Append< T, TY >::List, typename PrefixAll< T, TYPES >::List > List
Node< B, typename Splice< BS, OVERLAY, i-1 >::Front > Front
append (concatenate) lists-of-types
apply a transformation (template) to each type in the list
Build all possible combinations, based on a enumeration of the basic cases.
generate all possible on-off combinations of the given flags.
conditional node: skip an element based on evaluating a predicate
Allows to access various parts of a given typelist: Start and End, Prefix and Tail....
build a list-of lists, where each element of the first arg list gets in turn prepended to all element...
filter away those types which don't fulfil a predicate metafunction
enumeration generator for the Combine metafunction, yielding an "on" and "off" case; the latter is re...
»Empty« mark
Definition typelist.hpp:82
Type list with head and tail; T ≡ Nil marks list end.
Definition typelist.hpp:90
pick the n-th element from a typelist
access the last list element
prefix each of the elements, yielding a list-of lists-of-types
splice some typelist like an overlay into a base typelist, starting at given index.
Implementation namespace for support and library code.
A template metaprogramming technique for manipulating collections of types.