proxsuite 0.6.7
The Advanced Proximal Optimization Toolbox
Loading...
Searching...
No Matches
get.hpp
Go to the documentation of this file.
1#ifndef VEG_GET_HPP_QRS8GNSHS
2#define VEG_GET_HPP_QRS8GNSHS
3
6
7namespace proxsuite {
8namespace linalg {
9namespace veg {
10namespace meta {
11template<typename T>
14template<typename T, usize N>
16{};
17
18template<typename T>
19struct array_extent : constant<usize, 0>
20{};
21template<usize N, typename T>
22struct array_extent<T[N]> : constant<usize, N>
23{};
24} // namespace meta
25
26namespace _detail {
27namespace _meta {
28
29template<typename T>
30void
31get() = delete;
32
34{
35 template<typename I, typename T>
36 using result_type = decltype(VEG_DECLVAL(T&&)[I::value]);
37
38 template<usize I, typename T>
39 VEG_INLINE static constexpr auto apply(T&& arr)
40 VEG_NOEXCEPT -> decltype(VEG_FWD(arr)[I])
41 {
42 return VEG_FWD(arr)[I];
43 }
44};
45
47{
48 template<typename I, typename T>
49 using result_type = decltype(VEG_DECLVAL(T&&).template get<I::value>());
50 template<usize I, typename T>
51 VEG_INLINE static constexpr auto apply(T&& arg)
52 VEG_DEDUCE_RET(VEG_FWD(arg).template get<I>());
53};
54struct adl_get
55{
56 template<typename I, typename T>
57 using result_type = decltype(get<I::value>(VEG_DECLVAL(T&&)));
58
59 template<usize I, typename T>
60 VEG_INLINE static constexpr auto apply(T&& arg)
62};
63
65{
66 template<typename I, typename T>
67 using result_type = void;
68};
69
70template<typename I, typename T>
71using member_get_expr = decltype(VEG_DECLVAL(T&&).template get<I::value>());
72template<typename I, typename T>
73using adl_get_expr = decltype(get<I::value>(VEG_DECLVAL(T&&)));
74
75template<usize I, typename T>
77 : meta::bool_constant<meta::is_bounded_array<meta::uncvref_t<T>>::value>
78 , array_get
79{};
80
81template<usize I, typename T>
83 : bool_constant<VEG_CONCEPT(
84 detected<member_get::result_type, constant<usize, I>, T&&>)>
86{};
87template<usize I, typename T>
89 : bool_constant<VEG_CONCEPT(
90 detected<adl_get::result_type, constant<usize, I>, T&&>)>
91 , adl_get
92{};
93
94} // namespace _meta
95} // namespace _detail
96
97namespace concepts {
98namespace aux {
101} // namespace aux
103 (usize I, typename T),
105 ((aux::, bounded_array<uncvref_t<T>>),
106 (aux::, less_than<I, meta::array_extent<uncvref_t<T>>::value>)));
108 (usize I, typename T),
113 (usize I, typename T),
117
119 gettable,
122 (, adl_gettable<I, T>)));
123} // namespace concepts
124
125namespace nb {
126template<usize I>
127struct get
128{
130 (typename T,
135 requires(VEG_CONCEPT(gettable<I, T>)),
136 VEG_INLINE constexpr auto
137 operator(),
138 (arg, T&&))
139 const VEG_NOEXCEPT_IF(VEG_IS_NOEXCEPT(Impl::template apply<I>(VEG_FWD(arg))))
140 ->meta::detected_t<Impl::template result_type, meta::constant<usize, I>, T>
141 {
142 return Impl::template apply<I>(VEG_FWD(arg));
143 }
144};
145} // namespace nb
146
148} // namespace veg
149} // namespace linalg
150} // namespace proxsuite
151
153#endif /* end of include guard VEG_GET_HPP_QRS8GNSHS */
#define VEG_DEF_CONCEPT_DISJUNCTION(Tpl, Name, Terms)
Definition macros.hpp:367
#define VEG_CONCEPT(...)
Definition macros.hpp:1243
#define VEG_TEMPLATE(TParams, Constraint, Attr_Name,...)
Definition macros.hpp:385
#define VEG_NIEBLOID_TEMPLATE(Tpl, Name,...)
Definition macros.hpp:547
#define VEG_INLINE
Definition macros.hpp:118
#define VEG_FWD(X)
Definition macros.hpp:569
#define VEG_DEF_CONCEPT_CONJUNCTION(Tpl, Name, Terms)
Definition macros.hpp:360
#define VEG_DEDUCE_RET(...)
Definition macros.hpp:160
#define VEG_DECLVAL(...)
Definition macros.hpp:131
#define VEG_DEF_CONCEPT(Tpl, Name,...)
Definition macros.hpp:321
decltype(sizeof(0)) usize
Definition macros.hpp:702
#define VEG_NOEXCEPT
Definition prologue.hpp:30
#define VEG_IS_NOEXCEPT(Expr)
Definition prologue.hpp:32
#define VEG_NOEXCEPT_IF(...)
Definition prologue.hpp:31
static VEG_INLINE constexpr auto apply(T &&arg) VEG_DEDUCE_RET(get< I >(VEG_FWD(arg)))
decltype(VEG_DECLVAL(T &&)[I::value]) result_type
Definition get.hpp:36
static VEG_INLINE constexpr auto apply(T &&arr) VEG_NOEXCEPT -> decltype(VEG_FWD(arr)[I])
Definition get.hpp:39
static VEG_INLINE constexpr auto apply(T &&arg) VEG_DEDUCE_RET(VEG_FWD(arg).template get< I >())