|
|
@@ -1669,16 +1669,24 @@ inline bool meta_any::assign(meta_any &&other) {
|
|
|
class meta_sequence_container::meta_iterator final {
|
|
|
friend class meta_sequence_container;
|
|
|
|
|
|
- using vtable_type = void(const bool, const any &, const std::ptrdiff_t, meta_any *);
|
|
|
+ enum class operation : std::uint8_t {
|
|
|
+ incr,
|
|
|
+ deref
|
|
|
+ };
|
|
|
+
|
|
|
+ using vtable_type = void(const operation, const any &, const std::ptrdiff_t, meta_any *);
|
|
|
|
|
|
template<typename It>
|
|
|
- static void basic_vtable(const bool incr_or_deref, const any &value, const std::ptrdiff_t offset, meta_any *other) {
|
|
|
- if(incr_or_deref) {
|
|
|
+ static void basic_vtable(const operation op, const any &value, const std::ptrdiff_t offset, meta_any *other) {
|
|
|
+ switch(op) {
|
|
|
+ case operation::incr: {
|
|
|
auto &it = any_cast<It &>(const_cast<any &>(value));
|
|
|
it = std::next(it, offset);
|
|
|
- } else {
|
|
|
+ } break;
|
|
|
+ case operation::deref: {
|
|
|
const auto &it = any_cast<const It &>(value);
|
|
|
other->emplace<decltype(*it)>(*it);
|
|
|
+ } break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1701,30 +1709,30 @@ public:
|
|
|
handle{iter} {}
|
|
|
|
|
|
meta_iterator &operator++() noexcept {
|
|
|
- vtable(true, handle, 1, nullptr);
|
|
|
+ vtable(operation::incr, handle, 1, nullptr);
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
|
meta_iterator operator++(int value) noexcept {
|
|
|
meta_iterator orig = *this;
|
|
|
- vtable(true, handle, ++value, nullptr);
|
|
|
+ vtable(operation::incr, handle, ++value, nullptr);
|
|
|
return orig;
|
|
|
}
|
|
|
|
|
|
meta_iterator &operator--() noexcept {
|
|
|
- vtable(true, handle, -1, nullptr);
|
|
|
+ vtable(operation::incr, handle, -1, nullptr);
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
|
meta_iterator operator--(int value) noexcept {
|
|
|
meta_iterator orig = *this;
|
|
|
- vtable(true, handle, --value, nullptr);
|
|
|
+ vtable(operation::incr, handle, --value, nullptr);
|
|
|
return orig;
|
|
|
}
|
|
|
|
|
|
[[nodiscard]] reference operator*() const {
|
|
|
reference other{meta_ctx_arg, *ctx};
|
|
|
- vtable(false, handle, 0, &other);
|
|
|
+ vtable(operation::deref, handle, 0, &other);
|
|
|
return other;
|
|
|
}
|
|
|
|
|
|
@@ -1751,13 +1759,20 @@ private:
|
|
|
};
|
|
|
|
|
|
class meta_associative_container::meta_iterator final {
|
|
|
- using vtable_type = void(const bool, const any &, std::pair<meta_any, meta_any> *);
|
|
|
+ enum class operation : std::uint8_t {
|
|
|
+ incr,
|
|
|
+ deref
|
|
|
+ };
|
|
|
+
|
|
|
+ using vtable_type = void(const operation, const any &, std::pair<meta_any, meta_any> *);
|
|
|
|
|
|
template<bool KeyOnly, typename It>
|
|
|
- static void basic_vtable(const bool incr_or_deref, const any &value, std::pair<meta_any, meta_any> *other) {
|
|
|
- if(incr_or_deref) {
|
|
|
+ static void basic_vtable(const operation op, const any &value, std::pair<meta_any, meta_any> *other) {
|
|
|
+ switch(op) {
|
|
|
+ case operation::incr:
|
|
|
++any_cast<It &>(const_cast<any &>(value));
|
|
|
- } else {
|
|
|
+ break;
|
|
|
+ case operation::deref:
|
|
|
const auto &it = any_cast<const It &>(value);
|
|
|
if constexpr(KeyOnly) {
|
|
|
other->first.emplace<decltype(*it)>(*it);
|
|
|
@@ -1765,6 +1780,7 @@ class meta_associative_container::meta_iterator final {
|
|
|
other->first.emplace<decltype((it->first))>(it->first);
|
|
|
other->second.emplace<decltype((it->second))>(it->second);
|
|
|
}
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1787,7 +1803,7 @@ public:
|
|
|
handle{iter} {}
|
|
|
|
|
|
meta_iterator &operator++() noexcept {
|
|
|
- vtable(true, handle, nullptr);
|
|
|
+ vtable(operation::incr, handle, nullptr);
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
|
@@ -1798,7 +1814,7 @@ public:
|
|
|
|
|
|
[[nodiscard]] reference operator*() const {
|
|
|
reference other{{meta_ctx_arg, *ctx}, {meta_ctx_arg, *ctx}};
|
|
|
- vtable(false, handle, &other);
|
|
|
+ vtable(operation::deref, handle, &other);
|
|
|
return other;
|
|
|
}
|
|
|
|