diff --git a/src/entt/meta/context.hpp b/src/entt/meta/context.hpp index d9ea62296..a7bf71927 100644 --- a/src/entt/meta/context.hpp +++ b/src/entt/meta/context.hpp @@ -21,8 +21,8 @@ struct meta_type_node; struct meta_context { dense_map value{}; - static inline meta_context &from(meta_ctx &ctx); - static inline const meta_context &from(const meta_ctx &ctx); + [[nodiscard]] static inline meta_context &from(meta_ctx &ctx); + [[nodiscard]] static inline const meta_context &from(const meta_ctx &ctx); }; } // namespace internal @@ -49,11 +49,11 @@ class meta_ctx: private internal::meta_context { * Internal details not to be documented. */ -inline internal::meta_context &internal::meta_context::from(meta_ctx &ctx) { +[[nodiscard]] inline internal::meta_context &internal::meta_context::from(meta_ctx &ctx) { return ctx; } -inline const internal::meta_context &internal::meta_context::from(const meta_ctx &ctx) { +[[nodiscard]] inline const internal::meta_context &internal::meta_context::from(const meta_ctx &ctx) { return ctx; } diff --git a/src/entt/meta/factory.hpp b/src/entt/meta/factory.hpp index b548ec88c..8637bccd7 100644 --- a/src/entt/meta/factory.hpp +++ b/src/entt/meta/factory.hpp @@ -29,7 +29,7 @@ namespace entt { namespace internal { -inline decltype(auto) owner(meta_ctx &ctx, const type_info &info) { +[[nodiscard]] inline decltype(auto) owner(meta_ctx &ctx, const type_info &info) { auto &&context = internal::meta_context::from(ctx); ENTT_ASSERT(context.value.contains(info.hash()), "Type not available"); return context.value[info.hash()]; diff --git a/src/entt/meta/meta.hpp b/src/entt/meta/meta.hpp index f8cb917f9..c3cddf210 100644 --- a/src/entt/meta/meta.hpp +++ b/src/entt/meta/meta.hpp @@ -613,7 +613,7 @@ private: * @return A properly initialized and not necessarily owning wrapper. */ template -meta_any forward_as_meta(const meta_ctx &ctx, Type &&value) { +[[nodiscard]] meta_any forward_as_meta(const meta_ctx &ctx, Type &&value) { return meta_any{ctx, std::in_place_type, std::forward(value)}; } @@ -624,7 +624,7 @@ meta_any forward_as_meta(const meta_ctx &ctx, Type &&value) { * @return A properly initialized and not necessarily owning wrapper. */ template -meta_any forward_as_meta(Type &&value) { +[[nodiscard]] meta_any forward_as_meta(Type &&value) { return forward_as_meta(locator::value_or(), std::forward(value)); } @@ -1348,12 +1348,12 @@ public: * @param element A valid pointer to an element of the underlying type. * @return A wrapper that references the given instance. */ - meta_any from_void(void *element) const { + [[nodiscard]] meta_any from_void(void *element) const { return (element && node.from_void) ? node.from_void(*ctx, element, nullptr) : meta_any{meta_ctx_arg, *ctx}; } /*! @copydoc from_void */ - meta_any from_void(const void *element) const { + [[nodiscard]] meta_any from_void(const void *element) const { return (element && node.from_void) ? node.from_void(*ctx, nullptr, element) : meta_any{meta_ctx_arg, *ctx}; } diff --git a/src/entt/meta/utility.hpp b/src/entt/meta/utility.hpp index 3ee98ee31..d84e3503a 100644 --- a/src/entt/meta/utility.hpp +++ b/src/entt/meta/utility.hpp @@ -162,7 +162,7 @@ using meta_function_helper_t = typename meta_function_helper::t * @return A meta any containing the returned value, if any. */ template -std::enable_if_t, meta_any> meta_dispatch(const meta_ctx &ctx, [[maybe_unused]] Type &&value) { +[[nodiscard]] std::enable_if_t, meta_any> meta_dispatch(const meta_ctx &ctx, [[maybe_unused]] Type &&value) { if constexpr(std::is_same_v) { return meta_any{ctx, std::in_place_type}; } else if constexpr(std::is_same_v) { @@ -183,7 +183,7 @@ std::enable_if_t, meta_any> meta_dispatch(const meta_ct * @return A meta any containing the returned value, if any. */ template -std::enable_if_t, meta_any> meta_dispatch(Type &&value) { +[[nodiscard]] std::enable_if_t, meta_any> meta_dispatch(Type &&value) { return meta_dispatch(locator::value_or(), std::forward(value)); }