rcpputils
master
C++ API providing common utilities and data structures.
|
Go to the documentation of this file.
15 #ifndef RCPPUTILS__SCOPE_EXIT_HPP_
16 #define RCPPUTILS__SCOPE_EXIT_HPP_
20 #include "rcutils/macros.h"
25 template<
typename CallableT>
29 : callable_(
std::forward<CallableT>(callable))
53 bool cancelled_{
false};
56 template<
typename CallableT>
65 #define RCPPUTILS_SCOPE_EXIT(code) \
66 auto RCUTILS_JOIN(scope_exit_, __LINE__) = rcpputils::make_scope_exit([&]() {code;})
68 #endif // RCPPUTILS__SCOPE_EXIT_HPP_
scope_exit< CallableT > make_scope_exit(CallableT &&callable)
Definition: scope_exit.hpp:58
Definition: asserts.hpp:37
void cancel()
Definition: scope_exit.hpp:46
~scope_exit()
Definition: scope_exit.hpp:39
scope_exit(CallableT &&callable)
Definition: scope_exit.hpp:28
scope_exit & operator=(const scope_exit &)=delete
Definition: scope_exit.hpp:26