proxsuite 0.7.1
The Advanced Proximal Optimization Toolbox
Loading...
Searching...
No Matches
defer.hpp
Go to the documentation of this file.
1#ifndef VEG_DEFER_HPP_SQPONLRGS
2#define VEG_DEFER_HPP_SQPONLRGS
3
7
8namespace proxsuite {
9namespace linalg {
10namespace veg {
11template<typename Fn>
13{
14 Fn fn;
15 constexpr Defer(Fn _fn) VEG_NOEXCEPT_IF(VEG_CONCEPT(nothrow_movable<Fn>))
16 : fn(VEG_FWD(_fn))
17 {
18 }
19 Defer(Defer const&) = delete;
21 auto operator=(Defer const&) -> Defer& = delete;
22 auto operator=(Defer&&) VEG_NOEXCEPT->Defer& = delete;
23 VEG_CPP20(constexpr)
25 VEG_NOEXCEPT_IF(VEG_NOEXCEPT_IF(VEG_CONCEPT(nothrow_fn_once<Fn, void>)))
26 {
27 VEG_FWD(fn)();
28 }
29};
31
32 template<typename Fn> Defer(Fn) -> Defer<Fn>;
33
34)
35
36namespace nb {
37struct defer
38{
39 VEG_TEMPLATE(typename Fn,
40 requires(VEG_CONCEPT(fn_once<Fn, void>)),
41 VEG_INLINE VEG_CPP20(constexpr) auto
42 operator(),
43 (fn, Fn&&))
44 const VEG_NOEXCEPT_IF(VEG_CONCEPT(nothrow_movable<Fn>))
45 ->proxsuite::linalg::veg::Defer<Fn>
46 {
47 return { VEG_FWD(fn) };
48 }
49};
50} // namespace nb
52} // namespace veg
53} // namespace linalg
54} // namespace proxsuite
55
57#endif /* end of include guard VEG_DEFER_HPP_SQPONLRGS */
#define VEG_CONCEPT(...)
Definition macros.hpp:1241
#define VEG_TEMPLATE(TParams, Constraint, Attr_Name,...)
Definition macros.hpp:385
#define VEG_NIEBLOID(Name)
Definition macros.hpp:545
#define VEG_INLINE
Definition macros.hpp:118
#define VEG_FWD(X)
Definition macros.hpp:569
#define VEG_CPP20(...)
Definition prologue.hpp:83
#define VEG_NODISCARD
Definition prologue.hpp:97
#define VEG_NOEXCEPT
Definition prologue.hpp:30
#define VEG_CPP17(...)
Definition prologue.hpp:77
#define VEG_NOEXCEPT_IF(...)
Definition prologue.hpp:31
Defer(Defer const &)=delete
constexpr Defer(Fn _fn) VEG_NOEXCEPT_IF(VEG_CONCEPT(nothrow_movable< Fn >))
Definition defer.hpp:15
Defer(Defer &&) VEG_NOEXCEPT=delete