proxsuite
0.7.3
The Advanced Proximal Optimization Toolbox
Toggle main menu visibility
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
4
#include "
proxsuite/linalg/veg/type_traits/core.hpp
"
5
#include "
proxsuite/linalg/veg/internal/prologue.hpp
"
6
7
namespace
proxsuite
{
8
namespace
linalg
{
9
namespace
veg
{
10
namespace
meta
{
11
template
<
typename
T>
12
struct
is_bounded_array
:
false_type
13
{};
14
template
<
typename
T, usize N>
15
struct
is_bounded_array
<T[N]> :
true_type
16
{};
17
18
template
<
typename
T>
19
struct
array_extent
:
constant
<usize, 0>
20
{};
21
template
<usize N,
typename
T>
22
struct
array_extent
<T[N]> :
constant
<usize, N>
23
{};
24
}
// namespace meta
25
26
namespace
_detail
{
27
namespace
_meta {
28
29
template
<
typename
T>
30
void
31
get
() =
delete
;
32
33
struct
array_get
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)
VEG_NOEXCEPT
40
->
decltype
(
VEG_FWD
(arr)[I])
41
{
42
return
VEG_FWD
(arr)[I];
43
}
44
};
45
46
struct
member_get
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
};
54
struct
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)
61
VEG_DEDUCE_RET
(
get<I>
(
VEG_FWD
(arg)));
62
};
63
64
struct
none_found
:
true_type
65
{
66
template
<
typename
I,
typename
T>
67
using
result_type
= void;
68
};
69
70
template
<
typename
I,
typename
T>
71
using
member_get_expr
=
decltype
(
VEG_DECLVAL
(T&&).template
get<I::value>
());
72
template
<
typename
I,
typename
T>
73
using
adl_get_expr
=
decltype
(
get<I::value>
(
VEG_DECLVAL
(T&&)));
74
75
template
<usize I,
typename
T>
76
struct
has_array_get
77
:
meta::bool_constant
<meta::is_bounded_array<meta::uncvref_t<T>>::value>
78
,
array_get
79
{};
80
81
template
<usize I,
typename
T>
82
struct
has_member_get
83
:
bool_constant
<VEG_CONCEPT(
84
detected<member_get::result_type, constant<usize, I>, T&&>)>
85
,
member_get
86
{};
87
template
<usize I,
typename
T>
88
struct
has_adl_get
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
97
namespace
concepts
{
98
namespace
aux {
99
VEG_DEF_CONCEPT
((
usize
I,
usize
N), less_than, (I < N));
100
VEG_DEF_CONCEPT
(
typename
T, bounded_array,
meta::is_bounded_array<T>::value
);
101
}
// namespace aux
102
VEG_DEF_CONCEPT_CONJUNCTION
(
103
(
usize
I,
typename
T),
104
array_gettable,
105
((
aux
::, bounded_array<
uncvref_t<T>
>),
106
(
aux
::, less_than<I,
meta::array_extent
<
uncvref_t<T>
>::value>)));
107
VEG_DEF_CONCEPT
(
108
(
usize
I,
typename
T),
109
member_gettable,
110
VEG_CONCEPT
(
111
detected<
_detail::_meta::member_get_expr
,
meta::constant<usize, I>
, T>));
112
VEG_DEF_CONCEPT
(
113
(
usize
I,
typename
T),
114
adl_gettable,
115
VEG_CONCEPT
(
116
detected<
_detail::_meta::adl_get_expr
,
meta::constant<usize, I>
, T>));
117
118
VEG_DEF_CONCEPT_DISJUNCTION
((
usize
I,
typename
T),
119
gettable,
120
((, array_gettable<I, T>),
121
(, member_gettable<I, T>),
122
(, adl_gettable<I, T>)));
123
}
// namespace concepts
124
125
namespace
nb
{
126
template
<usize I>
127
struct
get
128
{
129
VEG_TEMPLATE
(
130
(
typename
T,
131
typename
Impl =
meta::disjunction
<
_detail::_meta::has_array_get<I, T>
,
132
_detail::_meta::has_member_get<I, T>
,
133
_detail::_meta::has_adl_get<I, T>
,
134
_detail::_meta::none_found
>),
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
147
VEG_NIEBLOID_TEMPLATE
(
usize
I, get, I);
148
}
// namespace veg
149
}
// namespace linalg
150
}
// namespace proxsuite
151
152
#include "
proxsuite/linalg/veg/internal/epilogue.hpp
"
153
#endif
/* end of include guard VEG_GET_HPP_QRS8GNSHS */
epilogue.hpp
VEG_DEF_CONCEPT_DISJUNCTION
#define VEG_DEF_CONCEPT_DISJUNCTION(Tpl, Name, Terms)
Definition
macros.hpp:367
VEG_CONCEPT
#define VEG_CONCEPT(...)
Definition
macros.hpp:1238
VEG_TEMPLATE
#define VEG_TEMPLATE(TParams, Constraint, Attr_Name,...)
Definition
macros.hpp:385
VEG_NIEBLOID_TEMPLATE
#define VEG_NIEBLOID_TEMPLATE(Tpl, Name,...)
Definition
macros.hpp:547
VEG_INLINE
#define VEG_INLINE
Definition
macros.hpp:118
VEG_FWD
#define VEG_FWD(X)
Definition
macros.hpp:569
VEG_DEF_CONCEPT_CONJUNCTION
#define VEG_DEF_CONCEPT_CONJUNCTION(Tpl, Name, Terms)
Definition
macros.hpp:360
VEG_DEDUCE_RET
#define VEG_DEDUCE_RET(...)
Definition
macros.hpp:160
VEG_DECLVAL
#define VEG_DECLVAL(...)
Definition
macros.hpp:131
VEG_DEF_CONCEPT
#define VEG_DEF_CONCEPT(Tpl, Name,...)
Definition
macros.hpp:321
proxsuite::linalg::veg::_detail::_meta::get
void get()=delete
proxsuite::linalg::veg::_detail::_meta::member_get_expr
decltype(VEG_DECLVAL(T &&).template get< I::value >()) member_get_expr
Definition
get.hpp:71
proxsuite::linalg::veg::_detail::_meta::adl_get_expr
decltype(get< I::value >(VEG_DECLVAL(T &&))) adl_get_expr
Definition
get.hpp:73
proxsuite::linalg::veg::_detail
Definition
collection_algo.hpp:11
proxsuite::linalg::veg::concepts::aux
Definition
primitives.hpp:16
proxsuite::linalg::veg::concepts
Definition
fix_index.hpp:51
proxsuite::linalg::veg::meta
Definition
integer_seq.hpp:11
proxsuite::linalg::veg::meta::uncvref_t
typename _detail::_meta::uncvlref< T & >::type uncvref_t
Definition
macros.hpp:884
proxsuite::linalg::veg::meta::bool_constant
constant< bool, B > bool_constant
Definition
macros.hpp:897
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::nb
Definition
macros.hpp:687
proxsuite::linalg::veg
Definition
collection_algo.hpp:10
proxsuite::linalg::veg::usize
decltype(sizeof(0)) usize
Definition
macros.hpp:699
proxsuite::linalg
Definition
core.hpp:85
proxsuite
Definition
common.hpp:14
prologue.hpp
VEG_NOEXCEPT
#define VEG_NOEXCEPT
Definition
prologue.hpp:30
VEG_IS_NOEXCEPT
#define VEG_IS_NOEXCEPT(Expr)
Definition
prologue.hpp:32
VEG_NOEXCEPT_IF
#define VEG_NOEXCEPT_IF(...)
Definition
prologue.hpp:31
proxsuite::linalg::veg::_detail::_meta::adl_get
Definition
get.hpp:55
proxsuite::linalg::veg::_detail::_meta::adl_get::apply
static VEG_INLINE constexpr auto apply(T &&arg) VEG_DEDUCE_RET(get< I >(VEG_FWD(arg)))
proxsuite::linalg::veg::_detail::_meta::adl_get::result_type
decltype(get< I::value >(VEG_DECLVAL(T &&))) result_type
Definition
get.hpp:57
proxsuite::linalg::veg::_detail::_meta::array_get
Definition
get.hpp:34
proxsuite::linalg::veg::_detail::_meta::array_get::result_type
decltype(VEG_DECLVAL(T &&)[I::value]) result_type
Definition
get.hpp:36
proxsuite::linalg::veg::_detail::_meta::array_get::apply
static VEG_INLINE constexpr auto apply(T &&arr) VEG_NOEXCEPT -> decltype(VEG_FWD(arr)[I])
Definition
get.hpp:39
proxsuite::linalg::veg::_detail::_meta::has_adl_get
Definition
get.hpp:92
proxsuite::linalg::veg::_detail::_meta::has_array_get
Definition
get.hpp:79
proxsuite::linalg::veg::_detail::_meta::has_member_get
Definition
get.hpp:86
proxsuite::linalg::veg::_detail::_meta::member_get
Definition
get.hpp:47
proxsuite::linalg::veg::_detail::_meta::member_get::result_type
decltype(VEG_DECLVAL(T &&).template get< I::value >()) result_type
Definition
get.hpp:49
proxsuite::linalg::veg::_detail::_meta::member_get::apply
static VEG_INLINE constexpr auto apply(T &&arg) VEG_DEDUCE_RET(VEG_FWD(arg).template get< I >())
proxsuite::linalg::veg::_detail::_meta::none_found
Definition
get.hpp:65
proxsuite::linalg::veg::_detail::_meta::none_found::result_type
void result_type
Definition
get.hpp:67
proxsuite::linalg::veg::meta::array_extent
Definition
get.hpp:20
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::disjunction
Definition
core.hpp:89
proxsuite::linalg::veg::meta::is_bounded_array
Definition
get.hpp:13
proxsuite::linalg::veg::nb::get
Definition
get.hpp:128
core.hpp
include
proxsuite
linalg
veg
util
get.hpp
Generated by
1.17.0