Alchemy  1.0
A framework to robustly process network messages and structured data
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
type_list/length.h
1 /// @file meta/type_list/length.h
2 ///
3 /// Defines a construct that reports the number of types in a **type_container**.
4 ///
5 /// The MIT License(MIT)
6 /// @copyright 2014 Paul M Watt
7 // ****************************************************************************
8 #ifndef TYPE_LIST_LENGTH_H_INCLUDED
9 #define TYPE_LIST_LENGTH_H_INCLUDED
10 // Includes ******************************************************************
11 #include <Pb/type_list.h>
12 
13 namespace Hg
14 {
15 
16 // ***************************************************************************
17 /// Calculate the number of elements in the specified type container.
18 /// One definition is required for every specialization of the list.
19 /// The list currently supports 32 index entries. The hand written
20 /// version of this function for the list is 150 lines longs.
21 /// Therefore, the following MACRO will be used to create the
22 /// required definitions:
23 ///
24 /// tmp_TYPE_LIST_LENGTH(...)
25 ///
26 /// More details further below.
27 ///
28 
29 #define tmp_TYPE_LIST_LENGTH(I) \
30 template <TMP_ARRAY_##I(typename T)> \
31 struct length<TypeList<TMP_ARRAY_##I(T)> > \
32  : std::integral_constant<size_t, (I)> \
33 { }
34 
35 // MACRO Declarations for each ENTRY that is supported for the TypeList size
36  //template <typename T0>
37  //struct length<TypeList<T0> >
38  // : std::integral_constant<size_t, (1)>
39  //{ };
40 
41 
42 tmp_TYPE_LIST_LENGTH(1);
43 tmp_TYPE_LIST_LENGTH(2);
44 tmp_TYPE_LIST_LENGTH(3);
45 tmp_TYPE_LIST_LENGTH(4);
46 tmp_TYPE_LIST_LENGTH(5);
47 tmp_TYPE_LIST_LENGTH(6);
48 tmp_TYPE_LIST_LENGTH(7);
49 tmp_TYPE_LIST_LENGTH(8);
50 tmp_TYPE_LIST_LENGTH(9);
51 tmp_TYPE_LIST_LENGTH(10);
52 tmp_TYPE_LIST_LENGTH(11);
53 tmp_TYPE_LIST_LENGTH(12);
54 tmp_TYPE_LIST_LENGTH(13);
55 tmp_TYPE_LIST_LENGTH(14);
56 tmp_TYPE_LIST_LENGTH(15);
57 tmp_TYPE_LIST_LENGTH(16);
58 tmp_TYPE_LIST_LENGTH(17);
59 tmp_TYPE_LIST_LENGTH(18);
60 tmp_TYPE_LIST_LENGTH(19);
61 tmp_TYPE_LIST_LENGTH(20);
62 tmp_TYPE_LIST_LENGTH(21);
63 tmp_TYPE_LIST_LENGTH(22);
64 tmp_TYPE_LIST_LENGTH(23);
65 tmp_TYPE_LIST_LENGTH(24);
66 tmp_TYPE_LIST_LENGTH(25);
67 tmp_TYPE_LIST_LENGTH(26);
68 tmp_TYPE_LIST_LENGTH(27);
69 tmp_TYPE_LIST_LENGTH(28);
70 tmp_TYPE_LIST_LENGTH(29);
71 tmp_TYPE_LIST_LENGTH(30);
72 tmp_TYPE_LIST_LENGTH(31);
73 tmp_TYPE_LIST_LENGTH(32);
74 
75 // Undefining the declaration MACRO to prevent its further use. ***************
76 #undef tmp_TYPE_LIST_LENGTH
77 
78 } // namespace Hg
79 
80 #endif