proxsuite 0.6.7
The Advanced Proximal Optimization Toolbox
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
7
8namespace proxsuite {
9namespace linalg {
10namespace veg {
11namespace meta {
12
13template<typename T, T N>
15template<usize N>
17
18template<typename T, T... Nums>
20template<usize... Nums>
22template<typename... Ts>
24
25template<typename Seq, typename... Bs>
27{};
28template<typename Seq, typename... Bs>
30{};
31
32template<usize Is, typename T>
33using indexed = T;
34
35template<typename... Ts>
37{
38 static constexpr usize value = sizeof...(Ts);
39};
40template<usize... Is>
42{};
43template<usize... Is>
45{};
46
47} // namespace meta
48namespace _detail {
49namespace _meta {
50using namespace meta;
51
52template<typename ISeq, typename... Ts>
55template<usize... Is, typename T>
56struct all_same_impl<meta::index_sequence<Is...>,
57 discard_1st<decltype(Is), T>...> : true_type
58{};
59
60template<>
62{};
63} // namespace _meta
64} // namespace _detail
65
66namespace concepts {
68 typename... Ts,
71 Ts...>::value);
72} // namespace concepts
73
74namespace _detail {
75namespace _meta {
76template<template<typename...> class F, typename Seq>
78template<template<typename...> class F, typename... Ts>
79struct apply_type_seq<F, meta::type_sequence<Ts...>>
80{
81 using type = F<Ts...>;
82};
83
84template<typename Valid, template<typename...> class F, typename... Seqs>
86
87template<typename Valid, template<typename...> class F, typename... Seqs>
89template<template<typename...> class F, typename... Seqs>
91
92template<template<typename...> class F>
93struct zip_type_seq<meta::true_type, F>
94{
95 using type = F<>;
96};
97
98template<template<typename...> class F, typename... Ts>
99struct zip_type_seq<meta::true_type, F, F<Ts...>>
100{
101 using type = F<F<Ts>...>;
102};
103
104template<template<typename...> class F, typename... Ts, typename... Zipped>
105struct zip_type_seq2<F, F<Ts...>, F<Zipped...>>
106{
107 using type =
109};
110
111template<template<typename...> class F, typename T>
114template<template<typename...> class F, typename... Ts>
116{};
117
118template<template<typename...> class F, typename T>
120{};
121template<template<typename...> class F, typename... Ts>
122struct specialize_len<F, F<Ts...>> : meta::constant<usize, sizeof...(Ts)>
123{};
124
125template<template<typename...> class F,
126 typename... Ts,
127 typename Seq,
128 typename... Seqs>
129struct 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
137template<template<typename...> class F>
139{
140 using type = F<>;
141};
142
143template<template<typename...> class F, typename... Ts>
144struct concat_type_seq<true_type, F, F<Ts...>>
145{
146 using type = F<Ts...>;
147};
148
149template<template<typename...> class F, typename... Ts, typename... Us>
150struct concat_type_seq<true_type, F, F<Ts...>, F<Us...>>
151{
152 using type = F<Ts..., Us...>;
153};
154
155template<template<typename...> class F,
156 typename... Ts,
157 typename... Us,
158 typename... Vs,
159 typename... Seqs>
160struct 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
170namespace meta {
171template<template<typename... F> class F, typename... Seqs>
174 F,
175 Seqs...>::type;
176
177template<template<typename...> class F, typename... Seqs>
182 all_same<
184 F,
185 Seqs...>::type;
186
187template<template<typename...> class F, typename Seq>
190} // namespace meta
191
192namespace _detail {
193
194template<usize I, typename T>
196{};
197
198template<typename ISeq, typename... Ts>
200template<usize... Is, typename... Ts>
201struct HollowIndexedTuple<meta::index_sequence<Is...>, Ts...>
202 : HollowLeaf<Is, Ts>...
203{};
204
205template<usize I, typename T>
206auto
208template<typename T, usize I>
209auto
211
212template<usize I>
214{
215 template<typename... Ts>
216 using Type = decltype(_detail::get_type<I>(
217 static_cast<
219 nullptr)));
220};
221
222template<typename T>
224{
225 template<typename... Ts>
226 using Type = decltype(_detail::get_idx<T>(
227 static_cast<
229 nullptr)));
230};
231} // namespace _detail
232
233template<typename T, typename... Ts>
235
236#if VEG_HAS_BUILTIN(__type_pack_element)
237namespace _detail {
238template<usize I, typename... Ts>
240{
241 using type = __type_pack_element<I, Ts...>;
242};
243}
244template<usize I, typename... Ts>
245using ith = typename _detail::type_pack_element<I, Ts...>::type;
246#else
247template<usize I, typename... Ts>
248using ith = typename _detail::pack_ith_elem<I>::template Type<Ts...>;
249#endif
250} // namespace veg
251} // namespace linalg
252} // namespace proxsuite
253
255#endif /* end of include guard VEG_INTEGER_SEQ_HPP_JBT0EKAQS */
#define VEG_ALL_OF(...)
Definition macros.hpp:177
#define VEG_CONCEPT(...)
Definition macros.hpp:1243
#define VEG_DEF_CONCEPT(Tpl, Name,...)
Definition macros.hpp:321
auto get_type(HollowLeaf< I, T > const *) VEG_NOEXCEPT -> T
auto get_idx(HollowLeaf< I, T > const *) VEG_NOEXCEPT -> meta::constant< usize, I >
typename _detail::_meta::apply_type_seq< F, Seq >::type type_sequence_apply
_detail::_meta::make_integer_sequence< T, N > * make_integer_sequence
_detail::_meta::make_integer_sequence< usize, N > * make_index_sequence
bool_constant< true > true_type
Definition macros.hpp:902
typename _detail::_meta::concat_type_seq< bool_constant< VEG_ALL_OF(_detail::_meta::specializes< F, Seqs >::value)>, F, Seqs... >::type type_sequence_cat
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
typename _detail::pack_idx_elem< T >::template Type< Ts... > position_of
typename _detail::pack_ith_elem< I >::template Type< Ts... > ith
decltype(sizeof(0)) usize
Definition macros.hpp:702
#define VEG_NOEXCEPT
Definition prologue.hpp:30
typename concat_type_seq< true_type, F, F< Ts..., Us..., Vs... >, typename concat_type_seq< true_type, F, Seqs... >::type >::type type
typename zip_type_seq2< F, F< Ts... >, typename zip_type_seq< meta::true_type, F, Seq, Seqs... >::type >::type type
decltype(_detail::get_idx< T >( static_cast< HollowIndexedTuple< meta::make_index_sequence< sizeof...(Ts)>, Ts... > * >( nullptr))) Type
decltype(_detail::get_type< I >( static_cast< HollowIndexedTuple< meta::make_index_sequence< sizeof...(Ts)>, Ts... > * >( nullptr))) Type