TooN Algorithm Library - tag
0.2
|
#include <tuple.h>
Classes | |
class | index_type |
Public Types | |
enum | { elements = (Internal::length<C,D>::len) } |
typedef C | val_type |
The type of the current element. More... | |
typedef D | next_type |
The type of the rest of the list. More... | |
Public Member Functions | |
T_list (const C &c, const D &d) | |
template<class X > | |
T_list< X, T_list< C, D > > | operator, (const X &c) const |
template<int i> | |
const Internal::T_index_forward < tag::T_list, C, D, i > ::val_type & | index () const |
Public Attributes | |
const C & | val |
The value of the current element (the end of the list) More... | |
const D & | next |
The rest of the list. More... | |
Tuple/ typelist class. Passed by const reference.
A typelist containing an int, float and char* represented by the class:
Typelists can be conviniently be built through use of the ,
operator. The following code will have the type given above:
or more convieniently with a macro:
Note that the order is reversed between how the type is written and how a list is written using operator,()
. The lists can be statically indexed, and the indexing matches the order written using ,
. That is index 0 will refer to (char*) "hello"
. Indexing can be performed by value:
and by type:
The length of the list is a static member, so the last element can be eccessed by:
The following code gives a simple example of the usage. The code simply prints out a list of values.
This will print
typedef D tag::T_list< C, D >::next_type |
The type of the rest of the list.
typedef C tag::T_list< C, D >::val_type |
The type of the current element.
|
inline |
Construct a typelist.
c | The value of the end of the list |
d | The rest of the list |
|
inline |
Index the list in logical order and return the value. Index 0 is the first element added to the list (the one closest to T_ListEnd)
|
inline |
This operator can be used to build a typelist from values in code
The list:
containing 1, 2.0 and 3.3 can be built up by:
Though it is important to note that the list is built in reverse, so that 3.3 is the most accessible element.
c | List to which an element should be appended. |
const D& tag::T_list< C, D >::next |
The rest of the list.
const C& tag::T_list< C, D >::val |
The value of the current element (the end of the list)