Alchemy
1.0
A framework to robustly process network messages and structured data
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
Pb
type_at.h
1
/// @file meta/type_at.h
2
///
3
/// Provides utility functions for use with type_containers.
4
///
5
/// This file provides these utility access functions for use with the
6
///
7
/// - **TypeList**
8
/// This provides a form of reflection upon the data type. Reflection is not
9
/// a feature provided by C++. **TypeAt** works upon a **TypeList**
10
/// definition to query the type of parameter at the specified index.
11
///
12
/// - **front**
13
/// Returns the type for the element at the beginning of the **TypeList**.
14
///
15
/// - **pop_front**
16
/// Removes the type for the element at the beginning of the
17
/// **TypeList**. The TypeList defined in the resulting
18
/// meta-structure is the original TypeList with the first element removed.
19
///
20
/// - **push_front**
21
/// Pushes a new type at the beginning of the **TypeList**.
22
/// The TypeList defined in the resulting meta-structure is the original
23
/// TypeList with the new element added to the front of the array.
24
///
25
/// - **back**
26
/// Returns the type for the element at the end of the **TypeList**.
27
///
28
/// The MIT License(MIT)
29
/// @copyright 2014 Paul M Watt
30
// ****************************************************************************
31
#ifndef TYPE_AT_H_INCLUDED
32
#define TYPE_AT_H_INCLUDED
33
// Includes ******************************************************************
34
#include <Pb/type_list.h>
35
36
namespace
Hg
37
{
38
39
// ****************************************************************************
40
/// Return the type at the specified array index.
41
///
42
/// @note
43
/// If the type at Index does not exist, a compiler error will occur.
44
///
45
template
<
size_t
Index,
46
typename
ContainerT,
47
typename
ErrorT = error::Undefined_Type>
48
struct
TypeAt;
49
50
// ****************************************************************************
51
/// The generic form of this template simply returns an error.
52
///
53
template
<
size_t
Index,
54
typename
ContainerT,
55
typename
ErrorT>
56
struct
TypeAt
57
{
58
typedef
ErrorT type;
59
};
60
61
// ****************************************************************************
62
/// Specialization for an MT Type Container
63
///
64
template
<>
65
struct
front<
MT
>
66
{
67
typedef
MT
type
;
68
};
69
70
// ****************************************************************************
71
/// Specialization for a TypeNode
72
///
73
template
<
typename
T1,
typename
T2>
74
struct
pop_front<
TypeNode
<T1, T2> >
75
{
76
typedef
T2 type;
77
};
78
79
// ****************************************************************************
80
/// Specialization for an MT TypeList: results with type T and empty.
81
///
82
template
<
typename
T>
83
struct
push_front<
MT
, T>
84
{
85
typedef
TypeNode<T, MT>
type
;
86
};
87
88
// ****************************************************************************
89
/// Specialization for a TypeNode: TypeList
90
///
91
template
<
typename
T1,
typename
T2,
typename
T>
92
struct
push_front<
TypeNode
<T1, T2>, T>
93
{
94
typedef
TypeNode< T, TypeNode<T1, T2>
>
type
;
95
};
96
97
// ****************************************************************************
98
/// Specialization for an MT TypeList
99
///
100
template
<>
101
struct
back<
MT
>
102
{ };
103
104
105
}
// namespace Hg
106
107
// Include Type Container specific implementations.
108
#include <Pb/type_list/type_at.h>
109
110
#endif
Generated on Sat May 9 2015 21:25:05 for Alchemy by
1.8.3.1