.. _program_listing_file__tmp_ws_src_proxsuite_include_proxsuite_linalg_veg_util_defer.hpp: Program Listing for File defer.hpp ================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/proxsuite/include/proxsuite/linalg/veg/util/defer.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #ifndef VEG_DEFER_HPP_SQPONLRGS #define VEG_DEFER_HPP_SQPONLRGS #include "proxsuite/linalg/veg/type_traits/constructible.hpp" #include "proxsuite/linalg/veg/type_traits/invocable.hpp" #include "proxsuite/linalg/veg/internal/prologue.hpp" namespace proxsuite { namespace linalg { namespace veg { template struct VEG_NODISCARD Defer { Fn fn; constexpr Defer(Fn _fn) VEG_NOEXCEPT_IF(VEG_CONCEPT(nothrow_movable)) : fn(VEG_FWD(_fn)) { } Defer(Defer const&) = delete; Defer(Defer&&) VEG_NOEXCEPT = delete; auto operator=(Defer const&) -> Defer& = delete; auto operator=(Defer&&) VEG_NOEXCEPT->Defer& = delete; VEG_CPP20(constexpr) VEG_INLINE ~Defer() VEG_NOEXCEPT_IF(VEG_NOEXCEPT_IF(VEG_CONCEPT(nothrow_fn_once))) { VEG_FWD(fn)(); } }; VEG_CPP17( template Defer(Fn) -> Defer; ) namespace nb { struct defer { VEG_TEMPLATE(typename Fn, requires(VEG_CONCEPT(fn_once)), VEG_INLINE VEG_CPP20(constexpr) auto operator(), (fn, Fn&&)) const VEG_NOEXCEPT_IF(VEG_CONCEPT(nothrow_movable)) ->proxsuite::linalg::veg::Defer { return { VEG_FWD(fn) }; } }; } // namespace nb VEG_NIEBLOID(defer); } // namespace veg } // namespace linalg } // namespace proxsuite #include "proxsuite/linalg/veg/internal/epilogue.hpp" #endif /* end of include guard VEG_DEFER_HPP_SQPONLRGS */