18namespace jsonv::detail
21template <
typename Function>
22class scope_exit_invoker
25 explicit scope_exit_invoker(Function&& func) :
26 _func(
std::move(func)),
30 scope_exit_invoker(scope_exit_invoker&& src)
noexcept(std::is_nothrow_move_constructible_v<Function>) :
31 _func(
std::move(src._func)),
32 _responsible(src._responsible)
34 src._responsible =
false;
37 scope_exit_invoker(
const scope_exit_invoker&) =
delete;
38 scope_exit_invoker& operator=(
const scope_exit_invoker&) =
delete;
39 scope_exit_invoker& operator=(scope_exit_invoker&&) =
delete;
57template <
typename Function>
59scope_exit_invoker<Function> on_scope_exit(Function func)
61 return scope_exit_invoker<Function>(std::move(func));
Copyright (c) 2014-2020 by Travis Gockel.
#define JSONV_NODISCARD
Warn if the caller discards the result of this function.