Browse Source

workaround to make it compile also with clang 5

Michele Caini 7 years ago
parent
commit
ae927c5600
4 changed files with 19 additions and 19 deletions
  1. 3 3
      docs/md/entity.md
  2. 3 3
      src/entt/entity/helper.hpp
  3. 12 12
      src/entt/entity/registry.hpp
  4. 1 1
      test/entt/entity/registry.cpp

+ 3 - 3
docs/md/entity.md

@@ -354,7 +354,7 @@ The function type of a listener for the construction signal should be equivalent
 to the following:
 
 ```cpp
-void(registry &, Component &, entt::entity);
+void(registry &, entt::entity, Component &);
 ```
 
 Where `Component` is intuitively the type of component of interest. In other
@@ -369,8 +369,8 @@ void(registry &, entt::entity);
 ```
 
 This is mainly due to performance reasons. While the component is made available
-after the construction, it is not when destroyed. Because of that, there is no
-reason to get it from the underlying storage unless the user requires so. In
+after the construction, it is not when destroyed. Because of that, there are no
+reasons to get it from the underlying storage unless the user requires so. In
 this case, the registry is made available for the purpose.
 
 Note also that:

+ 3 - 3
src/entt/entity/helper.hpp

@@ -129,7 +129,7 @@ as_group(const basic_registry<Entity> &) ENTT_NOEXCEPT -> as_group<true, Entity>
  * @param entt A valid entity identifier.
  */
 template<typename Entity, typename Component, typename... Dependency>
-void dependency(basic_registry<Entity> &reg, const Component &, const Entity entt) {
+void dependency(basic_registry<Entity> &reg, const Entity entt, const Component &) {
     ((reg.template has<Dependency>(entt) ? void() : (reg.template assign<Dependency>(entt), void())), ...);
 }
 
@@ -153,7 +153,7 @@ void dependency(basic_registry<Entity> &reg, const Component &, const Entity ent
  * @param sink A sink object properly initialized.
  */
 template<typename... Dependency, typename Component, typename Entity>
-inline void connect(sink<void(basic_registry<Entity> &, Component &, const Entity)> sink) {
+inline void connect(sink<void(basic_registry<Entity> &, const Entity, Component &)> sink) {
     sink.template connect<dependency<Entity, Component, Dependency...>>();
 }
 
@@ -177,7 +177,7 @@ inline void connect(sink<void(basic_registry<Entity> &, Component &, const Entit
  * @param sink A sink object properly initialized.
  */
 template<typename... Dependency, typename Component, typename Entity>
-inline void disconnect(sink<void(basic_registry<Entity> &, Component &, const Entity)> sink) {
+inline void disconnect(sink<void(basic_registry<Entity> &, const Entity, Component &)> sink) {
     sink.template disconnect<dependency<Entity, Component, Dependency...>>();
 }
 

+ 12 - 12
src/entt/entity/registry.hpp

@@ -67,7 +67,7 @@ class basic_registry {
         template<typename... Args>
         Component & construct(const Entity entt, Args &&... args) {
             auto &component = sparse_set<Entity, Component>::construct(entt, std::forward<Args>(args)...);
-            construction.publish(*owner, component, entt);
+            construction.publish(*owner, entt, component);
             return component;
         }
 
@@ -77,7 +77,7 @@ class basic_registry {
 
             if(!construction.empty()) {
                 std::for_each(first, last, [component, this](const auto entt) mutable {
-                    construction.publish(*owner, *(component++), entt);
+                    construction.publish(*owner, entt, *(component++));
                 });
             }
 
@@ -94,11 +94,11 @@ class basic_registry {
             destruction.publish(*owner, entt);
             auto &component = sparse_set<Entity, Component>::get(entt);
             component = Component{std::forward<Args>(args)...};
-            construction.publish(*owner, component, entt);
+            construction.publish(*owner, entt, component);
             return component;
         }
 
-        sigh<void(basic_registry &, Component &, const Entity)> construction;
+        sigh<void(basic_registry &, const Entity, Component &)> construction;
         sigh<void(basic_registry &, const Entity)> destruction;
         basic_registry *owner;
     };
@@ -112,7 +112,7 @@ class basic_registry {
     template<typename... Get, typename... Exclude>
     struct non_owning_group<type_list<Exclude...>, type_list<Get...>>: sparse_set<Entity> {
         template<typename Component, typename... Args>
-        void maybe_valid_if(basic_registry &reg, const Args &..., const Entity entt) {
+        void maybe_valid_if(basic_registry &reg, const Entity entt, const Args &...) {
             if constexpr(std::disjunction_v<std::is_same<Get, Component>...>) {
                 if(((std::is_same_v<Component, Get> || reg.pool<Get>()->has(entt)) && ...) && !(reg.pool<Exclude>()->has(entt) || ...)) {
                     this->construct(entt);
@@ -126,8 +126,8 @@ class basic_registry {
             }
         }
 
-        template<typename... Component>
-        void destroy_if(basic_registry &, const Component &..., const Entity entt) {
+        template<typename... Args>
+        void destroy_if(basic_registry &, const Entity entt, const Args &...) {
             if(this->has(entt)) {
                 this->destroy(entt);
             }
@@ -144,7 +144,7 @@ class basic_registry {
     template<typename... Owned, typename... Get, typename... Exclude>
     struct owning_group<type_list<Exclude...>, type_list<Get...>, Owned...>: boxed_owned {
         template<typename Component, typename... Args>
-        void maybe_valid_if(basic_registry &reg, const Args &..., const Entity entt) {
+        void maybe_valid_if(basic_registry &reg, const Entity entt, const Args &...) {
             const auto cpools = std::make_tuple(reg.pool<Owned>()...);
 
             auto construct = [&cpools, entt, this]() {
@@ -172,8 +172,8 @@ class basic_registry {
             }
         }
 
-        template<typename... Component>
-        void discard_if(basic_registry &reg, const Component &..., const Entity entt) {
+        template<typename... Args>
+        void discard_if(basic_registry &reg, const Entity entt, const Args &...) {
             const auto cpools = std::make_tuple(reg.pool<Owned>()...);
 
             if(std::get<0>(cpools)->has(entt) && std::get<0>(cpools)->sparse_set<Entity>::get(entt) < this->owned) {
@@ -399,7 +399,7 @@ public:
 
     /*! @brief Construction sink type for the given component. */
     template<typename Component>
-    using construction_sink_type = typename sigh<void(basic_registry &, Component &, const Entity)>::sink_type;
+    using construction_sink_type = typename sigh<void(basic_registry &, const Entity, Component &)>::sink_type;
 
     /*! @brief Default constructor. */
     basic_registry() ENTT_NOEXCEPT = default;
@@ -1038,7 +1038,7 @@ public:
      *
      * The function type for a listener is equivalent to:
      * @code{.cpp}
-     * void(registry<Entity> &, Component &, Entity);
+     * void(registry<Entity> &, Entity, Component &);
      * @endcode
      *
      * Listeners are invoked **after** the component has been assigned to the

+ 1 - 1
test/entt/entity/registry.cpp

@@ -13,7 +13,7 @@ ENTT_NAMED_TYPE(int)
 
 struct listener {
     template<typename Component>
-    void incr(entt::registry &registry, const Component &, entt::entity entity) {
+    void incr(entt::registry &registry, entt::entity entity, const Component &) {
         ASSERT_TRUE(registry.valid(entity));
         ASSERT_TRUE(registry.has<Component>(entity));
         last = entity;