From 6791cf1e2e1c13781c8a3b2a86ea970d90c6e177 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Sun, 10 Sep 2017 16:40:20 +0200 Subject: [PATCH] minor changes --- src/registry.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/registry.hpp b/src/registry.hpp index e0b69148c..5a0cf7469 100644 --- a/src/registry.hpp +++ b/src/registry.hpp @@ -325,18 +325,21 @@ public: template const Comp & get(entity_type entity) const noexcept { + assert(valid(entity)); constexpr auto index = ident.template get(); return std::get(pool).get(entity); } template Comp & get(entity_type entity) noexcept { + assert(valid(entity)); constexpr auto index = ident.template get(); return std::get(pool).get(entity); } template Comp & replace(entity_type entity, Args... args) { + assert(valid(entity)); constexpr auto index = ident.template get(); return (std::get(pool).get(entity) = Comp{args...}); } @@ -363,12 +366,16 @@ public: template Comp & copy(entity_type to, entity_type from) { + assert(valid(to)); + assert(valid(from)); constexpr auto index = ident.template get(); auto &&cpool = std::get(pool); return (cpool.get(to) = cpool.get(from)); } void copy(entity_type to, entity_type from) { + assert(valid(to)); + assert(valid(from)); using accumulator_type = int[]; accumulator_type accumulator = { 0, (sync(to, from), 0)... }; (void)accumulator; @@ -376,6 +383,8 @@ public: template void swap(entity_type lhs, entity_type rhs) { + assert(valid(lhs)); + assert(valid(rhs)); std::get.template get()>(pool).swap(lhs, rhs); }