proxsuite 0.6.7
The Advanced Proximal Optimization Toolbox
Loading...
Searching...
No Matches
alloc.hpp
Go to the documentation of this file.
1#ifndef VEG_ALLOC_HPP_QHYOV5XDS
2#define VEG_ALLOC_HPP_QHYOV5XDS
3
12#include <cstring>
13
14namespace proxsuite {
15namespace linalg {
16namespace veg {
17namespace mem {
18template<typename T>
19struct Alloc
20{};
21template<typename T>
22struct Cloner
23{};
24} // namespace mem
25namespace _detail {
26
27#if VEG_HAS_ASAN
28extern "C" void __sanitizer_annotate_contiguous_container /* NOLINT */ (
29 const void* begin,
30 const void* end,
31 const void* old_mid,
32 const void* new_mid);
33#endif
34
37[[noreturn]] inline void
39namespace _mem {
40struct DeferUnreachable /* NOLINT */
41{
44 {
45 if (is_unreachable) {
47 }
48 }
49};
50} // namespace _mem
51} // namespace _detail
52
53namespace mem {
54inline auto
55memmove(void* dest, void const* src, usize nbytes) noexcept -> void*
56{
57 if (dest != nullptr) {
58 return std::memmove(dest, src, nbytes);
59 } else {
60 return dest;
61 }
62}
63
64using byte = unsigned char;
66{
67 void* data;
69};
75struct RelocFn
76{
77 void* (*fn)(void*, void const*, usize);
78
79 VEG_INLINE void operator()(void* dst, void* src, usize n) const noexcept
80 {
82 (*fn)(dst, src, n);
83 _.is_unreachable = false;
84 }
86 {
87 return fn == &mem::memmove;
88 }
89};
90} // namespace mem
91namespace concepts {
92namespace alloc {
93VEG_CONCEPT_EXPR((typename A),
94 (A),
95 dealloc,
98 VEG_DECLVAL(void*),
100 true);
101
102VEG_CONCEPT_EXPR((typename A),
103 (A),
104 alloc,
108
109VEG_CONCEPT_EXPR((typename A),
110 (A),
115
116VEG_CONCEPT_EXPR((typename A),
117 (A),
118 grow,
120 VEG_DECLVAL(void*),
125
126VEG_CONCEPT_EXPR((typename A),
127 (A),
128 shrink,
130 VEG_DECLVAL(void*),
135
136VEG_CONCEPT_EXPR((typename C, typename T, typename A),
137 (C, T, A),
138 destroy,
141 VEG_DECLVAL(T*),
143 true);
144
145VEG_CONCEPT_EXPR((typename C, typename T, typename A),
146 (C, T, A),
147 clone,
153
154VEG_CONCEPT_EXPR((typename C, typename T, typename A),
155 (C, T, A),
156 clone_from,
161 true);
162} // namespace alloc
163} // namespace concepts
164} // namespace veg
165} // namespace linalg
166} // namespace proxsuite
167
169#endif /* end of include guard VEG_ALLOC_HPP_QHYOV5XDS */
#define HEDLEY_UNREACHABLE()
#define HEDLEY_NEVER_INLINE
#define VEG_CONCEPT_EXPR(Tpl, TplNames, Name, Expr,...)
Definition macros.hpp:272
#define VEG_CONCEPT(...)
Definition macros.hpp:1243
#define VEG_INLINE
Definition macros.hpp:118
#define VEG_DECLVAL(...)
Definition macros.hpp:131
HEDLEY_NEVER_INLINE void throw_bad_alloc()
auto memmove(void *dest, void const *src, usize nbytes) noexcept -> void *
Definition alloc.hpp:55
decltype(sizeof(0)) usize
Definition macros.hpp:702
void *(* fn)(void *, void const *, usize)
Definition alloc.hpp:77
VEG_INLINE void operator()(void *dst, void *src, usize n) const noexcept
Definition alloc.hpp:79
VEG_INLINE auto is_trivial() const noexcept -> bool
Definition alloc.hpp:85