meta: added meta context object

This commit is contained in:
Michele Caini
2019-10-07 22:40:41 +02:00
parent 0303facfd9
commit faf7e28119

View File

@@ -318,7 +318,7 @@ class meta_any {
template<typename Type>
static Type * release(Type *instance) {
auto * const node = internal::meta_info<Type>::resolve();
const auto * const node = internal::meta_info<Type>::resolve();
[[maybe_unused]] const bool destroyed = (!node->dtor || node->dtor->invoke(*instance));
ENTT_ASSERT(destroyed);
return instance;
@@ -1748,6 +1748,43 @@ private:
};
/*! @brief Opaque container for a meta context. */
class meta_ctx {
auto ctx() const ENTT_NOEXCEPT {
return &internal::meta_info<>::local;
}
public:
/*! @brief Default constructor. */
meta_ctx() ENTT_NOEXCEPT = default;
/*! @brief Default copy constructor, deleted on purpose. */
meta_ctx(const meta_ctx &) = delete;
/*! @brief Default move constructor, deleted on purpose. */
meta_ctx(meta_ctx &&) = delete;
/**
* @brief Copy assignment operator.
* @param other The instance to copy from.
* @return This meta object.
*/
meta_ctx & operator=(const meta_ctx &other) {
internal::meta_info<>::ctx = other.ctx();
return *this;
}
/**
* @brief Move assignment operator.
* @param other The instance to move from.
* @return This meta object.
*/
meta_ctx & operator=(meta_ctx &&other) {
internal::meta_info<>::ctx = other.ctx();
return *this;
}
};
/*! @copydoc operator!=(const meta_prop &, const meta_prop &) */
inline bool operator!=(const meta_type &lhs, const meta_type &rhs) ENTT_NOEXCEPT {
return !(lhs == rhs);