Claw  1.7.3
type_list.hpp
Go to the documentation of this file.
1 /*
2  CLAW - a C++ Library Absolutely Wonderful
3 
4  CLAW is a free library without any particular aim but being useful to
5  anyone.
6 
7  Copyright (C) 2005-2011 Julien Jorge
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 
23  contact: julien.jorge@gamned.org
24 */
30 #ifndef __CLAW_TYPE_LIST_HPP__
31 #define __CLAW_TYPE_LIST_HPP__
32 
34 #include <claw/meta/no_type.hpp>
35 #include <claw/meta/same_type.hpp>
36 
37 namespace claw
38 {
39  namespace meta
40  {
58  template<typename Head, typename Queue>
59  struct type_list
60  {
62  typedef Head head_type;
63 
65  typedef Queue queue_type;
66 
67  }; // struct type_list
68 
76  template<typename Delimiter, typename TypeList>
78 
81  template<typename Delimiter>
82  struct split_type_list_at<Delimiter, no_type>
83  {
86 
89 
90  }; // struct split_type_list_at
91 
99  template<typename Delimiter, typename TypeList>
100  struct split_type_list_at
101  {
103  typedef typename if_then_else
105  no_type, /* delimiter is found, mark the end of the list. */
106  type_list /* otherwise, cut in the remaining types. */
107  < typename TypeList::head_type,
108  typename split_type_list_at
109  <Delimiter, typename TypeList::queue_type>::left_part_type > >::result
111 
113  typedef typename if_then_else
115  TypeList, /* delimiter is found, this is the right part. */
116  typename split_type_list_at
117  <Delimiter, typename TypeList::queue_type>::right_part_type >::result
119 
120  }; // struct split_type_list_at
121 
126  template<typename T1>
128  {
131  }; // struct type_list_maker_1
132 
137  template<typename T1, typename T2>
139  {
142  }; // struct type_list_maker_2
143 
148  template<typename T1, typename T2, typename T3>
150  {
152  typedef
154  }; // struct type_list_maker_3
155 
160  template<typename T1, typename T2, typename T3, typename T4>
162  {
164  typedef
166  }; // struct type_list_maker_4
167 
172  template<typename T1, typename T2, typename T3, typename T4, typename T5>
174  {
176  typedef type_list
177  < T1,
179  }; // struct type_list_maker_5
180 
185  template<typename T1, typename T2, typename T3, typename T4, typename T5,
186  typename T6>
188  {
190  typedef type_list
191  < T1,
193  }; // struct type_list_maker_6
194 
199  template<typename T1, typename T2, typename T3, typename T4, typename T5,
200  typename T6, typename T7>
202  {
204  typedef type_list
205  < T1,
207  }; // struct type_list_maker_7
208 
213  template<typename T1, typename T2, typename T3, typename T4, typename T5,
214  typename T6, typename T7, typename T8>
216  {
218  typedef type_list
219  < T1,
221  }; // struct type_list_maker_8
222 
227  template<typename T1, typename T2, typename T3, typename T4, typename T5,
228  typename T6, typename T7, typename T8, typename T9>
230  {
232  typedef type_list
233  < T1,
234  typename type_list_maker_8
235  <T2, T3, T4, T5, T6, T7, T8, T9>::result
237  }; // struct type_list_maker_9
238 
243  template<typename T1, typename T2, typename T3, typename T4, typename T5,
244  typename T6, typename T7, typename T8, typename T9, typename T10>
246  {
248  typedef type_list
249  < T1,
250  typename type_list_maker_9
251  <T2, T3, T4, T5, T6, T7, T8, T9, T10>::result
253  }; // struct type_list_maker_10
254 
259  template<typename T1, typename T2, typename T3, typename T4, typename T5,
260  typename T6, typename T7, typename T8, typename T9, typename T10,
261  typename T11>
263  {
265  typedef type_list
266  < T1,
267  typename type_list_maker_10
268  <T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>::result
270  }; // struct type_list_maker_11
271 
276  template<typename T1, typename T2, typename T3, typename T4, typename T5,
277  typename T6, typename T7, typename T8, typename T9, typename T10,
278  typename T11, typename T12>
280  {
282  typedef type_list
283  < T1,
284  typename type_list_maker_11
285  <T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>::result
287  }; // struct type_list_maker_12
288 
293  template<typename T1, typename T2, typename T3, typename T4, typename T5,
294  typename T6, typename T7, typename T8, typename T9, typename T10,
295  typename T11, typename T12, typename T13>
297  {
299  typedef type_list
300  < T1,
301  typename type_list_maker_12
302  <T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>::result
304  }; // struct type_list_maker_13
305 
310  template<typename T1, typename T2, typename T3, typename T4, typename T5,
311  typename T6, typename T7, typename T8, typename T9, typename T10,
312  typename T11, typename T12, typename T13, typename T14>
314  {
316  typedef type_list
317  < T1,
318  typename type_list_maker_13
319  <T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>::result
321  }; // struct type_list_maker_14
322 
327  template<typename T1, typename T2, typename T3, typename T4, typename T5,
328  typename T6, typename T7, typename T8, typename T9, typename T10,
329  typename T11, typename T12, typename T13, typename T14,
330  typename T15>
332  {
334  typedef type_list
335  < T1,
336  typename type_list_maker_14
337  <T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>::result
339  }; // struct type_list_maker_15
340 
346  template< typename T1, typename T2 = no_type, typename T3 = no_type,
347  typename T4 = no_type, typename T5 = no_type,
348  typename T6 = no_type, typename T7 = no_type,
349  typename T8 = no_type, typename T9 = no_type,
350  typename T10 = no_type, typename T11 = no_type,
351  typename T12 = no_type, typename T13 = no_type,
352  typename T14 = no_type, typename T15 = no_type >
354  {
356  typedef typename split_type_list_at
357  < no_type,
358  typename type_list_maker_15
359  < T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
360  T15 >::result
361  >::left_part_type result;
362  }; // struct type_list_maker
363 
376  template<typename T, typename List>
378  {
379  enum
380  {
383  };
384  }; // struct type_list_find
385 
386  template<typename T>
388  {
389  enum
390  {
392  };
393  }; // struct type_list_find
394 
401  template<typename List>
403  {
404  enum
405  {
406  result = !type_list_find<typename List::head_type,
407  typename List::queue_type>::result
409  };
410  }; // struct type_list_is_a_set
411 
412  template<>
414  {
415  enum
416  {
417  result = true
418  };
419  }; // struct type_list_is_a_set [no_type]
420 
426  template<typename List>
428  {
429  enum
430  {
432  };
433  }; // struct type_list_length
434 
435  template<>
437  {
438  enum
439  {
440  result = 0
441  };
442  }; // struct type_list_length [no_type]
443 
451  template<typename T, typename List>
453 
454  template<typename T, typename Tail>
455  struct type_list_contains< T, type_list<T, Tail> >
456  {
457  enum
458  {
459  result = true
460  };
461  }; // struct type_list_contains
462 
463  template<typename T>
465  {
466  enum
467  {
468  result = false
469  };
470  }; // struct type_list_contains
471 
472  template<typename T, typename Head, typename Tail>
473  struct type_list_contains< T, type_list<Head, Tail> >
474  {
475  enum
476  {
478  };
479  }; // struct type_list_contains
480 
482  typedef type_list_maker
483  < signed char, unsigned char,
484  signed short, unsigned short,
485  signed int, unsigned int,
486  signed long, unsigned long,
487 #ifndef __STRICT_ANSI__
488  signed long long, unsigned long long,
489 #endif
490  float,
491  double,
492  long double,
493  bool >::result cpp_type_list;
494 
495  } // namespace meta
496 } // namespace claw
497 
498 #endif // __CLAW_TYPE_LIST_HPP__
claw::meta::type_list_maker_2::result
type_list< T1, typename type_list_maker_1< T2 >::result > result
The list described by this implementation.
Definition: type_list.hpp:141
claw::meta::type_list_contains
Tell if a given type list contains a given type.
Definition: type_list.hpp:452
claw::meta::type_list_maker_5::result
type_list< T1, typename type_list_maker_4< T2, T3, T4, T5 >::result > result
The list described by this implementation.
Definition: type_list.hpp:178
claw::meta::type_list_maker_15::result
type_list< T1, typename type_list_maker_14< T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 >::result > result
The list described by this implementation.
Definition: type_list.hpp:338
claw::meta::split_type_list_at::right_part_type
if_then_else< same_type< Delimiter, typename TypeList::head_type >::result, TypeList, typename split_type_list_at< Delimiter, typename TypeList::queue_type >::right_part_type >::result right_part_type
The right part of the list. The delimiter is included.
Definition: type_list.hpp:118
claw::meta::split_type_list_at::left_part_type
if_then_else< same_type< Delimiter, typename TypeList::head_type >::result, no_type, type_list< typename TypeList::head_type, typename split_type_list_at< Delimiter, typename TypeList::queue_type >::left_part_type > >::result left_part_type
The left part of the list. The delimiter is not included.
Definition: type_list.hpp:110
claw::meta::type_list_maker_4
A type list with four types, more readable than an imbricated type_list.
Definition: type_list.hpp:161
conditional.hpp
Structures for meta-programming.
claw::meta::split_type_list_at
Split a type_list according to the first instance of a given type.
Definition: type_list.hpp:77
claw::meta::type_list_maker_11::result
type_list< T1, typename type_list_maker_10< T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 >::result > result
The list described by this implementation.
Definition: type_list.hpp:269
claw::meta::type_list
Use this class to make a list of types.
Definition: type_list.hpp:59
claw::meta::type_list_maker_7
A type list with seven types, more readable than an imbricated type_list.
Definition: type_list.hpp:201
claw
This is the main namespace.
Definition: algorithm.hpp:33
claw::meta::split_type_list_at< Delimiter, no_type >::right_part_type
no_type right_part_type
There is no right part if there is no list.
Definition: type_list.hpp:88
claw::meta::type_list_maker_11
A type list with eleven types, more readable than an imbricated type_list.
Definition: type_list.hpp:262
claw::meta::type_list_maker_2
A type list with two types, more readable than an imbricated type_list.
Definition: type_list.hpp:138
claw::meta::type_list_maker::result
split_type_list_at< no_type, typename type_list_maker_15< T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 >::result >::left_part_type result
The list described by this implementation.
Definition: type_list.hpp:361
claw::meta::type_list_maker_13
A type list with thirteen types, more readable than an imbricated type_list.
Definition: type_list.hpp:296
claw::meta::type_list_maker_3
A type list with three types, more readable than an imbricated type_list.
Definition: type_list.hpp:149
claw::meta::type_list_length
This class computes the length of a list of types.
Definition: type_list.hpp:427
claw::meta::type_list_maker_4::result
type_list< T1, typename type_list_maker_3< T2, T3, T4 >::result > result
The list described by this implementation.
Definition: type_list.hpp:165
claw::meta::same_type
This predicate tells if two types are the sames.
Definition: same_type.hpp:48
claw::meta::type_list_maker
A type list with up to six types, more readable than an imbricated type_list, more readable than type...
Definition: type_list.hpp:353
claw::meta::type_list_maker_6::result
type_list< T1, typename type_list_maker_5< T2, T3, T4, T5, T6 >::result > result
The list described by this implementation.
Definition: type_list.hpp:192
claw::meta::type_list_maker_7::result
type_list< T1, typename type_list_maker_6< T2, T3, T4, T5, T6, T7 >::result > result
The list described by this implementation.
Definition: type_list.hpp:206
claw::meta::type_list_maker_9::result
type_list< T1, typename type_list_maker_8< T2, T3, T4, T5, T6, T7, T8, T9 >::result > result
The list described by this implementation.
Definition: type_list.hpp:236
claw::meta::type_list_maker_12
A type list with twelve types, more readable than an imbricated type_list.
Definition: type_list.hpp:279
claw::meta::type_list_maker_1
A type list with a single type, more readable than an imbricated type_list.
Definition: type_list.hpp:127
claw::meta::type_list_maker_12::result
type_list< T1, typename type_list_maker_11< T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 >::result > result
The list described by this implementation.
Definition: type_list.hpp:286
claw::meta::type_list_maker_14
A type list with fourteen types, more readable than an imbricated type_list.
Definition: type_list.hpp:313
claw::meta::type_list_maker_8::result
type_list< T1, typename type_list_maker_7< T2, T3, T4, T5, T6, T7, T8 >::result > result
The list described by this implementation.
Definition: type_list.hpp:220
claw::meta::type_list::head_type
Head head_type
The first type in the list.
Definition: type_list.hpp:62
claw::meta::type_list_maker_10::result
type_list< T1, typename type_list_maker_9< T2, T3, T4, T5, T6, T7, T8, T9, T10 >::result > result
The list described by this implementation.
Definition: type_list.hpp:252
claw::meta::cpp_type_list
type_list_maker< signed char, unsigned char, signed short, unsigned short, signed int, unsigned int, signed long, unsigned long, signed long long, unsigned long long, float, double, long double, bool >::result cpp_type_list
The list of the types of the C++ language.
Definition: type_list.hpp:493
claw::meta::type_list_maker_1::result
type_list< T1, no_type > result
The list described by this implementation.
Definition: type_list.hpp:130
claw::meta::type_list_find
Check if a type is present in a type_list.
Definition: type_list.hpp:377
claw::meta::if_then_else
This structure allows to do conditional typing.
Definition: conditional.hpp:50
claw::meta::type_list_maker_6
A type list with six types, more readable than an imbricated type_list.
Definition: type_list.hpp:187
claw::meta::type_list::queue_type
Queue queue_type
The remaining types in the list.
Definition: type_list.hpp:65
claw::meta::type_list_maker_3::result
type_list< T1, typename type_list_maker_2< T2, T3 >::result > result
The list described by this implementation.
Definition: type_list.hpp:153
claw::meta::type_list_is_a_set
This class checks if each type in a type_list<> is present only once.
Definition: type_list.hpp:402
claw::meta::type_list_maker_9
A type list with nine types, more readable than an imbricated type_list.
Definition: type_list.hpp:229
claw::meta::type_list_maker_15
A type list with fifteen types, more readable than an imbricated type_list.
Definition: type_list.hpp:331
claw::meta::no_type
Empty type.
Definition: no_type.hpp:40
claw::meta::type_list_maker_13::result
type_list< T1, typename type_list_maker_12< T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 >::result > result
The list described by this implementation.
Definition: type_list.hpp:303
same_type.hpp
Check if two types are the same.
claw::meta::type_list_maker_5
A type list with five types, more readable than an imbricated type_list.
Definition: type_list.hpp:173
no_type.hpp
An empty class not considered as a effective type.
claw::meta::split_type_list_at< Delimiter, no_type >::left_part_type
no_type left_part_type
There is no left part if there is no list.
Definition: type_list.hpp:85
claw::meta::type_list_maker_10
A type list with ten types, more readable than an imbricated type_list.
Definition: type_list.hpp:245
claw::meta::type_list_maker_14::result
type_list< T1, typename type_list_maker_13< T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 >::result > result
The list described by this implementation.
Definition: type_list.hpp:320
claw::meta::type_list_maker_8
A type list with height types, more readable than an imbricated type_list.
Definition: type_list.hpp:215