diff --git a/src/entt/meta/factory.hpp b/src/entt/meta/factory.hpp index f9a704261..c8f588805 100644 --- a/src/entt/meta/factory.hpp +++ b/src/entt/meta/factory.hpp @@ -524,13 +524,14 @@ private: * dedicated factory. * * @tparam Type Type to reflect. + * @param ctx The context into which to construct meta types. * @return A meta factory for the given type. */ template -[[nodiscard]] auto meta() noexcept { +[[nodiscard]] auto meta(meta_ctx &ctx = locator::value_or()) noexcept { // make sure the type exists in the context before returning a factory - internal::meta_context::from(locator::value_or()).value.try_emplace(type_id().hash(), internal::resolve_TODO()); - return meta_factory{}; + internal::meta_context::from(ctx).value.try_emplace(type_id().hash(), internal::resolve_TODO()); + return meta_factory{ctx}; } /** @@ -543,9 +544,10 @@ template * The type is also removed from the set of searchable types. * * @param id Unique identifier. + * @param ctx The context from which to reset meta types. */ -inline void meta_reset(const id_type id) noexcept { - auto &&context = internal::meta_context::from(locator::value_or()); +inline void meta_reset(const id_type id, meta_ctx &ctx = locator::value_or()) noexcept { + auto &&context = internal::meta_context::from(ctx); for(auto it = context.value.begin(); it != context.value.end();) { if(it->second.id == id) { @@ -562,19 +564,22 @@ inline void meta_reset(const id_type id) noexcept { * @sa meta_reset * * @tparam Type Type to reset. + * @param ctx The context from which to reset meta types. */ template -void meta_reset() noexcept { - internal::meta_context::from(locator::value_or()).value.erase(type_id().hash()); +void meta_reset(meta_ctx &ctx = locator::value_or()) noexcept { + internal::meta_context::from(ctx).value.erase(type_id().hash()); } /** * @brief Resets all meta types. * * @sa meta_reset + * + * @param ctx The context from which to reset meta types. */ -inline void meta_reset() noexcept { - internal::meta_context::from(locator::value_or()).value.clear(); +inline void meta_reset(meta_ctx &ctx = locator::value_or()) noexcept { + internal::meta_context::from(ctx).value.clear(); } } // namespace entt