diff --git a/src/entt/meta/meta.hpp b/src/entt/meta/meta.hpp index eb9b1eafb..be6aec546 100644 --- a/src/entt/meta/meta.hpp +++ b/src/entt/meta/meta.hpp @@ -1658,24 +1658,16 @@ inline bool meta_any::assign(meta_any &&other) { class meta_sequence_container::meta_iterator final { friend class meta_sequence_container; - enum class operation : std::uint8_t { - incr, - deref - }; - - using vtable_type = void(const operation, const any &, const std::ptrdiff_t, meta_any *); + using vtable_type = void(const bool, const any &, const std::ptrdiff_t, meta_any *); template - static void basic_vtable(const operation op, const any &value, const std::ptrdiff_t offset, meta_any *other) { - switch(op) { - case operation::incr: { + static void basic_vtable(const bool incr_or_deref, const any &value, const std::ptrdiff_t offset, meta_any *other) { + if(incr_or_deref) { auto &it = any_cast(const_cast(value)); it = std::next(it, offset); - } break; - case operation::deref: { + } else { const auto &it = any_cast(value); other->emplace(*it); - } break; } } @@ -1698,30 +1690,30 @@ public: handle{iter} {} meta_iterator &operator++() noexcept { - vtable(operation::incr, handle, 1, nullptr); + vtable(true, handle, 1, nullptr); return *this; } meta_iterator operator++(int value) noexcept { meta_iterator orig = *this; - vtable(operation::incr, handle, ++value, nullptr); + vtable(true, handle, ++value, nullptr); return orig; } meta_iterator &operator--() noexcept { - vtable(operation::incr, handle, -1, nullptr); + vtable(true, handle, -1, nullptr); return *this; } meta_iterator operator--(int value) noexcept { meta_iterator orig = *this; - vtable(operation::incr, handle, --value, nullptr); + vtable(true, handle, --value, nullptr); return orig; } [[nodiscard]] reference operator*() const { reference other{meta_ctx_arg, *ctx}; - vtable(operation::deref, handle, 0, &other); + vtable(false, handle, 0, &other); return other; } @@ -1748,20 +1740,13 @@ private: }; class meta_associative_container::meta_iterator final { - enum class operation : std::uint8_t { - incr, - deref - }; - - using vtable_type = void(const operation, const any &, std::pair *); + using vtable_type = void(const bool, const any &, std::pair *); template - static void basic_vtable(const operation op, const any &value, std::pair *other) { - switch(op) { - case operation::incr: + static void basic_vtable(const bool incr_or_deref, const any &value, std::pair *other) { + if(incr_or_deref) { ++any_cast(const_cast(value)); - break; - case operation::deref: + } else { const auto &it = any_cast(value); if constexpr(KeyOnly) { other->first.emplace(*it); @@ -1769,7 +1754,6 @@ class meta_associative_container::meta_iterator final { other->first.emplacefirst))>(it->first); other->second.emplacesecond))>(it->second); } - break; } } @@ -1792,7 +1776,7 @@ public: handle{iter} {} meta_iterator &operator++() noexcept { - vtable(operation::incr, handle, nullptr); + vtable(true, handle, nullptr); return *this; } @@ -1803,7 +1787,7 @@ public: [[nodiscard]] reference operator*() const { reference other{{meta_ctx_arg, *ctx}, {meta_ctx_arg, *ctx}}; - vtable(operation::deref, handle, &other); + vtable(false, handle, &other); return other; }