Struct meta_handle
Synopsis
#include <src/entt/meta/meta.hpp>
struct meta_handle
Description
Opaque pointers to instances of any type.
A handle doesn't perform copies and isn't responsible for the contained object. It doesn't prolong the lifetime of the pointed instance.
Handles are used to generate meta references to actual objects when needed.
Methods
meta_handle overload | Default constructor. | |
meta_handle overload | Creates a handle that points to an unmanaged object. | |
operator* | Dereference operator for accessing the contained opaque object. | |
operator-> overload | Access operator for accessing the contained opaque object. |
Source
Lines 574-620 in src/entt/meta/meta.hpp.
struct meta_handle {
/*! @brief Default constructor. */
meta_handle() = default;
/**
* @brief Creates a handle that points to an unmanaged object.
* @tparam Type Type of object to use to initialize the handle.
* @param value An instance of an object to use to initialize the handle.
*/
template<typename Type, typename = std::enable_if_t<!std::is_same_v<std::remove_cv_t<std::remove_reference_t<Type>>, meta_handle>>>
meta_handle(Type &value) ENTT_NOEXCEPT
: meta_handle{}
{
if constexpr(std::is_same_v<std::remove_cv_t<std::remove_reference_t<Type>>, meta_any>) {
any = as_ref(value);
} else {
any = std::reference_wrapper{value};
}
}
/**
* @brief Dereference operator for accessing the contained opaque object.
* @return A meta any that shares a reference to an unmanaged object.
*/
[[nodiscard]] meta_any operator*() const {
return any;
}
/**
* @brief Access operator for accessing the contained opaque object.
* @return A meta any that shares a reference to an unmanaged object.
*/
[[nodiscard]] meta_any * operator->() {
return &any;
}
/**
* @brief Access operator for accessing the contained opaque object.
* @return A meta any that shares a reference to an unmanaged object.
*/
[[nodiscard]] const meta_any * operator->() const {
return &any;
}
private:
meta_any any;
};