use std::for_each instead of std::for_each_n (the latter isn't supported by older compilers)

This commit is contained in:
Michele Caini
2019-11-22 14:26:31 +01:00
parent 54bb4797db
commit 33f5e13b29

View File

@@ -82,8 +82,9 @@ class basic_registry {
std::enable_if_t<std::is_same_v<typename std::iterator_traits<It>::value_type, Entity>, typename storage<Entity, Component>::reverse_iterator_type>
assign(basic_registry &owner, It first, It last, Args &&... args) {
auto it = storage<Entity, Component>::construct(first, last, std::forward<Args>(args)...);
const auto end = it + (!construction.empty() * std::distance(first, last));
std::for_each_n(it, !construction.empty() * std::distance(first, last), [this, &owner, &first](decltype(*it) component) {
std::for_each(it, end, [this, &owner, &first](decltype(*it) component) {
construction.publish(*(first++), owner, component);
});