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_node.h
1
/// @file meta/type_node.h
2
///
3
/// Defines a basic building block for type operations.
4
///
5
/// This file contains the declarations for a template meta-program TypeNode.
6
/// The node is useful for creating more useful type constructs by
7
/// concatenating strings of these types.
8
///
9
/// The MIT License(MIT)
10
/// @copyright 2014 Paul M Watt
11
// ****************************************************************************
12
#ifndef TYPE_NODE_H_INCLUDED
13
#define TYPE_NODE_H_INCLUDED
14
// Includes ******************************************************************
15
16
namespace
Hg
17
{
18
19
// ****************************************************************************
20
/// A fundamental type used for template meta-programming type containers.
21
///
22
/// The fundamental element that is used to create both a template-meta
23
/// TypeList and TypeList. These constructs are useful for building structures
24
/// known at compile time that incur a very minimal runtime cost.
25
///
26
/// These constructs have a data buffer allocated with a size that matches the
27
/// size of the two parameterized types passed in. This will allow these types
28
/// to behave similar to the intrinsic types for calculating and creating
29
/// objects on the stack.
30
///
31
template
<
typename
H,
typename
T>
32
struct
TypeNode
33
{
34
typedef
H head;
35
typedef
T tail;
36
37
private
:
38
unsigned
char
size_info_[
sizeof
(H)+
sizeof
(T)];
39
};
40
41
// ****************************************************************************
42
/// A terminator for TypeNode chains.
43
///
44
/// A specialized version of the TypeNode template to facilitate sizeof
45
/// calculations that are consistent with how the operator behaves for
46
/// intrinsic and regular user-defined types.
47
///
48
/// This specialization is the equivalent of applying the EBO. Otherwise, the
49
/// size of the MT type all by itself will add the mandatory 1 extra byte.
50
/// This creates an off-by-one error for all objects since this is the
51
/// terminator case.
52
///
53
template
<
typename
H>
54
struct
TypeNode
<H,
MT
>
55
{
56
typedef
H head;
57
typedef
MT
tail
;
58
private
:
59
unsigned
char
size_info_[
sizeof
(H)];
60
61
// prevent the instantiation of a TypeNode, and all types built upon it.
62
~
TypeNode
();
63
};
64
65
}
// namespace Hg
66
67
#endif
Generated on Sat May 9 2015 21:25:05 for Alchemy by
1.8.3.1