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
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
18namespace proxsuite {
19namespace linalg {
20namespace veg {
21
22#if !(VEG_HAS_BUILTIN(__builtin_addressof) || defined(VEG_WITH_CXX17_SUPPORT))
23
24namespace _detail {
25namespace _mem {
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};
39{
40 template<typename T>
41 using type = decltype(void(operator&(VEG_DECLVAL(T&))));
42};
44{
45 template<typename T>
46 VEG_INLINE static constexpr auto apply(T& var) VEG_NOEXCEPT -> T*
47 {
48 return &var;
49 }
50};
51template<typename T>
53 : meta::bool_constant<VEG_CONCEPT(detected<member_addr::type, T&>)>
55{};
56template<typename T>
58 : meta::bool_constant<VEG_CONCEPT(detected<adl_addr::type, T&>)>
59 , adl_addr
60{};
61
62template<typename T>
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
72namespace mem {
73namespace nb {
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)
82#elif defined(VEG_WITH_CXX17_SUPPORT)
83 return ::std::addressof(var);
84#else
86#endif
87 }
88};
89} // namespace nb
90VEG_NIEBLOID(addressof);
91} // namespace mem
92} // namespace veg
93} // namespace linalg
94} // namespace proxsuite
95
97#endif /* end of include guard VEG_ADDRESS_HPP_ZP6FDIHZS */
#define VEG_NIEBLOID(Name)
Definition macros.hpp:545
#define VEG_INLINE
Definition macros.hpp:118
#define VEG_DECLVAL(...)
Definition macros.hpp:131
#define VEG_NOEXCEPT
Definition prologue.hpp:30
static VEG_INLINE constexpr auto apply(T &var) VEG_NOEXCEPT -> T *
Definition address.hpp:46
static VEG_INLINE auto apply(T &var) VEG_NOEXCEPT -> T *
Definition address.hpp:32
VEG_INLINE constexpr auto operator()(T &&var) const VEG_NOEXCEPT -> meta::unref_t< T > *
Definition address.hpp:77