proxsuite
0.7.3
The Advanced Proximal Optimization Toolbox
Toggle main menu visibility
Loading...
Searching...
No Matches
integer_seq.hpp
Go to the documentation of this file.
1
#ifndef VEG_INTEGER_SEQ_HPP_JBT0EKAQS
2
#define VEG_INTEGER_SEQ_HPP_JBT0EKAQS
3
4
#include "
proxsuite/linalg/veg/internal/typedefs.hpp
"
5
#include "
proxsuite/linalg/veg/internal/macros.hpp
"
6
#include "
proxsuite/linalg/veg/internal/prologue.hpp
"
7
8
namespace
proxsuite
{
9
namespace
linalg
{
10
namespace
veg
{
11
namespace
meta
{
12
13
template
<
typename
T, T N>
14
using
make_integer_sequence
=
_detail::_meta::make_integer_sequence<T, N>
*;
15
template
<usize N>
16
using
make_index_sequence
=
_detail::_meta::make_integer_sequence<usize, N>
*;
17
18
template
<
typename
T, T... Nums>
19
using
integer_sequence
=
_detail::_meta::integer_sequence
<T, Nums...>*;
20
template
<
usize
... Nums>
21
using
index_sequence
=
integer_sequence
<
usize
, Nums...>;
22
template
<
typename
... Ts>
23
using
type_sequence
=
_detail::_meta::type_sequence
<Ts...>*;
24
25
template
<
typename
Seq,
typename
... Bs>
26
struct
and_test
:
false_type
27
{};
28
template
<
typename
Seq,
typename
... Bs>
29
struct
or_test
:
true_type
30
{};
31
32
template
<usize Is,
typename
T>
33
using
indexed
= T;
34
35
template
<
typename
... Ts>
36
struct
pack_size
37
{
38
static
constexpr
usize
value
=
sizeof
...(Ts);
39
};
40
template
<
usize
... Is>
41
struct
and_test
<
index_sequence
<Is...>,
indexed
<Is,
true_type
>...> :
true_type
42
{};
43
template
<
usize
... Is>
44
struct
or_test
<
index_sequence
<Is...>,
indexed
<Is,
false_type
>...> :
false_type
45
{};
46
47
}
// namespace meta
48
namespace
_detail
{
49
namespace
_meta {
50
using namespace
meta
;
51
52
template
<
typename
ISeq,
typename
... Ts>
53
struct
all_same_impl
:
false_type
54
{};
55
template
<
usize
... Is,
typename
T>
56
struct
all_same_impl
<
meta
::
index_sequence
<Is...>,
57
discard_1st
<decltype(Is), T>...> :
true_type
58
{};
59
60
template
<>
61
struct
all_same_impl
<
meta
::
index_sequence
<>> :
true_type
62
{};
63
}
// namespace _meta
64
}
// namespace _detail
65
66
namespace
concepts
{
67
VEG_DEF_CONCEPT
(
68
typename
... Ts,
69
all_same,
70
_detail::_meta::all_same_impl
<
meta::make_index_sequence
<
sizeof
...(Ts)>,
71
Ts...>::value);
72
}
// namespace concepts
73
74
namespace
_detail
{
75
namespace
_meta {
76
template
<
template
<
typename
...>
class
F,
typename
Seq>
77
struct
apply_type_seq
;
78
template
<
template
<
typename
...>
class
F,
typename
... Ts>
79
struct
apply_type_seq
<F,
meta
::
type_sequence
<Ts...>>
80
{
81
using
type
= F<Ts...>;
82
};
83
84
template
<
typename
Valid,
template
<
typename
...>
class
F,
typename
... Seqs>
85
struct
concat_type_seq
;
86
87
template
<
typename
Valid,
template
<
typename
...>
class
F,
typename
... Seqs>
88
struct
zip_type_seq
;
89
template
<
template
<
typename
...>
class
F,
typename
... Seqs>
90
struct
zip_type_seq2
;
91
92
template
<
template
<
typename
...>
class
F>
93
struct
zip_type_seq
<
meta
::
true_type
, F>
94
{
95
using
type
= F<>;
96
};
97
98
template
<
template
<
typename
...>
class
F,
typename
... Ts>
99
struct
zip_type_seq
<
meta
::
true_type
, F, F<Ts...>>
100
{
101
using
type
= F<F<Ts>...>;
102
};
103
104
template
<
template
<
typename
...>
class
F,
typename
... Ts,
typename
... Zipped>
105
struct
zip_type_seq2
<F, F<Ts...>, F<Zipped...>>
106
{
107
using
type
=
108
F<typename concat_type_seq<true_type, F, F<Ts>, Zipped>
::type
...>;
109
};
110
111
template
<
template
<
typename
...>
class
F,
typename
T>
112
struct
specializes
:
meta::false_type
113
{};
114
template
<
template
<
typename
...>
class
F,
typename
... Ts>
115
struct
specializes
<F, F<Ts...>> :
meta::true_type
116
{};
117
118
template
<
template
<
typename
...>
class
F,
typename
T>
119
struct
specialize_len
:
meta::constant
<usize, 0>
120
{};
121
template
<
template
<
typename
...>
class
F,
typename
... Ts>
122
struct
specialize_len
<F, F<Ts...>> :
meta::constant
<usize, sizeof...(Ts)>
123
{};
124
125
template
<
template
<
typename
...>
class
F,
126
typename
... Ts,
127
typename
Seq,
128
typename
... Seqs>
129
struct
zip_type_seq
<
meta
::
true_type
, F, F<Ts...>, Seq, Seqs...>
130
{
131
using
type
=
typename
zip_type_seq2
<
132
F,
133
F<Ts...>,
134
typename
zip_type_seq
<
meta::true_type
, F, Seq, Seqs...>
::type
>
::type
;
135
};
136
137
template
<
template
<
typename
...>
class
F>
138
struct
concat_type_seq
<
true_type
, F>
139
{
140
using
type
= F<>;
141
};
142
143
template
<
template
<
typename
...>
class
F,
typename
... Ts>
144
struct
concat_type_seq
<
true_type
, F, F<Ts...>>
145
{
146
using
type
= F<Ts...>;
147
};
148
149
template
<
template
<
typename
...>
class
F,
typename
... Ts,
typename
... Us>
150
struct
concat_type_seq
<
true_type
, F, F<Ts...>, F<Us...>>
151
{
152
using
type
= F<Ts..., Us...>;
153
};
154
155
template
<
template
<
typename
...>
class
F,
156
typename
... Ts,
157
typename
... Us,
158
typename
... Vs,
159
typename
... Seqs>
160
struct
concat_type_seq
<
true_type
, F, F<Ts...>, F<Us...>, F<Vs...>, Seqs...>
161
{
162
using
type
=
typename
concat_type_seq
<
163
true_type
,
164
F,
165
F<Ts..., Us..., Vs...>,
166
typename
concat_type_seq
<
true_type
, F, Seqs...>
::type
>
::type
;
167
};
168
}
// namespace _meta
169
}
// namespace _detail
170
namespace
meta
{
171
template
<
template
<
typename
... F>
class
F, typename... Seqs>
172
using
type_sequence_cat
=
typename
_detail::_meta::concat_type_seq
<
173
bool_constant
<
VEG_ALL_OF
(
_detail::_meta::specializes<F, Seqs>::value
)>,
174
F,
175
Seqs...>::type;
176
177
template
<
template
<
typename
...>
class
F,
typename
... Seqs>
178
using
type_sequence_zip
=
typename
_detail::_meta::zip_type_seq
<
179
meta::bool_constant
<
180
VEG_ALL_OF
(
_detail::_meta::specializes<F, Seqs>::value
) &&
181
VEG_CONCEPT
(
182
all_same<
183
constant
<
usize
,
_detail::_meta::specialize_len<F, Seqs>::value
>...>)>,
184
F,
185
Seqs...>::type;
186
187
template
<
template
<
typename
...>
class
F,
typename
Seq>
188
using
type_sequence_apply
=
189
typename
_detail::_meta::apply_type_seq<F, Seq>::type
;
190
}
// namespace meta
191
192
namespace
_detail
{
193
194
template
<usize I,
typename
T>
195
struct
HollowLeaf
196
{};
197
198
template
<
typename
ISeq,
typename
... Ts>
199
struct
HollowIndexedTuple
;
200
template
<
usize
... Is,
typename
... Ts>
201
struct
HollowIndexedTuple
<
meta
::index_sequence<Is...>, Ts...>
202
:
HollowLeaf
<Is, Ts>...
203
{};
204
205
template
<usize I,
typename
T>
206
auto
207
get_type
(
HollowLeaf<I, T>
const
*)
VEG_NOEXCEPT
-> T;
208
template
<
typename
T, usize I>
209
auto
210
get_idx
(
HollowLeaf<I, T>
const
*)
VEG_NOEXCEPT
->
meta::constant<usize, I>
;
211
212
template
<usize I>
213
struct
pack_ith_elem
214
{
215
template
<
typename
... Ts>
216
using
Type
=
decltype
(
_detail::get_type<I>
(
217
static_cast<
218
HollowIndexedTuple
<
meta::make_index_sequence
<sizeof...(Ts)
>
, Ts...>*>(
219
nullptr
)));
220
};
221
222
template
<
typename
T>
223
struct
pack_idx_elem
224
{
225
template
<
typename
... Ts>
226
using
Type
=
decltype
(
_detail::get_idx<T>
(
227
static_cast<
228
HollowIndexedTuple
<
meta::make_index_sequence
<sizeof...(Ts)
>
, Ts...>*>(
229
nullptr
)));
230
};
231
}
// namespace _detail
232
233
template
<
typename
T,
typename
... Ts>
234
using
position_of
=
typename
_detail::pack_idx_elem<T>::template
Type<Ts...>;
235
236
#if VEG_HAS_BUILTIN(__type_pack_element)
237
namespace
_detail
{
238
template
<
usize
I,
typename
... Ts>
239
struct
type_pack_element
240
{
241
using
type = __type_pack_element<I, Ts...>;
242
};
243
}
244
template
<
usize
I,
typename
... Ts>
245
using
ith
=
typename
_detail::type_pack_element<I, Ts...>::type;
246
#else
247
template
<
usize
I,
typename
... Ts>
248
using
ith
=
typename
_detail::pack_ith_elem<I>::template
Type<Ts...>;
249
#endif
250
}
// namespace veg
251
}
// namespace linalg
252
}
// namespace proxsuite
253
254
#include "
proxsuite/linalg/veg/internal/epilogue.hpp
"
255
#endif
/* end of include guard VEG_INTEGER_SEQ_HPP_JBT0EKAQS */
epilogue.hpp
macros.hpp
VEG_ALL_OF
#define VEG_ALL_OF(...)
Definition
macros.hpp:177
VEG_CONCEPT
#define VEG_CONCEPT(...)
Definition
macros.hpp:1238
VEG_DEF_CONCEPT
#define VEG_DEF_CONCEPT(Tpl, Name,...)
Definition
macros.hpp:321
proxsuite::linalg::veg::_detail::_meta::discard_1st
V discard_1st
Definition
macros.hpp:628
proxsuite::linalg::veg::_detail
Definition
collection_algo.hpp:11
proxsuite::linalg::veg::_detail::get_type
auto get_type(HollowLeaf< I, T > const *) VEG_NOEXCEPT -> T
proxsuite::linalg::veg::_detail::get_idx
auto get_idx(HollowLeaf< I, T > const *) VEG_NOEXCEPT -> meta::constant< usize, I >
proxsuite::linalg::veg::concepts
Definition
fix_index.hpp:51
proxsuite::linalg::veg::meta
Definition
integer_seq.hpp:11
proxsuite::linalg::veg::meta::type_sequence_apply
typename _detail::_meta::apply_type_seq< F, Seq >::type type_sequence_apply
Definition
integer_seq.hpp:188
proxsuite::linalg::veg::meta::type_sequence
_detail::_meta::type_sequence< Ts... > * type_sequence
Definition
integer_seq.hpp:23
proxsuite::linalg::veg::meta::integer_sequence
_detail::_meta::integer_sequence< T, Nums... > * integer_sequence
Definition
integer_seq.hpp:19
proxsuite::linalg::veg::meta::type_sequence_zip
typename _detail::_meta::zip_type_seq< meta::bool_constant< VEG_ALL_OF(_detail::_meta::specializes< F, Seqs >::value) && VEG_CONCEPT( all_same< constant< usize, _detail::_meta::specialize_len< F, Seqs >::value >... >)>, F, Seqs... >::type type_sequence_zip
Definition
integer_seq.hpp:178
proxsuite::linalg::veg::meta::indexed
T indexed
Definition
integer_seq.hpp:33
proxsuite::linalg::veg::meta::make_integer_sequence
_detail::_meta::make_integer_sequence< T, N > * make_integer_sequence
Definition
integer_seq.hpp:14
proxsuite::linalg::veg::meta::type_sequence_cat
typename _detail::_meta::concat_type_seq< bool_constant< VEG_ALL_OF(_detail::_meta::specializes< F, Seqs >::value)>, F, Seqs... >::type type_sequence_cat
Definition
integer_seq.hpp:172
proxsuite::linalg::veg::meta::bool_constant
constant< bool, B > bool_constant
Definition
macros.hpp:897
proxsuite::linalg::veg::meta::make_index_sequence
_detail::_meta::make_integer_sequence< usize, N > * make_index_sequence
Definition
integer_seq.hpp:16
proxsuite::linalg::veg::meta::false_type
bool_constant< false > false_type
Definition
macros.hpp:900
proxsuite::linalg::veg::meta::true_type
bool_constant< true > true_type
Definition
macros.hpp:899
proxsuite::linalg::veg::meta::index_sequence
integer_sequence< usize, Nums... > index_sequence
Definition
integer_seq.hpp:21
proxsuite::linalg::veg
Definition
collection_algo.hpp:10
proxsuite::linalg::veg::usize
decltype(sizeof(0)) usize
Definition
macros.hpp:699
proxsuite::linalg::veg::position_of
typename _detail::pack_idx_elem< T >::template Type< Ts... > position_of
Definition
integer_seq.hpp:234
proxsuite::linalg::veg::ith
typename _detail::pack_ith_elem< I >::template Type< Ts... > ith
Definition
integer_seq.hpp:248
proxsuite::linalg
Definition
core.hpp:85
proxsuite
Definition
common.hpp:14
prologue.hpp
VEG_NOEXCEPT
#define VEG_NOEXCEPT
Definition
prologue.hpp:30
proxsuite::linalg::veg::_detail::HollowIndexedTuple
Definition
integer_seq.hpp:199
proxsuite::linalg::veg::_detail::HollowLeaf
Definition
integer_seq.hpp:196
proxsuite::linalg::veg::_detail::_meta::all_same_impl
Definition
integer_seq.hpp:54
proxsuite::linalg::veg::_detail::_meta::apply_type_seq< F, meta::type_sequence< Ts... > >::type
F< Ts... > type
Definition
integer_seq.hpp:81
proxsuite::linalg::veg::_detail::_meta::apply_type_seq
Definition
integer_seq.hpp:77
proxsuite::linalg::veg::_detail::_meta::concat_type_seq< true_type, F, F< Ts... >, F< Us... > >::type
F< Ts..., Us... > type
Definition
integer_seq.hpp:152
proxsuite::linalg::veg::_detail::_meta::concat_type_seq< true_type, F, F< Ts... > >::type
F< Ts... > type
Definition
integer_seq.hpp:146
proxsuite::linalg::veg::_detail::_meta::concat_type_seq< true_type, F >::type
F<> type
Definition
integer_seq.hpp:140
proxsuite::linalg::veg::_detail::_meta::concat_type_seq< true_type, F, F< Ts... >, F< Us... >, F< Vs... >, Seqs... >::type
typename concat_type_seq< true_type, F, F< Ts..., Us..., Vs... >, typename concat_type_seq< true_type, F, Seqs... >::type >::type type
Definition
integer_seq.hpp:162
proxsuite::linalg::veg::_detail::_meta::concat_type_seq
Definition
integer_seq.hpp:85
proxsuite::linalg::veg::_detail::_meta::integer_sequence
Definition
macros.hpp:711
proxsuite::linalg::veg::_detail::_meta::specialize_len
Definition
integer_seq.hpp:120
proxsuite::linalg::veg::_detail::_meta::specializes
Definition
integer_seq.hpp:113
proxsuite::linalg::veg::_detail::_meta::type_sequence
Definition
macros.hpp:795
proxsuite::linalg::veg::_detail::_meta::zip_type_seq2< F, F< Ts... >, F< Zipped... > >::type
F< typename concat_type_seq< true_type, F, F< Ts >, Zipped >::type... > type
Definition
integer_seq.hpp:107
proxsuite::linalg::veg::_detail::_meta::zip_type_seq2
Definition
integer_seq.hpp:90
proxsuite::linalg::veg::_detail::_meta::zip_type_seq< meta::true_type, F >::type
F<> type
Definition
integer_seq.hpp:95
proxsuite::linalg::veg::_detail::_meta::zip_type_seq< meta::true_type, F, F< Ts... >, Seq, Seqs... >::type
typename zip_type_seq2< F, F< Ts... >, typename zip_type_seq< meta::true_type, F, Seq, Seqs... >::type >::type type
Definition
integer_seq.hpp:131
proxsuite::linalg::veg::_detail::_meta::zip_type_seq< meta::true_type, F, F< Ts... > >::type
F< F< Ts >... > type
Definition
integer_seq.hpp:101
proxsuite::linalg::veg::_detail::_meta::zip_type_seq
Definition
integer_seq.hpp:88
proxsuite::linalg::veg::_detail::pack_idx_elem
Definition
integer_seq.hpp:224
proxsuite::linalg::veg::_detail::pack_idx_elem::Type
decltype(_detail::get_idx< T >( static_cast< HollowIndexedTuple< meta::make_index_sequence< sizeof...(Ts)>, Ts... > * >( nullptr))) Type
Definition
integer_seq.hpp:226
proxsuite::linalg::veg::_detail::pack_ith_elem
Definition
integer_seq.hpp:214
proxsuite::linalg::veg::_detail::pack_ith_elem::Type
decltype(_detail::get_type< I >( static_cast< HollowIndexedTuple< meta::make_index_sequence< sizeof...(Ts)>, Ts... > * >( nullptr))) Type
Definition
integer_seq.hpp:216
proxsuite::linalg::veg::meta::and_test
Definition
integer_seq.hpp:27
proxsuite::linalg::veg::meta::constant
Definition
macros.hpp:891
proxsuite::linalg::veg::meta::constant< bool, B >< false >::value
static constexpr bool value
Definition
macros.hpp:892
proxsuite::linalg::veg::meta::or_test
Definition
integer_seq.hpp:30
proxsuite::linalg::veg::meta::pack_size
Definition
integer_seq.hpp:37
proxsuite::linalg::veg::meta::pack_size::value
static constexpr usize value
Definition
integer_seq.hpp:38
typedefs.hpp
include
proxsuite
linalg
veg
internal
integer_seq.hpp
Generated by
1.17.0