Skip to content

Engine → Assets

asset_payload.h

Type erasure for published payloads. This is the only erasure in the module: asset types need no base class, no shared_ptr and no virtual call on the hot path.

Type Aliases

asset_payload

using asset_payload = std::unique_ptr<void, void (*)(void *)>;

An owned, type-erased payload: the object pointer plus the deleter that knows its type.

Functions

Public

detail::delete_nothing

inline void delete_nothing(void *) noexcept;

detail::delete_payload

template <typename ValueType> void delete_payload(void *object) noexcept;

make_null_payload

[[nodiscard]] inline asset_payload make_null_payload() noexcept;

A payload that owns nothing. Destroying it does nothing.

make_payload

template <typename ValueType> [[nodiscard]] asset_payload make_payload(
    ValueType &&value);

Moves (or copies) a value onto the heap and erases its type. The payload destroys the value through its real type.

payload_as

template <typename ValueType> [[nodiscard]] ValueType *payload_as(
    const asset_payload &payload) noexcept;

Views the payload as its real type. The caller must know the type (the slot's type id).