27 #ifndef EASTL_FINALLY_H
28 #define EASTL_FINALLY_H
30 #if defined(EA_PRAGMA_ONCE_SUPPORTED)
34 #include <EASTL/internal/config.h>
35 #include <EASTL/internal/move_help.h>
36 #include <EASTL/type_traits.h>
45 template <
typename Functor>
48 static_assert(!eastl::is_lvalue_reference_v<Functor>,
"eastl::finally requires the callable is passed as an rvalue reference.");
51 bool m_engaged =
false;
54 finally(Functor f) : m_functor(
eastl::move(f)), m_engaged(
true) {}
56 finally(
finally&& other) : m_functor(
eastl::move(other.m_functor)), m_engaged(other.m_engaged)
63 finally(
const finally&) =
delete;
64 finally& operator=(
const finally&) =
delete;
65 finally& operator=(
finally&&) =
delete;
67 inline void dismiss() { m_engaged =
false; }
87 auto make_finally(F&& f)
EA Standard Template Library.
Definition: algorithm.h:288
OutputIterator move(InputIterator first, InputIterator last, OutputIterator result)
Definition: copy_help.h:170