1#ifndef VEG_TUPLE_HPP_B8PHUNWES
2#define VEG_TUPLE_HPP_B8PHUNWES
11#if defined(__GLIBCXX__)
13_GLIBCXX_BEGIN_NAMESPACE_VERSION
16template<::proxsuite::linalg::veg::usize,
typename T>
18_GLIBCXX_END_NAMESPACE_VERSION
25#define __VEG_IMPL_BIND(I, Tuple, Identifier) \
27 ::proxsuite::linalg::veg::nb::get<I>{}(VEG_FWD(Tuple));
29#define __VEG_IMPL_BIND_ID_SEQ( \
35 CV_Auto TupleId = Tuple; \
37 ::std::tuple_size<typename ::proxsuite::linalg::veg::meta::uncvref_t< \
38 decltype(TupleId)>>::value == (Tuple_Size), \
39 "wrong number of identifiers"); \
40 __VEG_PP_TUPLE_FOR_EACH_I(__VEG_IMPL_BIND, TupleId, Identifiers) \
53#define VEG_BIND(CV_Auto, Identifiers, Tuple) \
54 __VEG_IMPL_BIND_ID_SEQ(CV_Auto, \
57 __VEG_PP_TUPLE_SIZE(Identifiers), \
58 __VEG_PP_CAT(_dummy_tuple_variable_id_, __LINE__))
64template<
typename T, usize I>
67template<
typename... Ts>
74 template<
typename... Ts>
85inline namespace tags {
95template<
typename ISeq,
typename... Ts>
99#if VEG_HAS_NO_UNIQUE_ADDRESS
100#define __VEG_IMPL_LEAF(Tuple, I, ...) \
102 ::proxsuite::linalg::veg::tuple::TupleLeaf<I, __VA_ARGS__> const&>( \
105#define __VEG_IMPL_LEAF_MUT(Tuple, I, ...) \
106 (static_cast<::proxsuite::linalg::veg::tuple::TupleLeaf<I, __VA_ARGS__>&>( \
109#define __VEG_IMPL_LEAF_ONCE(Tuple, I, ...) \
110 (static_cast<__VA_ARGS__&&>( \
111 static_cast<::proxsuite::linalg::veg::tuple::TupleLeaf<I, __VA_ARGS__>&&>( \
115template<usize I,
typename T>
122#define __VEG_IMPL_LEAF(Tuple, I, ...) \
123 (static_cast<__VA_ARGS__ const&>( \
125 ::proxsuite::linalg::veg::tuple::TupleLeaf<I, __VA_ARGS__> const&>( \
129#define __VEG_IMPL_LEAF_MUT(Tuple, I, ...) \
130 (static_cast<::proxsuite::linalg::veg::tuple::TupleLeaf<I, __VA_ARGS__>&>( \
134#define __VEG_IMPL_LEAF_ONCE(Tuple, I, ...) \
135 (static_cast<__VA_ARGS__&&>( \
136 static_cast<::proxsuite::linalg::veg::tuple::TupleLeaf<I, __VA_ARGS__>&&>( \
140template<
typename T,
bool = (VEG_CONCEPT(empty<T>) && !VEG_CONCEPT(final<T>))>
146 template<
typename Fn>
155 return const_cast<T&
>(
static_cast<T
const&
>(*this));
163 template<
typename Fn>
173 return const_cast<T&
>(leaf);
177template<usize I,
typename T>
188 (
typename Fn,
typename... Ts,
usize... Is),
204 ->proxsuite::linalg::veg::meta::invoke_result_t<
Fn, Ts&&...>
232 (
typename Fn,
typename... Ts,
usize... Is),
249 (
typename Fn,
typename... Ts,
usize...
Is),
280 (
typename Fn,
typename... Ts,
usize... Is),
309template<
usize... Is,
typename... Ts>
314#if !defined(VEG_WITH_CXX17_SUPPORT)
315#if VEG_HAS_NO_UNIQUE_ADDRESS
316 template<
typename...
Fns>
323 template<
typename...
Fns>
338#if !defined(VEG_WITH_CXX17_SUPPORT)
342#if VEG_HAS_NO_UNIQUE_ADDRESS
361#if !defined(VEG_WITH_CXX17_SUPPORT)
365#if VEG_HAS_NO_UNIQUE_ADDRESS
398 requires(
static_cast<usize>(I) <
sizeof...(Ts)),
407 *
this,
static_cast<usize>(I),
ith<
static_cast<usize>(I), Ts...>);
411 requires(
static_cast<usize>(I) <
sizeof...(Ts)),
422 requires(
static_cast<usize>(I) <
sizeof...(Ts)),
439 static constexpr bool is_tuple =
false;
446template<
typename... Ts>
449 static constexpr bool is_tuple =
true;
450 static constexpr usize size =
sizeof...(Ts);
462 template<
usize... Is,
typename... Ts>
470template<
usize... Is,
typename... Ts>
482 decltype(_detail::meta_::is_tuple_helper::test(
static_cast<T*
>(
nullptr)));
491template<usize I,
typename T>
505template<
typename... Ts>
513 using Indexed::Indexed;
541 return static_cast<ith<I, Ts...
> const&&>(
556template<
usize... Is,
typename... Ts>
562 ((void)(
tup), tuplify),
585 ->proxsuite::linalg::veg::Tuple<
595 template<
typename...
Tuples>
599 template<
typename...
Tuples>
600 using Zip = proxsuite::linalg::veg::meta::
601 detected_t<PreZip, typename meta::TupleBaseInfo<Tuples>::Tuple...>;
618 template<
typename...
Tuples>
625 template<
typename...
Tuples>
630 return zip::from_ref_to_result(
634 zip::apply(_detail::_tuple::tuple_fwd(
VEG_FWD(
tups))...));
639 template<usize I,
typename T>
642 template<
typename... Ts>
643 using Type = Tuple<T, meta::tuple_element<I, Ts>...>;
645 template<
typename... Ts>
658 template<usize... Is,
typename... Ts,
typename... Tuples>
663 typename Helper<Is, Ts>::
664 template Type<Tuples...>...>
667 ((void)first, tuplify{}),
669 .template apply<Tuples...>(
VEG_FWD(rest)...)...,
673 template<
typename ISeq,
typename... InnerTargets>
674 struct ConverterImpl;
675 template<
typename OuterTarget>
678 template<usize... Is,
typename... InnerTargets>
679 struct ConverterImpl<
proxsuite::linalg::veg::meta::index_sequence<Is...>,
683 InnerTargets&&...>&& refs;
691 _detail::MoveFn<InnerTargets>{
697 template<
typename... InnerTargets>
698 struct Converter<Tuple<InnerTargets...>>
706 template<usize... Is,
typename... Tups,
typename... OuterTargets>
707 VEG_INLINE static constexpr auto from_ref_to_result(
708 Tag<Tuple<OuterTargets...>> ,
713 ((void)zipped_refs, inplace[tuplify{}]),
714 typename Converter<OuterTargets>::Type{
724 template<
typename...
Tuples>
727 template<
typename...
Tuples>
728 using Concat = proxsuite::linalg::veg::meta::
729 detected_t<PreConcat, typename meta::TupleBaseInfo<Tuples>::Tuple...>;
744 template<
typename...
Tuples>
752 template<
typename...
Tuples>
757 return cat::template from_ref_to_result(
759 cat::apply(_detail::_tuple::tuple_fwd(
VEG_FWD(
tups))...));
762 template<
typename... Targets, usize... Is,
typename... Refs>
763 VEG_INLINE static constexpr auto from_ref_to_result(
764 Tag<Tuple<Targets...>> ,
776 template<usize... Is,
typename... Ts,
typename... Tuples>
784 typename _detail::meta_::IndexedToTuple<Tuples>::Type...>
789 template<usize... Is,
typename... Ts, usize... Js,
typename... Us>
807 (
typename... Ts,
typename...
Us,
usize... Is),
841template<
usize... Is,
typename... Ts>
843 tuple::IndexedTuple<meta::index_sequence<Is...>, Ts...>>
846template<
usize... Is,
typename... Ts>
848 tuple::IndexedTuple<meta::index_sequence<Is...>, Ts...>>
852template<
typename... Ts>
856template<
typename... Ts>
865template<
typename... Ts>
866struct std::tuple_size<
proxsuite::linalg::veg::Tuple<Ts...>>
871struct std::tuple_element<I,
proxsuite::linalg::veg::Tuple<Ts...>>
#define VEG_EVAL_ALL(...)
#define VEG_NIEBLOID(Name)
#define VEG_NO_UNIQUE_ADDRESS
#define VEG_DEF_CONCEPT(Tpl, Name,...)
static VEG_INLINE constexpr auto tuple_fwd(tuple::IndexedTuple< meta::index_sequence< Is... >, Ts... > &&tup) VEG_NOEXCEPT -> Tuple< Ts &&... >
VEG_NODISCARD VEG_INLINE constexpr auto get(tuple::IndexedTuple< proxsuite::linalg::veg::meta::index_sequence< Is... >, Ts... > const &tup) VEG_NOEXCEPT -> ith< I, Ts... > const &
typename _detail::pack_ith_elem< I >::template Type< Ts... > ith
_detail::_meta::make_signed< usize >::Type isize
decltype(sizeof(0)) usize
#define VEG_NOEXCEPT_LIKE(Expr)
#define VEG_NOEXCEPT_IF(...)
VEG_INLINE constexpr auto leaf_get() const VEG_NOEXCEPT -> T &
VEG_INLINE constexpr TupleLeafImpl(InPlace< void >, Fn fn) VEG_NOEXCEPT_LIKE(VEG_FWD(fn)())
VEG_INLINE constexpr TupleLeafImpl(InPlace< void >, Fn fn) VEG_NOEXCEPT_LIKE(VEG_FWD(fn)())
VEG_INLINE constexpr auto leaf_get() const VEG_NOEXCEPT -> T &
VEG_TEMPLATE((typename... Tuples), requires(VEG_ALL_OF(VEG_CONCEPT(tuple::tuple< Tuples >))), VEG_NODISCARD VEG_INLINE constexpr auto operator(),(... tups, Tuples)) const VEG_NOEXCEPT -> Concat< Tuples... >
proxsuite::linalg::veg::meta::type_sequence_cat< Tuple, Tuples... > PreConcat
proxsuite::linalg::veg::meta:: detected_t< PreConcat, typename meta::TupleBaseInfo< Tuples >::Tuple... > Concat
VEG_TEMPLATE((typename... Ts, typename... Us, usize... Is), requires(VEG_ALL_OF(VEG_CONCEPT(assignable< Ts &, Us const & >))), VEG_INLINE VEG_CPP14(constexpr) void operator(),(ts, IndexedTuple< proxsuite::linalg::veg::meta::index_sequence< Is... >, RefMut< Ts >... >),(us, IndexedTuple< proxsuite::linalg::veg::meta::index_sequence< Is... >, Ref< Us >... >)) const VEG_NOEXCEPT_IF(VEG_ALL_OF(VEG_CONCEPT(nothrow_assignable< Ts &
VEG_TEMPLATE((typename Fn, typename... Ts, usize... Is), requires(VEG_ALL_OF(VEG_CONCEPT(fn_once< inner_ith< Fn &, Is >, void, Ts >))), VEG_INLINE VEG_CPP14(constexpr) void operator(),(args, IndexedTuple< proxsuite::linalg::veg::meta::index_sequence< Is... >, Ts... > &&),(fn, Fn)) const VEG_NOEXCEPT_IF(VEG_ALL_OF(VEG_CONCEPT(nothrow_fn_once< inner_ith< Fn
VEG_TEMPLATE((typename Fn, typename... Ts, usize... Is), requires(VEG_ALL_OF(VEG_CONCEPT(fn_mut< Fn, void, Ts && >))), VEG_INLINE VEG_CPP14(constexpr) void operator(),(args, IndexedTuple< proxsuite::linalg::veg::meta::index_sequence< Is... >, Ts... > &&),(fn, Fn)) const VEG_NOEXCEPT_IF(VEG_ALL_OF(VEG_CONCEPT(nothrow_fn_mut< Fn
VEG_TEMPLATE((typename Fn, typename... Ts, usize... Is), requires(VEG_ALL_OF(VEG_CONCEPT(fn_once< inner_ith< Fn &, Is >, proxsuite::linalg::veg::meta::invoke_result_t< inner_ith< Fn &, Is >, Ts >, Ts >))), VEG_NODISCARD VEG_INLINE VEG_CPP14(constexpr) auto operator(),(args, IndexedTuple< proxsuite::linalg::veg::meta::index_sequence< Is... >, Ts... > &&),(fn, Fn)) const VEG_NOEXCEPT_IF(VEG_ALL_OF(VEG_CONCEPT(nothrow_fn_once< inner_ith< Fn &
VEG_TEMPLATE((typename Fn, typename... Ts, usize... Is), requires(VEG_ALL_OF(VEG_CONCEPT(fn_mut< Fn, proxsuite::linalg::veg::meta::invoke_result_t< Fn &, Ts && >, Ts && >))), VEG_NODISCARD VEG_INLINE VEG_CPP14(constexpr) auto operator(),(args, IndexedTuple< proxsuite::linalg::veg::meta::index_sequence< Is... >, Ts... > &&),(fn, Fn)) const VEG_NOEXCEPT_IF(VEG_ALL_OF(VEG_CONCEPT(nothrow_fn_mut< Fn
VEG_NODISCARD VEG_INLINE constexpr auto operator()(Ts... args) const VEG_NOEXCEPT -> proxsuite::linalg::veg::Tuple< Ts... >
VEG_TEMPLATE((typename Fn, typename... Ts, usize... Is), requires(VEG_CONCEPT(fn_once< Fn, proxsuite::linalg::veg::meta::invoke_result_t< Fn, Ts &&... >, Ts &&... >)), VEG_INLINE constexpr auto operator(),(args, IndexedTuple< proxsuite::linalg::veg::meta::index_sequence< Is... >, Ts... > &&),(fn, Fn)) const VEG_NOEXCEPT_IF(VEG_CONCEPT(nothrow_fn_once< Fn
VEG_TEMPLATE(typename... Fns, requires(VEG_ALL_OF(VEG_CONCEPT(fn_once< Fns, proxsuite::linalg::veg::meta::invoke_result_t< Fns > >))), VEG_NODISCARD VEG_INLINE constexpr auto operator(),(... args, Fns)) const VEG_NOEXCEPT_IF(VEG_ALL_OF(VEG_CONCEPT(nothrow_fn_once< Fns
proxsuite::linalg::veg::meta::type_sequence_zip< Tuple, Tuples... > PreZip
VEG_TEMPLATE((typename... Tuples), requires(VEG_ALL_OF(VEG_CONCEPT(tuple::tuple< Tuples >)) &&VEG_CONCEPT(all_same< tuple::meta::tuple_size< Tuples >... >)), VEG_NODISCARD VEG_INLINE constexpr auto operator(),(... tups, Tuples)) const VEG_NOEXCEPT -> Zip< Tuples... >
proxsuite::linalg::veg::meta:: detected_t< PreZip, typename meta::TupleBaseInfo< Tuples >::Tuple... > Zip
#define __VEG_IMPL_LEAF_ONCE(Tuple, I,...)
#define __VEG_IMPL_LEAF_MUT(Tuple, I,...)
#define __VEG_IMPL_LEAF(Tuple, I,...)