-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTuple.hpp
More file actions
558 lines (479 loc) · 21.3 KB
/
Tuple.hpp
File metadata and controls
558 lines (479 loc) · 21.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
#include <iostream>
#include <type_traits>
#include <utility>
template<size_t N, typename... Args>
struct GetType {};
template<size_t N, typename Head, typename... Tail>
struct GetType<N, Head, Tail...> {
using type = typename GetType<N - 1, Tail...>::type;
};
template<typename Head, typename... Tail>
struct GetType<0, Head, Tail...> {
using type = Head;
};
template<typename... Types>
class tuple {};
namespace detail {
template<typename... Types>
struct is_types_copy_constructible : std::conjunction<std::is_copy_constructible<Types>...> {};
template<typename... Types>
struct is_types_move_constructible : std::conjunction<std::is_move_constructible<Types>...> {};
template<typename... Types>
struct is_types_default_constructible : std::conjunction<std::is_default_constructible<Types>...> {};
template<typename... Types>
struct is_types_copy_assignable : std::conjunction<std::is_copy_assignable<Types>...> {};
template<typename... Types>
struct is_types_move_assignable : std::conjunction<std::is_move_assignable<Types>...> {};
template<typename... Types>
struct is_tuple_types_copy_assignable_universal {};
template<typename... Types, typename... UTypes>
struct is_tuple_types_copy_assignable_universal<tuple<Types...>, tuple<UTypes...>> : std::conjunction<std::is_assignable<Types&, const UTypes&>...> {};
template<typename... Types>
struct is_tuple_types_move_assignable_universal {};
template<typename... Types, typename... UTypes>
struct is_tuple_types_move_assignable_universal<tuple<Types...>, tuple<UTypes...>> : std::conjunction<std::is_assignable<Types&, UTypes>...> {};
template<typename... Types>
struct is_copy_list_initializable : std::conjunction<std::is_constructible<Types, std::initializer_list< std::remove_reference_t<Types> >>...> {};
template<typename... Types>
struct is_tuple_types_convertible {};
template<typename... Types, typename... UTypes>
struct is_tuple_types_convertible<tuple<Types...>, tuple<UTypes...> >
: std::conjunction<std::is_convertible<Types, UTypes>...> {
};
template<typename... Types>
struct is_types_copy_convertible : is_tuple_types_convertible<tuple<Types...>, tuple<const Types &...>> {};
template<typename... Types>
struct is_tuple_types_constructible {};
template<typename... Types, typename... UTypes>
struct is_tuple_types_constructible<tuple<Types...>, tuple<UTypes...> >
: std::conjunction<std::is_constructible<Types, UTypes>...> {};
template<typename... Types>
struct is_tuple_sizes_equal {};
template<typename... Types, typename... UTypes>
struct is_tuple_sizes_equal<tuple<Types...>, tuple<UTypes...> > {
static constexpr bool value = (sizeof...(Types) == sizeof...(UTypes));
};
template<bool IsMove, typename Tuple>
struct other_ref;
template<typename Tuple>
struct other_ref<true, Tuple> {
using type = Tuple &&;
};
template<typename Tuple>
struct other_ref<false, Tuple> {
using type = const Tuple &;
};
template<bool IsMove, typename Tuple>
using other_ref_t = typename other_ref<IsMove, Tuple>::type;
template<bool IsMoveOther, typename... Types>
struct constructible_tuple {
};
template<bool IsMoveOther, typename First, typename Second>
struct constructible_tuple<IsMoveOther, tuple<First>, tuple<Second>> {
using ThisRef = First;
using OtherRef = decltype(get<0>(std::declval<other_ref_t<IsMoveOther, tuple<Second> >>()));
static constexpr bool value = std::is_constructible_v<ThisRef, OtherRef>;
};
template<bool IsMoveOther, typename Head, typename... Tail, typename UHead, typename... UTail>
struct constructible_tuple<IsMoveOther, tuple<Head, Tail...>, tuple<UHead, UTail...>>
: std::conjunction<
constructible_tuple<IsMoveOther, tuple<Head>, tuple<UHead> >,
constructible_tuple<IsMoveOther, tuple<Tail...>, tuple<UTail...> >
> {};
template<bool IsMove, typename... Types>
struct converting_constructor_third_condition {
};
template<bool IsMove, typename F, typename S, typename... Types, typename... UTypes> // statuc assert Types == Utypes
struct converting_constructor_third_condition<IsMove, tuple<F, S, Types...>, tuple<UTypes...> > : std::true_type {
};
template<bool IsMove, typename F, typename S>
struct converting_constructor_third_condition<IsMove, tuple<F>, tuple<S> > {
using OtherRef = other_ref_t<IsMove, tuple<S>>;
static constexpr bool value =
(!std::is_convertible_v<OtherRef, F>) && (!std::is_constructible_v<F, OtherRef>) && (!std::is_same_v<F, S>);
};
template<bool IsMove, typename... Types>
struct is_tuple_types_convertible_fwb {};
template<bool IsMove, typename Head, typename UHead>
struct is_tuple_types_convertible_fwb<IsMove, tuple<Head>, tuple<UHead>> {
using ThisRef = Head;
using OtherRef = decltype(get<0>( std::declval< other_ref_t<IsMove, tuple<Head>> >()));
static constexpr bool value = std::is_convertible_v<OtherRef, ThisRef>;
};
template<bool IsMove, typename Head, typename... Tail, typename UHead, typename... UTail>
struct is_tuple_types_convertible_fwb<IsMove, tuple<Head, Tail...>, tuple<UHead, UTail...>> : std::conjunction<
is_tuple_types_convertible_fwb<IsMove, tuple<Head>, tuple<UHead>>,
is_tuple_types_convertible_fwb<IsMove, tuple<Tail...>, tuple<UTail...>>
> {};
template<typename T, typename... Types>
struct tuple_cnt_type_T {};
template<typename T>
struct tuple_cnt_type_T<T, tuple<>> {
static constexpr u_int32_t value = 0;
};
template<typename T, typename Head, typename... Tail>
struct tuple_cnt_type_T<T, tuple<Head, Tail...>> {
static constexpr u_int32_t value = (std::is_same_v<std::decay_t<Head>, T> ? 1 : 0) + tuple_cnt_type_T<T, tuple<Tail...>>::value;
};
template<typename... Types>
constexpr bool is_types_copy_constructible_v = is_types_copy_constructible<Types...>::value;
template<typename... Types>
constexpr bool is_types_move_constructible_v = is_types_move_constructible<Types...>::value;
template<typename... Types>
constexpr bool is_types_default_constructible_v = is_types_default_constructible<Types...>::value;
template<typename... Types>
constexpr bool is_types_copy_assignable_v = is_types_copy_assignable<Types...>::value;
template<typename... Types>
constexpr bool is_types_move_assignable_v = is_types_move_assignable<Types...>::value;
template<typename Tuple1, typename Tuple2>
constexpr bool is_tuple_types_copy_assignable_universal_v = is_tuple_types_copy_assignable_universal<Tuple1, Tuple2>::value;
template<typename Tuple1, typename Tuple2>
constexpr bool is_tuple_types_move_assignable_universal_v = is_tuple_types_move_assignable_universal<Tuple1, Tuple2>::value;
template<typename... Types>
constexpr bool is_copy_list_initializable_v = is_copy_list_initializable<Types...>::value;
template<typename... Types>
constexpr bool is_types_copy_convertible_v = is_types_copy_convertible<Types...>::value;
template<typename Tuple1, typename Tuple2>
constexpr bool is_tuple_types_constructible_v = is_tuple_types_constructible<Tuple1, Tuple2>::value;
template<typename Tuple1, typename Tuple2>
constexpr bool is_tuple_sizes_equal_v = is_tuple_sizes_equal<Tuple1, Tuple2>::value;
template<typename Tuple1, typename Tuple2>
constexpr bool is_tuple_types_convertible_v = is_tuple_types_convertible<Tuple1, Tuple2>::value;
template<bool IsMoveOther, typename Tuple1, typename Tuple2>
constexpr bool constructible_tuple_v = constructible_tuple<IsMoveOther, Tuple1, Tuple2>::value;
template<bool IsMove, typename F, typename S>
constexpr bool converting_constructor_third_condition_v = converting_constructor_third_condition<IsMove, F, S>::value;
template<bool IsMove, typename F, typename S>
constexpr bool is_tuple_types_convertible_fwb_v = is_tuple_types_convertible_fwb<IsMove, F, S>::value;
template<typename T, typename Tuple>
constexpr u_int32_t tuple_cnt_type_T_v = tuple_cnt_type_T<T, Tuple>::value;
};
template<typename Head, typename... Tail>
class tuple<Head, Tail...> {
private:
Head head_;
tuple<Tail...> tail_;
public:
using HeadType = Head;
explicit(!detail::is_copy_list_initializable_v<Head, Tail...>)
tuple()
requires(detail::is_types_default_constructible_v<Head, Tail...>)
= default;
explicit (!detail::is_types_copy_convertible_v<Head, Tail...>)
tuple(const Head& head, const Tail&... tail)
requires(
detail::is_types_copy_constructible_v<Head, Tail...>
)
: head_(head),
tail_(tail...)
{}
template<typename UHead, typename... UTail>
explicit (!detail::is_tuple_types_convertible_v<tuple<Head, Tail...>, tuple<UHead, UTail...>>)
tuple(UHead &&other_head, UTail&& ...other_tail)
requires(
detail::is_tuple_sizes_equal_v<tuple<Head, Tail...>, tuple<UHead, UTail...>> &&
detail::is_tuple_types_constructible_v<tuple<Head, Tail...>, tuple<UHead, UTail...>> &&
detail::is_tuple_sizes_equal_v<tuple<Head, Tail...>, tuple<UHead, UTail...>>
)
: head_(std::forward<UHead>(other_head)),
tail_(std::forward<UTail>(other_tail)...)
{}
template<typename UHead, typename... UTail>
explicit(!detail::is_tuple_types_convertible_fwb_v<false, tuple<Head, Tail...>, tuple<UHead, UTail...>>)
tuple(const tuple<UHead, UTail...>& other)
requires(
detail::is_tuple_sizes_equal_v<tuple<Head, Tail...>, tuple<UHead, UTail...>> &&
detail::constructible_tuple_v<false, tuple<Head, Tail...>, tuple<UHead, UTail...>> &&
detail::converting_constructor_third_condition_v<false, tuple<Head, Tail...>, tuple<UHead, UTail...>>
)
: head_(std::forward<decltype((other.head_))>(other.head_)),
tail_(other.tail_)
{}
template<typename UHead, typename... UTail>
explicit(!detail::is_tuple_types_convertible_fwb_v<true, tuple<Head, Tail...>, tuple<UHead, UTail...>>)
tuple(tuple<UHead, UTail...>&& other)
requires(
detail::is_tuple_sizes_equal_v<tuple<Head, Tail...>, tuple<UHead, UTail...>> &&
detail::constructible_tuple_v<true, tuple<Head, Tail...>, tuple<UHead, UTail...>> &&
detail::converting_constructor_third_condition_v<true, tuple<Head, Tail...>, tuple<UHead, UTail...>>
)
: head_(std::move(other.head_)),
tail_(std::move(other.tail_))
{}
template<typename T1, typename T2>
tuple(const std::pair<T1, T2>& other):
head_(other.first),
tail_(other.second)
{}
template<typename T1, typename T2>
tuple(std::pair<T1, T2>&& other):
head_(std::move(other.first)),
tail_(std::move(other.second))
{}
tuple(const tuple& other)
requires(detail::is_types_copy_constructible_v<Head, Tail...>)
: head_(other.head_),
tail_(other.tail_)
{
static_assert(std::is_copy_constructible_v<decltype(head_)>);
}
tuple(const tuple& other)
requires(!detail::is_types_copy_constructible_v<Head, Tail...>) = delete;
tuple(tuple&& other)
requires(detail::is_types_move_constructible_v<Head, Tail...>)
: head_(std::move(other.head_)),
tail_(std::move(other.tail_))
{
static_assert(std::is_move_constructible_v<decltype(head_)>);
}
tuple(tuple&& other)
requires(!detail::is_types_move_constructible_v<Head, Tail...>) = delete;
tuple& operator=(const tuple& other)
requires(detail::is_types_copy_assignable_v<Head, Tail...>){
head_ = other.head_;
tail_ = other.tail_;
return *this;
}
tuple& operator=(const tuple& other)
requires(!detail::is_types_copy_assignable_v<Head, Tail...>) = delete;
tuple& operator=(tuple&& other)
requires(detail::is_types_move_assignable_v<Head, Tail...>){
head_ = std::forward<Head>(get<0>(std::move(other)));
tail_ = std::move(other.tail_);
return *this;
}
tuple& operator=(tuple&& other)
requires(!detail::is_types_move_assignable_v<Head, Tail...>) = delete;
template<typename UHead, typename... UTail>
tuple& operator=(const tuple<UHead, UTail...>& other)
requires(
detail::is_tuple_sizes_equal_v<tuple<Head, Tail...>, tuple<UHead, UTail...>> &&
detail::is_tuple_types_copy_assignable_universal_v<tuple<Head, Tail...>, tuple<UHead, UTail...>>
) {
head_ = other.head_;
tail_ = other.tail_;
return *this;
}
template<typename UHead, typename... UTail>
tuple& operator=(tuple<UHead, UTail...>&& other)
requires(
detail::is_tuple_sizes_equal_v<tuple<Head, Tail...>, tuple<UHead, UTail...>> &&
detail::is_tuple_types_move_assignable_universal_v<tuple<Head, Tail...>, tuple<UHead, UTail...>>
) {
head_ = std::move(other.head_);
tail_ = std::move(other.tail_);
return *this;
}
bool operator==(const tuple& other) const {
if (head_ != other.head_) return false;
if constexpr (sizeof...(Tail) > 0) {
return (tail_ == other.tail_);
} else {
return true;
}
}
template<size_t I, typename UHead, typename... UTail>
friend decltype(auto) get_impl(const tuple<UHead, UTail...> &tuple);
template<size_t I, typename UHead, typename... UTail>
friend decltype(auto) get_impl(const tuple<UHead, UTail...> &&tuple);
template<size_t I, typename UHead, typename... UTail>
friend decltype(auto) get_impl(tuple<UHead, UTail...> &tuple);
template<size_t I, typename UHead, typename... UTail>
friend decltype(auto) get_impl(tuple<UHead, UTail...> &&tuple);
template<size_t I, typename Tuple>
friend decltype(auto) get(Tuple&& t);
template<typename T, typename Tuple>
friend decltype(auto) get(Tuple&& t);
template<typename T, typename... UTypes>
friend decltype(auto) get_template_impl(const tuple<UTypes...>& t);
template<typename T, typename... UTypes>
friend decltype(auto) get_template_impl(tuple<UTypes...>& t);
template<typename T, typename... UTypes>
friend decltype(auto) get_template_impl(const tuple<UTypes...>&& t);
template<typename T, typename... UTypes>
friend decltype(auto) get_template_impl(tuple<UTypes...>&& t);
template<typename... UTypes>
friend class tuple_traits;
template<typename... UTypes>
friend class tuple;
template<typename FHead, typename... FTail, typename SHead, typename... STail>
friend bool operator==(const tuple<FHead, FTail...>& first, const tuple<SHead, STail...>& second);
template<typename FHead, typename... FTail, typename SHead, typename... STail>
friend std::partial_ordering operator<=>(const tuple<FHead, FTail...>& first, const tuple<SHead, STail...>& second);
};
template<typename FHead, typename... FTail, typename SHead, typename... STail>
bool operator==(const tuple<FHead, FTail...>& first, const tuple<SHead, STail...>& second) {
if constexpr(sizeof...(FTail) != sizeof...(STail)) {
return false;
} else {
using firstHeadType = typename std::remove_cvref_t<decltype(first.head_)>;
using secondHeadType = typename std::remove_cvref_t<decltype(second.head_)>;
static_assert(std::equality_comparable_with<firstHeadType, secondHeadType>);
if (first.head_ != second.head_) {
return false;
}
if constexpr (sizeof...(FTail) >= 0) {
return first.tail_ == second.tail_;
} else {
return true;
}
}
}
template<typename FHead, typename... FTail, typename SHead, typename... STail>
std::partial_ordering operator<=>(const tuple<FHead, FTail...>& first, const tuple<SHead, STail...>& second) {
if constexpr (sizeof...(FTail) != sizeof...(STail)) {
return std::partial_ordering::unordered;
} else {
using firstHeadType = typename std::remove_cvref_t<decltype(first.head_)>;
using secondHeadType = typename std::remove_cvref_t<decltype(second.head_)>;
static_assert(std::three_way_comparable_with<firstHeadType, secondHeadType>);
std::partial_ordering head_comp = (first.head_ <=> second.head_);
if (head_comp != std::partial_ordering::equivalent) {
return head_comp;
}
if constexpr (sizeof...(FTail) > 0) {
return first.tail_ <=> second.tail_;
} else {
return std::partial_ordering::equivalent;
}
}
}
template<typename... Types>
tuple(const Types& ... args) -> tuple<Types...>;
template<typename... Types>
tuple(Types&& ... args) -> tuple<Types...>;
template<typename T1, typename T2>
tuple(const std::pair<T1, T2>& pair) -> tuple<T1, T2>;
template<typename T1, typename T2>
tuple(std::pair<T1, T2>&& pair) -> tuple<T1, T2>;
template<size_t I, typename UHead, typename... UTail>
decltype(auto) get_impl(const tuple<UHead, UTail...> &tuple) {
return get<I - 1>(tuple.tail_);
}
template<size_t I, typename UHead, typename... UTail>
decltype(auto) get_impl(tuple<UHead, UTail...> &&tuple) {
return get<I - 1>(std::move(tuple.tail_));
}
template<size_t I, typename UHead, typename... UTail>
decltype(auto) get_impl(tuple<UHead, UTail...> &tuple) {
return get<I - 1>(tuple.tail_);
}
template<size_t I, typename UHead, typename... UTail>
decltype(auto) get_impl(const tuple<UHead, UTail...> &&tuple) {
return get<I - 1>(std::move(tuple.tail_));
}
template<size_t I, typename Tuple>
decltype(auto) get(Tuple&& tuple) {
constexpr bool is_const = std::is_const_v<std::remove_reference_t<Tuple>>;
constexpr bool is_lvalue = std::is_lvalue_reference_v<Tuple>;
if constexpr (I == 0) {
if constexpr (is_const && is_lvalue) {
return std::forward<const decltype(tuple.head_)&>(tuple.head_);
} else if constexpr (!is_const && is_lvalue){
return std::forward<decltype(tuple.head_)&>(tuple.head_);
} else if constexpr (is_const && !is_lvalue) {
return std::forward<const decltype(tuple.head_)&&>(tuple.head_);
} else {
static_assert(!is_const && !is_lvalue);
return std::forward<decltype(tuple.head_)&&>(tuple.head_);
}
} else {
return get_impl<I>(std::forward<Tuple>(tuple));
}
}
template<typename T, typename... Types>
decltype(auto) get_template_impl(const tuple<Types...>& tuple) {
return get<T>(tuple.tail_);
}
template<typename T, typename... Types>
decltype(auto) get_template_impl(tuple<Types...>& tuple) {
return get<T>(tuple.tail_);
}
template<typename T, typename... Types>
decltype(auto) get_template_impl(tuple<Types...>&& tuple) {
return get<T>(std::move(tuple.tail_));
}
template<typename T, typename... Types>
decltype(auto) get_template_impl(const tuple<Types...>&& tuple) {
return get<T>(std::move(tuple.tail_));
}
template<typename T, typename Tuple>
decltype(auto) get(Tuple&& tuple) {
static_assert(detail::tuple_cnt_type_T_v<T, std::remove_reference_t<Tuple>> == 1);
constexpr bool is_const = std::is_const_v<std::remove_reference_t<Tuple>>;
constexpr bool is_lvalue = std::is_lvalue_reference_v<Tuple>;
if constexpr (std::is_same_v<std::remove_reference_t<decltype(tuple.head_)>, T>) {
if constexpr (is_const && is_lvalue) {
return std::forward<const decltype(tuple.head_)&>(tuple.head_);
} else if constexpr (!is_const && is_lvalue){
return std::forward<decltype(tuple.head_)&>(tuple.head_);
} else if constexpr (is_const && !is_lvalue) {
return std::forward<const decltype(tuple.head_)&&>(tuple.head_);
} else {
static_assert(!is_const && !is_lvalue);
return std::forward<decltype(tuple.head_)&&>(tuple.head_);
}
} else {
return get_template_impl<T>(tuple);
}
}
template<>
class tuple<> {};
bool operator==(const tuple<>&, const tuple<>&) { return true; }
bool operator!=(const tuple<>&, const tuple<>&) { return false; }
std::partial_ordering operator<=>(const tuple<>&, const tuple<>&) { return std::partial_ordering::equivalent; }
template<typename Tuple>
struct tuple_size {};
template<typename Head, typename... Tail>
struct tuple_size<tuple<Head, Tail...>> {
static constexpr size_t value = 1 + tuple_size<tuple<Tail...>>::value;
};
template<>
struct tuple_size<tuple<>> {
static constexpr size_t value = 0;
};
template<typename... Types>
tuple<std::decay_t<Types>...> makeTuple(Types&&... args) {
return tuple<std::unwrap_ref_decay_t<Types>...>(std::forward<Types>(args)...);
}
template<typename... Types>
tuple<Types&...> tie(Types&... args) {
return tuple<Types&...>(args...);
}
template<typename... Types>
tuple<Types&&...> forwardAsTuple(Types&&... args) {
return tuple<Types&&...>(std::forward<Types>(args)...);
}
template<typename... Types>
struct CatTypes {};
template<typename... F, typename... S>
struct CatTypes<tuple<F...>, tuple<S...>> {
using type = tuple<F..., S...>;
};
template<typename T1, typename T2>
struct CatTypes<T1, T2> {
using type = typename CatTypes<std::remove_reference_t<T1>, std::remove_reference_t<T2>>::type;
};
template<typename T1, typename T2, typename... Other>
struct CatTypes<T1, T2, Other...> {
using type = CatTypes<typename CatTypes<T1, T2>::type, Other...>::type;
};
template<typename F, typename S, size_t... FIdx, size_t... SIdx>
auto catTwoTuplesHelper(F&& first, S&& second, std::index_sequence<FIdx...>, std::index_sequence<SIdx...>) -> CatTypes<F, S>::type {
return typename CatTypes<F, S>::type (get<FIdx>(std::forward<F>(first))... , get<SIdx>(std::forward<S>(second))...);
}
template<typename T1, typename T2>
auto catTwoTuples(T1&& first, T2&& second) -> CatTypes<T1, T2>::type {
std::make_index_sequence<tuple_size<std::remove_reference_t<T1>>::value> first_idx;
std::make_index_sequence<tuple_size<std::remove_reference_t<T2>>::value> second_idx;
return catTwoTuplesHelper(std::forward<T1>(first), std::forward<T2>(second), first_idx, second_idx);
}
template<typename T1, typename T2, typename... Other>
auto tupleCat(T1&& fir_tuple, T2&& sec_tuple, Other&&... other_tuples) -> CatTypes<T1, T2, Other...>::type {
typename CatTypes<T1, T2>::type merged = catTwoTuples(std::forward<T1>(fir_tuple), std::forward<T2>(sec_tuple));
if constexpr (sizeof...(Other) > 0) {
return tupleCat(std::move(merged), std::forward<Other>(other_tuples)...);
} else {
return merged;
}
}