From 450e20ae7897b71ad081f7dead91f0bf8b8fe88d Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Tue, 23 Jun 2020 11:30:53 +0200 Subject: [PATCH] meta: minor changes --- src/entt/meta/internal.hpp | 4 ++-- src/entt/meta/meta.hpp | 28 +++++++++++++--------------- src/entt/meta/range.hpp | 4 ++-- src/entt/meta/resolve.hpp | 2 +- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/entt/meta/internal.hpp b/src/entt/meta/internal.hpp index d0e3476fb..dfa79c4b0 100644 --- a/src/entt/meta/internal.hpp +++ b/src/entt/meta/internal.hpp @@ -345,11 +345,11 @@ public: : node{head} {} - iterator begin() const ENTT_NOEXCEPT { + [[nodiscard]] iterator begin() const ENTT_NOEXCEPT { return iterator{node}; } - iterator end() const ENTT_NOEXCEPT { + [[nodiscard]] iterator end() const ENTT_NOEXCEPT { return iterator{}; } diff --git a/src/entt/meta/meta.hpp b/src/entt/meta/meta.hpp index 0acd91bb5..982d79add 100644 --- a/src/entt/meta/meta.hpp +++ b/src/entt/meta/meta.hpp @@ -127,17 +127,15 @@ class meta_any { template [[nodiscard]] static meta_any dereference_operator(meta_any &any) { - meta_any other{}; - if constexpr(is_meta_pointer_like_v) { if constexpr(std::is_const_v())>>) { - other = *any.cast(); + return *any.cast(); } else { - other = std::ref(*any.cast()); + return std::ref(*any.cast()); } + } else { + return {}; } - - return other; } template @@ -676,7 +674,7 @@ struct meta_ctor { * @brief Returns a range to use to visit all meta properties. * @return An iterable range to use to visit all meta properties. */ - meta_range prop() const ENTT_NOEXCEPT { + [[nodiscard]] meta_range prop() const ENTT_NOEXCEPT { return node->prop; } @@ -787,7 +785,7 @@ struct meta_data { } /*! @copydoc meta_ctor::prop */ - meta_range prop() const ENTT_NOEXCEPT { + [[nodiscard]] meta_range prop() const ENTT_NOEXCEPT { return node->prop; } @@ -913,7 +911,7 @@ struct meta_func { } /*! @copydoc meta_ctor::prop */ - meta_range prop() const ENTT_NOEXCEPT { + [[nodiscard]] meta_range prop() const ENTT_NOEXCEPT { return node->prop; } @@ -1159,7 +1157,7 @@ public: * @brief Returns a range to use to visit top-level meta bases. * @return An iterable range to use to visit top-level meta bases. */ - meta_range base() const ENTT_NOEXCEPT { + [[nodiscard]] meta_range base() const ENTT_NOEXCEPT { return node->base; } @@ -1194,7 +1192,7 @@ public: * @return An iterable range to use to visit top-level meta conversion * functions. */ - meta_range conv() const ENTT_NOEXCEPT { + [[nodiscard]] meta_range conv() const ENTT_NOEXCEPT { return node->conv; } @@ -1228,7 +1226,7 @@ public: * @brief Returns a range to use to visit top-level meta constructors. * @return An iterable range to use to visit top-level meta constructors. */ - meta_range ctor() const ENTT_NOEXCEPT { + [[nodiscard]] meta_range ctor() const ENTT_NOEXCEPT { return node->ctor; } @@ -1259,7 +1257,7 @@ public: * @brief Returns a range to use to visit top-level meta data. * @return An iterable range to use to visit top-level meta data. */ - meta_range data() const ENTT_NOEXCEPT { + [[nodiscard]] meta_range data() const ENTT_NOEXCEPT { return node->data; } @@ -1295,7 +1293,7 @@ public: * @brief Returns a range to use to visit top-level meta functions. * @return An iterable range to use to visit top-level meta functions. */ - meta_range func() const ENTT_NOEXCEPT { + [[nodiscard]] meta_range func() const ENTT_NOEXCEPT { return node->func; } @@ -1358,7 +1356,7 @@ public: * @brief Returns a range to use to visit top-level meta properties. * @return An iterable range to use to visit top-level meta properties. */ - meta_range prop() const ENTT_NOEXCEPT { + [[nodiscard]] meta_range prop() const ENTT_NOEXCEPT { return node->prop; } diff --git a/src/entt/meta/range.hpp b/src/entt/meta/range.hpp index ddfbcab2d..e69eaec2c 100644 --- a/src/entt/meta/range.hpp +++ b/src/entt/meta/range.hpp @@ -74,7 +74,7 @@ public: * @brief Returns an iterator to the beginning. * @return An iterator to the first meta object of the range. */ - iterator begin() const ENTT_NOEXCEPT { + [[nodiscard]] iterator begin() const ENTT_NOEXCEPT { return iterator{node}; } @@ -83,7 +83,7 @@ public: * @return An iterator to the element following the last meta object of the * range. */ - iterator end() const ENTT_NOEXCEPT { + [[nodiscard]] iterator end() const ENTT_NOEXCEPT { return iterator{}; } diff --git a/src/entt/meta/resolve.hpp b/src/entt/meta/resolve.hpp index 84662286b..fa3eff16a 100644 --- a/src/entt/meta/resolve.hpp +++ b/src/entt/meta/resolve.hpp @@ -26,7 +26,7 @@ template * @brief Returns a range to use to visit all meta types. * @return An iterable range to use to visit all meta types. */ -inline meta_range resolve() { +[[nodiscard]] inline meta_range resolve() { return *internal::meta_context::global(); }