workaround for an issue of VS2019

This commit is contained in:
Michele Caini
2019-08-19 17:49:55 +02:00
parent 05417705ed
commit d921306dd8
3 changed files with 18 additions and 2 deletions

3
TODO
View File

@@ -27,3 +27,6 @@ TODO
* make meta work across boundaries
- inline variables are fine here, only the head represents a problem
- we should always resolve by looking into the list of types when working across boundaries, no direct resolve
* signals: entity/registry/component instead of registry/entity/component
- dependency becomes a short circuit on the registry
- deprecate dependency

View File

@@ -149,7 +149,8 @@ void dependency(basic_registry<Entity> &reg, const Entity entt) {
*/
template<typename... Dependency, typename Component, typename Entity>
void connect(sink<void(basic_registry<Entity> &, const Entity, Component &)> sink) {
sink.template connect<dependency<Entity, Dependency...>>();
constexpr auto function = &dependency<Entity, Dependency...>;
sink.template connect<function>();
}
@@ -173,7 +174,8 @@ void connect(sink<void(basic_registry<Entity> &, const Entity, Component &)> sin
*/
template<typename... Dependency, typename Component, typename Entity>
void disconnect(sink<void(basic_registry<Entity> &, const Entity, Component &)> sink) {
sink.template disconnect<dependency<Entity, Dependency...>>();
constexpr auto function = &dependency<Entity, Dependency...>;
sink.template disconnect<function>();
}

View File

@@ -26,8 +26,12 @@ TEST(Helper, AsGroup) {
TEST(Helper, Dependency) {
entt::registry registry;
const auto entity = registry.create();
ASSERT_TRUE(registry.on_construct<int>().empty());
entt::connect<double, float>(registry.on_construct<int>());
ASSERT_FALSE(registry.on_construct<int>().empty());
ASSERT_FALSE(registry.has<double>(entity));
ASSERT_FALSE(registry.has<float>(entity));
@@ -62,9 +66,16 @@ TEST(Helper, Dependency) {
registry.remove<int>(entity);
registry.remove<double>(entity);
registry.remove<float>(entity);
ASSERT_FALSE(registry.has<int>(entity));
ASSERT_FALSE(registry.has<double>(entity));
ASSERT_FALSE(registry.has<float>(entity));
entt::disconnect<double, float>(registry.on_construct<int>());
registry.assign<int>(entity);
ASSERT_TRUE(registry.on_construct<int>().empty());
ASSERT_TRUE(registry.has<int>(entity));
ASSERT_FALSE(registry.has<double>(entity));
ASSERT_FALSE(registry.has<float>(entity));
}