proxsuite
0.6.7
The Advanced Proximal Optimization Toolbox
Loading...
Searching...
No Matches
collection_algo.hpp
Go to the documentation of this file.
1
#ifndef VEG_CONTAINER_ALGOS_HPP_SGBCMQAYS
2
#define VEG_CONTAINER_ALGOS_HPP_SGBCMQAYS
3
4
#include "
proxsuite/linalg/veg/memory/alloc.hpp
"
5
#include "
proxsuite/linalg/veg/util/defer.hpp
"
6
#include "
proxsuite/linalg/veg/internal/prologue.hpp
"
7
8
namespace
proxsuite
{
9
namespace
linalg {
10
namespace
veg {
11
namespace
_detail {
12
namespace
_collections {
13
template
<
bool
IsNoExcept>
14
struct
DestroyImpl
;
15
16
template
<>
17
struct
DestroyImpl
<
true
>
18
{
19
template
<
typename
T,
typename
A,
typename
C>
20
VEG_INLINE
static
VEG_CPP14
(
constexpr
) void fn(
RefMut
<A> alloc,
21
RefMut
<C> cloner,
22
T* ptr,
23
T* ptr_end)
VEG_NOEXCEPT
24
{
25
while
(
true
) {
26
if
(ptr_end <= ptr) {
27
break
;
28
}
29
--ptr_end;
30
mem::Cloner<C>::destroy
(
//
31
RefMut<C>
(cloner),
32
static_cast<
T*
>
(ptr_end),
33
RefMut<A>
(alloc));
34
}
35
}
36
};
37
38
template
<
typename
T,
typename
A,
typename
C>
39
struct
Cleanup
40
{
41
RefMut<A>
alloc
;
42
RefMut<C>
cloner
;
43
T*
ptr
;
44
T*
ptr_end
;
45
46
VEG_CPP14
(
constexpr
) void
operator
()()
noexcept
47
{
48
DestroyImpl<true>::fn
(
alloc
,
cloner
,
ptr
,
ptr_end
);
49
}
50
};
51
52
template
<>
53
struct
DestroyImpl
<
false
>
54
{
55
template
<
typename
T,
typename
A,
typename
C>
56
VEG_INLINE
static
VEG_CPP20
(
constexpr
) void fn(
RefMut
<A> alloc,
57
RefMut
<C> cloner,
58
T* ptr,
59
T* ptr_end)
60
VEG_NOEXCEPT_IF
(
false
)
61
{
62
63
Defer<Cleanup<T, A, C>
> _{ { alloc, cloner, ptr, ptr_end } };
64
65
while
(
true
) {
66
if
(_.fn.ptr_end <= _.fn.ptr) {
67
break
;
68
}
69
--_.fn.ptr_end;
70
mem::Cloner<C>::destroy
(
//
71
RefMut<C>
(_.fn.cloner),
72
static_cast<
T*
>
(_.fn.ptr_end),
73
RefMut<A>
(_.fn.alloc));
74
}
75
}
76
};
77
78
template
<
typename
T,
typename
A,
typename
C>
79
VEG_CPP14
(
constexpr
)
80
void
backward_destroy
(
RefMut
<A> alloc,
RefMut
<C> cloner, T* ptr, T* ptr_end)
81
VEG_NOEXCEPT_IF
(
VEG_CONCEPT
(alloc::
nothrow_destroy
<C, T, A>))
82
{
83
DestroyImpl
<
VEG_CONCEPT
(alloc::nothrow_destroy<C, T, A>)>::fn(
84
alloc, cloner, ptr, ptr_end);
85
}
86
}
// namespace _collections
87
}
// namespace _detail
88
}
// namespace veg
89
}
// namespace linalg
90
}
// namespace proxsuite
91
92
#include "
proxsuite/linalg/veg/internal/epilogue.hpp
"
93
#endif
/* end of include guard VEG_CONTAINER_ALGOS_HPP_SGBCMQAYS */
defer.hpp
epilogue.hpp
VEG_CONCEPT
#define VEG_CONCEPT(...)
Definition
macros.hpp:1243
VEG_INLINE
#define VEG_INLINE
Definition
macros.hpp:118
alloc.hpp
proxsuite::linalg::veg::_detail::_collections::backward_destroy
void backward_destroy(RefMut< A > alloc, RefMut< C > cloner, T *ptr, T *ptr_end)
Definition
collection_algo.hpp:80
proxsuite
Definition
common.hpp:14
prologue.hpp
VEG_NOEXCEPT
#define VEG_NOEXCEPT
Definition
prologue.hpp:30
VEG_CPP14
#define VEG_CPP14(...)
Definition
prologue.hpp:71
VEG_NOEXCEPT_IF
#define VEG_NOEXCEPT_IF(...)
Definition
prologue.hpp:31
proxsuite::linalg::veg::RefMut
Definition
ref.hpp:68
proxsuite::linalg::veg::Ref
Definition
ref.hpp:30
proxsuite::linalg::veg::_detail::_collections::Cleanup
Definition
collection_algo.hpp:40
proxsuite::linalg::veg::_detail::_collections::Cleanup::alloc
RefMut< A > alloc
Definition
collection_algo.hpp:41
proxsuite::linalg::veg::_detail::_collections::Cleanup::ptr_end
T * ptr_end
Definition
collection_algo.hpp:44
proxsuite::linalg::veg::_detail::_collections::Cleanup::VEG_CPP14
VEG_CPP14(constexpr) void operator()() noexcept
Definition
collection_algo.hpp:46
proxsuite::linalg::veg::_detail::_collections::Cleanup::cloner
RefMut< C > cloner
Definition
collection_algo.hpp:42
proxsuite::linalg::veg::_detail::_collections::Cleanup::ptr
T * ptr
Definition
collection_algo.hpp:43
proxsuite::linalg::veg::_detail::_collections::DestroyImpl< false >::VEG_CPP20
static VEG_INLINE VEG_CPP20(constexpr) void fn(RefMut< A > alloc
proxsuite::linalg::veg::_detail::_collections::DestroyImpl< true >::VEG_CPP14
static VEG_INLINE VEG_CPP14(constexpr) void fn(RefMut< A > alloc
proxsuite::linalg::veg::_detail::_collections::DestroyImpl
Definition
collection_algo.hpp:14
proxsuite::linalg::veg::mem::Cloner
Definition
alloc.hpp:23
include
proxsuite
linalg
veg
internal
collection_algo.hpp
Generated by
1.10.0