@@ -956,17 +956,28 @@ class basic_registry {
956
956
*/
957
957
template <typename Type, typename ... Other, typename It>
958
958
size_type remove (It first, It last) {
959
+ size_type count{};
960
+
959
961
if constexpr (sizeof ...(Other) == 0u ) {
960
- return assure<Type>().remove (std::move (first), std::move (last));
961
- } else {
962
- size_type count{};
962
+ count += assure<Type>().remove (std::move (first), std::move (last));
963
+ } else if constexpr (std::is_same_v<It, typename basic_common_type::iterator>) {
964
+ constexpr size_type len = sizeof ...(Other) + 1u ;
965
+ basic_common_type *cpools[len]{&assure<Type>(), &assure<Other>()...};
966
+
967
+ for (size_type pos{}; pos < len; ++pos) {
968
+ if (cpools[pos]->data () == first.data ()) {
969
+ std::swap (cpools[pos], cpools[len - 1u ]);
970
+ }
963
971
972
+ count += cpools[pos]->remove (first, last);
973
+ }
974
+ } else {
964
975
for (auto cpools = std::forward_as_tuple (assure<Type>(), assure<Other>()...); first != last; ++first) {
965
976
count += std::apply ([entt = *first](auto &...curr ) { return (curr.remove (entt) + ... + 0u ); }, cpools);
966
977
}
967
-
968
- return count;
969
978
}
979
+
980
+ return count;
970
981
}
971
982
972
983
/* *
@@ -998,10 +1009,12 @@ class basic_registry {
998
1009
*/
999
1010
template <typename Type, typename ... Other, typename It>
1000
1011
void erase (It first, It last) {
1001
- constexpr size_type len = sizeof ...(Other) + 1u ;
1002
- basic_common_type *cpools[len]{&assure<Type>(), &assure<Other>()...};
1012
+ if constexpr (sizeof ...(Other) == 0u ) {
1013
+ assure<Type>().erase (std::move (first), std::move (last));
1014
+ } else if constexpr (std::is_same_v<It, typename basic_common_type::iterator>) {
1015
+ constexpr size_type len = sizeof ...(Other) + 1u ;
1016
+ basic_common_type *cpools[len]{&assure<Type>(), &assure<Other>()...};
1003
1017
1004
- if constexpr (std::is_same_v<It, typename basic_common_type::iterator>) {
1005
1018
for (size_type pos{}; pos < len; ++pos) {
1006
1019
if (cpools[pos]->data () == first.data ()) {
1007
1020
std::swap (cpools[pos], cpools[len - 1u ]);
@@ -1010,12 +1023,8 @@ class basic_registry {
1010
1023
cpools[pos]->erase (first, last);
1011
1024
}
1012
1025
} else {
1013
- for (; first != last; ++first) {
1014
- const auto entt = *first;
1015
-
1016
- for (size_type pos{}; pos < len; ++pos) {
1017
- cpools[pos]->erase (entt);
1018
- }
1026
+ for (auto cpools = std::forward_as_tuple (assure<Type>(), assure<Other>()...); first != last; ++first) {
1027
+ std::apply ([entt = *first](auto &...curr ) { (curr.erase (entt), ...); }, cpools);
1019
1028
}
1020
1029
}
1021
1030
}
0 commit comments