Skip to content

Commit

Permalink
oh, my... msvc :-(
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed May 19, 2018
1 parent d8d1ad2 commit 62dd57b
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions src/entt/entity/snapshot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#define ENTT_ENTITY_SNAPSHOT_HPP


#include <unordered_map>
#include <algorithm>
#include <array>
#include <cstddef>
#include <utility>
#include <cassert>
#include <iterator>
#include <type_traits>
#include <unordered_map>
#include "../config/config.h"
#include "entt_traits.hpp"
#include "utility.hpp"
Expand Down Expand Up @@ -76,11 +76,30 @@ class Snapshot final {
void get(Archive &archive, std::size_t sz, It first, It last) {
archive(static_cast<Entity>(sz));

std::for_each(first, last, [&archive, this](const auto entity) {
while(first != last) {
const auto entity = *(first++);

if(registry.template has<Component>(entity)) {
archive(entity, registry.template get<Component>(entity));
}
});
}
}

template<typename... Component, typename Archive, typename It, std::size_t... Indexes>
void component(Archive &archive, It first, It last, std::index_sequence<Indexes...>) {
std::array<std::size_t, sizeof...(Indexes)> size{};
auto begin = first;

while(begin != last) {
const auto entity = *(begin++);
using accumulator_type = std::size_t[];
accumulator_type accumulator = { (registry.template has<Component>(entity) ? ++size[Indexes] : size[Indexes])... };
(void)accumulator;
}

using accumulator_type = int[];
accumulator_type accumulator = { (get<Component>(archive, size[Indexes], first, last), 0)... };
(void)accumulator;
}

public:
Expand Down Expand Up @@ -170,20 +189,7 @@ class Snapshot final {
*/
template<typename... Component, typename Archive, typename It>
Snapshot & component(Archive &archive, It first, It last) {
std::array<std::size_t, sizeof...(Component)> size{};

std::for_each(first, last, [&size, this](const auto entity) {
std::size_t pos{};
using accumulator_type = std::size_t[];
accumulator_type accumulator = { (registry.template has<Component>(entity) ? ++size[pos++] : size[pos++])... };
(void)accumulator;
});

std::size_t pos{};
using accumulator_type = int[];
accumulator_type accumulator = { (get<Component>(archive, size[pos++], first, last), 0)... };
(void)accumulator;

component<Component...>(archive, first, last, std::make_index_sequence<sizeof...(Component)>{});
return *this;
}

Expand Down

0 comments on commit 62dd57b

Please sign in to comment.