sigh_mixin: avoid using weak ranges twice - close #1123
This commit is contained in:
@@ -271,11 +271,12 @@ public:
|
||||
*/
|
||||
template<typename It, typename... Args>
|
||||
void insert(It first, It last, Args &&...args) {
|
||||
auto from = underlying_type::size();
|
||||
underlying_type::insert(first, last, std::forward<Args>(args)...);
|
||||
|
||||
if(auto ® = owner_or_assert(); !construction.empty()) {
|
||||
for(; first != last; ++first) {
|
||||
construction.publish(reg, *first);
|
||||
for(const auto to = underlying_type::size(); from != to; ++from) {
|
||||
construction.publish(reg, underlying_type::operator[](from));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,23 @@ TYPED_TEST(SighMixin, Functionalities) {
|
||||
ASSERT_EQ(pool.size(), 0u);
|
||||
}
|
||||
|
||||
TYPED_TEST(SighMixin, InsertWeakRange) {
|
||||
using value_type = typename TestFixture::type;
|
||||
|
||||
entt::registry registry;
|
||||
auto &pool = registry.storage<value_type>();
|
||||
const auto view = registry.view<entt::entity>(entt::exclude<value_type>);
|
||||
[[maybe_unused]] const std::array entity{registry.create(), registry.create()};
|
||||
std::size_t on_construct{};
|
||||
|
||||
ASSERT_EQ(on_construct, 0u);
|
||||
|
||||
pool.on_construct().template connect<&listener<entt::registry>>(on_construct);
|
||||
pool.insert(view.begin(), view.end());
|
||||
|
||||
ASSERT_EQ(on_construct, 2u);
|
||||
}
|
||||
|
||||
TEST(SighMixin, NonDefaultConstructibleType) {
|
||||
entt::registry registry;
|
||||
auto &pool = registry.storage<test::non_default_constructible>();
|
||||
|
||||
Reference in New Issue
Block a user