diff --git a/src/entt/meta/container.hpp b/src/entt/meta/container.hpp index 1815e8e03..5f65e0fdd 100644 --- a/src/entt/meta/container.hpp +++ b/src/entt/meta/container.hpp @@ -78,16 +78,20 @@ struct basic_meta_sequence_container_traits { break; } case operation::begin: - *it = iterator{ctx, const_cast(cont)->begin()}; + if(value) { + *it = iterator{ctx, const_cast(cont)->begin()}; + } else { + *it = iterator{ctx, cont->begin()}; + } + return true; case operation::end: - *it = iterator{ctx, const_cast(cont)->end()}; - return true; - case operation::cbegin: - *it = iterator{ctx, cont->begin()}; - return true; - case operation::cend: - *it = iterator{ctx, cont->end()}; + if(value) { + *it = iterator{ctx, const_cast(cont)->end()}; + } else { + *it = iterator{ctx, cont->end()}; + } + return true; case operation::insert: case operation::erase: @@ -107,6 +111,7 @@ struct basic_meta_sequence_container_traits { return true; } } + break; } @@ -139,16 +144,20 @@ struct basic_meta_associative_container_traits { break; } case operation::begin: - *it = iterator{ctx, std::bool_constant{}, const_cast(cont)->begin()}; + if(value) { + *it = iterator{ctx, std::bool_constant{}, const_cast(cont)->begin()}; + } else { + *it = iterator{ctx, std::bool_constant{}, cont->begin()}; + } + return true; case operation::end: - *it = iterator{ctx, std::bool_constant{}, const_cast(cont)->end()}; - return true; - case operation::cbegin: - *it = iterator{ctx, std::bool_constant{}, cont->begin()}; - return true; - case operation::cend: - *it = iterator{ctx, std::bool_constant{}, cont->end()}; + if(value) { + *it = iterator{ctx, std::bool_constant{}, const_cast(cont)->end()}; + } else { + *it = iterator{ctx, std::bool_constant{}, cont->end()}; + } + return true; case operation::insert: if(key->allow_cast()) { @@ -159,19 +168,21 @@ struct basic_meta_associative_container_traits { return val->allow_cast() && const_cast(cont)->emplace(key->cast(), val->cast()).second; } } + break; case operation::erase: if(key->allow_cast()) { return const_cast(cont)->erase(key->cast()); } + break; case operation::find: if(key->allow_cast()) { if(value) { - *it = iterator{ctx, std::bool_constant{}, const_cast(cont)->find(key->cast())}; + *it = iterator{ctx, std::bool_constant{}, const_cast(cont)->find(key->cast())}; } else { *it = iterator{ctx, std::bool_constant{}, cont->find(key->cast())}; - } + } return true; } diff --git a/src/entt/meta/meta.hpp b/src/entt/meta/meta.hpp index 73b13db90..88a2e5140 100644 --- a/src/entt/meta/meta.hpp +++ b/src/entt/meta/meta.hpp @@ -40,8 +40,6 @@ enum class meta_sequence_container_operation { resize, begin, end, - cbegin, - cend, insert, erase }; @@ -52,8 +50,6 @@ enum class meta_associative_container_operation { reserve, begin, end, - cbegin, - cend, insert, erase, find @@ -1905,7 +1901,7 @@ inline bool meta_sequence_container::reserve(const size_type sz) { */ [[nodiscard]] inline meta_sequence_container::iterator meta_sequence_container::begin() { iterator it{}; - vtable(storage.policy() == any_policy::cref ? operation::cbegin : operation::begin, *ctx, std::as_const(storage).data(), nullptr, &it); + vtable(operation::begin, *ctx, std::as_const(storage).data(), storage.policy() == any_policy::cref ? nullptr : this, &it); return it; } @@ -1915,7 +1911,7 @@ inline bool meta_sequence_container::reserve(const size_type sz) { */ [[nodiscard]] inline meta_sequence_container::iterator meta_sequence_container::end() { iterator it{}; - vtable(storage.policy() == any_policy::cref ? operation::cend : operation::end, *ctx, std::as_const(storage).data(), nullptr, &it); + vtable(operation::end, *ctx, std::as_const(storage).data(), storage.policy() == any_policy::cref ? nullptr : this, &it); return it; } @@ -2005,14 +2001,14 @@ inline bool meta_associative_container::reserve(const size_type sz) { /*! @copydoc meta_sequence_container::begin */ [[nodiscard]] inline meta_associative_container::iterator meta_associative_container::begin() { iterator it{}; - vtable(storage.policy() == any_policy::cref ? operation::cbegin : operation::begin, *ctx, std::as_const(storage).data(), nullptr, nullptr, &it); + vtable(operation::begin, *ctx, std::as_const(storage).data(), nullptr, storage.policy() == any_policy::cref ? nullptr : this, &it); return it; } /*! @copydoc meta_sequence_container::end */ [[nodiscard]] inline meta_associative_container::iterator meta_associative_container::end() { iterator it{}; - vtable(storage.policy() == any_policy::cref ? operation::cend : operation::end, *ctx, std::as_const(storage).data(), nullptr, nullptr, &it); + vtable(operation::end, *ctx, std::as_const(storage).data(), nullptr, storage.policy() == any_policy::cref ? nullptr : this, &it); return it; }