Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
defer.hpp File Reference
#include <helios/compiler/compiler.hpp>
#include <helios/utils/macro.hpp>
#include <concepts>
#include <type_traits>
#include <utility>

Go to the source code of this file.

Classes

class  helios::utils::Defer< F >
 A utility class that defers the execution of a callable until the object goes out of scope. More...
struct  helios::utils::details::DeferHelper
 Helper struct for the HELIOS_DEFER macro to enable inline lambda syntax. More...

Namespaces

namespace  helios
namespace  helios::utils
namespace  helios::utils::details

Macros

#define HELIOS_DEFER
 Defers execution of an inline lambda until the end of the current scope.
#define HELIOS_DEFER_CALL(callable)
 Defers execution of a callable until the end of the current scope.

Macro Definition Documentation

◆ HELIOS_DEFER

#define HELIOS_DEFER
Value:
const auto HELIOS_CONCAT(_defer_, __COUNTER__) = \
::helios::utils::details::DeferHelper() + [&] HELIOS_ALWAYS_INLINE()
#define HELIOS_ALWAYS_INLINE
Definition compiler.hpp:44
#define HELIOS_CONCAT(a, b)
Definition macro.hpp:11

Defers execution of an inline lambda until the end of the current scope.

The lambda is written directly after the macro without explicit capture list.

int* ptr = new int(42);
delete ptr;
};
#define HELIOS_DEFER
Defers execution of an inline lambda until the end of the current scope.
Definition defer.hpp:82

Definition at line 82 of file defer.hpp.

◆ HELIOS_DEFER_CALL

#define HELIOS_DEFER_CALL ( callable)
Value:
const auto HELIOS_CONCAT(_defer_, __COUNTER__) = \
::helios::utils::Defer(callable)

Defers execution of a callable until the end of the current scope.

Accepts lambdas, functors, function pointers, and std::function objects.

auto cleanup = []() { std::cout << "Cleanup\n"; };
#define HELIOS_DEFER_CALL(callable)
Defers execution of a callable until the end of the current scope.
Definition defer.hpp:98

Definition at line 98 of file defer.hpp.