Midge
v3.9.2
Data Processing Framework
library
utility
typeat.hh
Go to the documentation of this file.
1
#ifndef _midge_typeat_hh_
2
#define _midge_typeat_hh_
3
4
#include "
typenull.hh
"
5
6
namespace
midge
7
{
8
// The type_at struct give you the type at a particular index within a set of types.
9
// e.g. the type at position 1 in [int, short, char] is short.
10
11
template
<
int
x_index,
class
... x_types >
12
struct
type_at_impl
;
13
14
// recursive case
15
template
<
int
x_index,
class
x_head,
class
... x_tail >
16
struct
type_at_impl
< x_index, x_head, x_tail... > :
type_at_impl
< x_index-1, x_tail... >
17
{ };
18
19
// base case
20
template
<
class
x_head,
class
... x_tail >
21
struct
type_at_impl
< 0, x_head, x_tail... >
22
{
23
using
type
= x_head;
24
};
25
26
template
<
int
x_index >
27
struct
type_at_impl
< x_index >
28
{
29
using
type
=
_
;
30
};
31
33
template
<
int
x_index,
class
... x_types >
34
using
type_at
=
typename
type_at_impl
< x_index, x_types... >::type;
35
36
37
// This version gives you the type at a position within a type's template parameters
38
// e.g. the type at position 1 in type_list<int, short, char> is short
39
// This version currently isn't used in midge, but the code has been kept in case it's useful in the future
40
/*
41
template< int x_index, class x_list >
42
struct type_at_impl;
43
44
// recursive case
45
template< int x_index, class x_head, class... x_tail >
46
struct type_at_impl< x_index, type_list< x_head, x_tail...> > : type_at_impl< x_index-1, type_list<x_tail...> >
47
{ };
48
49
// base case
50
template< class x_head, class... x_tail >
51
struct type_at_impl< 0, type_list<x_head, x_tail...> >
52
{
53
typedef x_head type;
54
};
55
56
template< int x_index >
57
struct type_at_impl< x_index, type_list<> >
58
{
59
typedef _ type;
60
};
61
62
template< int x_index, class x_list >
63
using type_at = typename type_at_impl< x_index, x_list >::type;
64
*/
65
}
66
67
#endif
typenull.hh
midge
Definition:
_buffer.hh:11
midge::type_at
typename type_at_impl< x_index, x_types... >::type type_at
Determines the type at position x_index within parameter pack x_types.
Definition:
typeat.hh:34
midge::type_at_impl< 0, x_head, x_tail... >::type
x_head type
Definition:
typeat.hh:23
midge::type_at_impl
Definition:
typeat.hh:12
midge::_
Definition:
typenull.hh:9
Generated by
1.8.13