3#include "plg/config.hpp"
6#if PLUGIFY_HAS_EXCEPTIONS
7 template <
class Rollback>
8 struct exception_guard_exceptions {
9 exception_guard_exceptions() =
delete;
11 constexpr explicit exception_guard_exceptions(Rollback rollback)
12 : rollback_(std::move(rollback))
16 constexpr exception_guard_exceptions(
17 exception_guard_exceptions&& other
18 )
noexcept(std::is_nothrow_move_constructible_v<Rollback>)
19 : rollback_(std::move(other.rollback_))
20 , completed_(other.completed_) {
21 other.completed_ =
true;
24 exception_guard_exceptions(
const exception_guard_exceptions&) =
delete;
25 exception_guard_exceptions& operator=(
const exception_guard_exceptions&) =
delete;
26 exception_guard_exceptions& operator=(exception_guard_exceptions&&) =
delete;
28 constexpr void complete() noexcept {
32 constexpr ~exception_guard_exceptions() {
39 PLUGIFY_NO_UNIQUE_ADDRESS Rollback rollback_;
43 template <
class Rollback>
44 using exception_guard = exception_guard_exceptions<Rollback>;
46 template <
class Rollback>
55 )
noexcept(std::is_nothrow_move_constructible_v<Rollback>)
56 : completed_(other.completed_) {
57 other.completed_ =
true;
64 constexpr void complete()
noexcept {
69 PLUGIFY_ASSERT(completed_,
"exception_guard not completed with exceptions disabled");
73 bool completed_ =
false;
76 template <
class Rollback>
80 template <
class Rollback>
87 PLUGIFY_NO_UNIQUE_ADDRESS
Func func_;
91 : func_(std::move(
func)) {
104 template <
class Func>