proxsuite
0.6.7
The Advanced Proximal Optimization Toolbox
Loading...
Searching...
No Matches
address.hpp
Go to the documentation of this file.
1
#ifndef VEG_ADDRESS_HPP_ZP6FDIHZS
2
#define VEG_ADDRESS_HPP_ZP6FDIHZS
3
4
#include "
proxsuite/linalg/veg/type_traits/core.hpp
"
5
#include "
proxsuite/linalg/veg/internal/std.hpp
"
6
#include "
proxsuite/linalg/veg/internal/prologue.hpp
"
7
8
#if !VEG_HAS_BUILTIN(__builtin_addressof)
9
10
// std::addressof
11
#if __VEG_HAS_INCLUDE(<bits / move.h>)
12
#include <bits/move.h>
13
#else
14
#include <memory>
15
#endif
16
#endif
17
18
namespace
proxsuite
{
19
namespace
linalg {
20
namespace
veg {
21
22
#if !(VEG_HAS_BUILTIN(__builtin_addressof) || defined(VEG_WITH_CXX17_SUPPORT))
23
24
namespace
_detail {
25
namespace
_mem {
26
struct
member_addr
27
{
28
template
<
typename
T>
29
using
type
=
decltype
(void(
VEG_DECLVAL
(T&).
operator
&()));
30
31
template
<
typename
T>
32
VEG_INLINE
static
auto
apply
(T&
var
)
VEG_NOEXCEPT
-> T*
33
{
34
using
char_ref
=
char
&;
35
return
static_cast<
T*
>
(
static_cast<
void
*
>
(&
char_ref
(
var
)));
36
}
37
};
38
struct
adl_addr
:
member_addr
39
{
40
template
<
typename
T>
41
using
type
=
decltype
(void(
operator
&(
VEG_DECLVAL
(T&))));
42
};
43
struct
builtin_addr
:
meta::true_type
44
{
45
template
<
typename
T>
46
VEG_INLINE
static
constexpr
auto
apply
(T&
var
)
VEG_NOEXCEPT
-> T*
47
{
48
return
&
var
;
49
}
50
};
51
template
<
typename
T>
52
struct
has_member_addr
53
:
meta::bool_constant
<VEG_CONCEPT(detected<member_addr::type, T&>)>
54
,
member_addr
55
{};
56
template
<
typename
T>
57
struct
has_adl_addr
58
:
meta::bool_constant
<VEG_CONCEPT(detected<adl_addr::type, T&>)>
59
,
adl_addr
60
{};
61
62
template
<
typename
T>
63
struct
addr_impl
64
:
meta::disjunction
<has_member_addr<T>, has_adl_addr<T>, builtin_addr>
65
{};
66
67
}
// namespace _mem
68
}
// namespace _detail
69
70
#endif
71
72
namespace
mem {
73
namespace
nb {
74
struct
addressof
75
{
76
template
<
typename
T>
77
VEG_INLINE
constexpr
auto
operator()
(T&&
var
)
const
78
VEG_NOEXCEPT
->meta::unref_t<T>*
79
{
80
#if VEG_HAS_BUILTIN(__builtin_addressof)
81
return
__builtin_addressof
(
var
);
82
#elif defined(VEG_WITH_CXX17_SUPPORT)
83
return ::std::addressof(
var
);
84
#else
85
return
_detail::_mem::addr_impl<T>::apply
(
var
);
86
#endif
87
}
88
};
89
}
// namespace nb
90
VEG_NIEBLOID
(addressof);
91
}
// namespace mem
92
}
// namespace veg
93
}
// namespace linalg
94
}
// namespace proxsuite
95
96
#include "
proxsuite/linalg/veg/internal/epilogue.hpp
"
97
#endif
/* end of include guard VEG_ADDRESS_HPP_ZP6FDIHZS */
epilogue.hpp
VEG_NIEBLOID
#define VEG_NIEBLOID(Name)
Definition
macros.hpp:545
VEG_INLINE
#define VEG_INLINE
Definition
macros.hpp:118
VEG_DECLVAL
#define VEG_DECLVAL(...)
Definition
macros.hpp:131
proxsuite
Definition
common.hpp:14
prologue.hpp
VEG_NOEXCEPT
#define VEG_NOEXCEPT
Definition
prologue.hpp:30
std.hpp
proxsuite::linalg::veg::Ref
Definition
ref.hpp:30
proxsuite::linalg::veg::_detail::_mem::addr_impl
Definition
address.hpp:65
proxsuite::linalg::veg::_detail::_mem::adl_addr
Definition
address.hpp:39
proxsuite::linalg::veg::_detail::_mem::builtin_addr
Definition
address.hpp:44
proxsuite::linalg::veg::_detail::_mem::builtin_addr::apply
static VEG_INLINE constexpr auto apply(T &var) VEG_NOEXCEPT -> T *
Definition
address.hpp:46
proxsuite::linalg::veg::_detail::_mem::has_adl_addr
Definition
address.hpp:60
proxsuite::linalg::veg::_detail::_mem::has_member_addr
Definition
address.hpp:55
proxsuite::linalg::veg::_detail::_mem::member_addr
Definition
address.hpp:27
proxsuite::linalg::veg::_detail::_mem::member_addr::apply
static VEG_INLINE auto apply(T &var) VEG_NOEXCEPT -> T *
Definition
address.hpp:32
proxsuite::linalg::veg::mem::nb::addressof
Definition
address.hpp:75
proxsuite::linalg::veg::mem::nb::addressof::operator()
VEG_INLINE constexpr auto operator()(T &&var) const VEG_NOEXCEPT -> meta::unref_t< T > *
Definition
address.hpp:77
proxsuite::linalg::veg::meta::constant
Definition
macros.hpp:894
proxsuite::linalg::veg::meta::disjunction
Definition
core.hpp:89
core.hpp
include
proxsuite
linalg
veg
memory
address.hpp
Generated by
1.10.0