فهرست منبع

group: make older compilers happy too

Michele Caini 1 سال پیش
والد
کامیت
6ca01d2faf
2فایلهای تغییر یافته به همراه17 افزوده شده و 7 حذف شده
  1. 14 4
      src/entt/entity/group.hpp
  2. 3 3
      src/entt/entity/registry.hpp

+ 14 - 4
src/entt/entity/group.hpp

@@ -312,8 +312,13 @@ public:
     /*! @brief Group handler type. */
     using handler = internal::group_handler<common_type, 0u, sizeof...(Get), sizeof...(Exclude)>;
 
-    /*! @brief Group opaque marker. */
-    static constexpr id_type group_id = type_hash<basic_group<owned_t<>, get_t<std::remove_const_t<Get>...>, exclude_t<std::remove_const_t<Exclude>...>>>::value();
+    /**
+     * @brief Group opaque identifier.
+     * @return Group opaque identifier.
+     */
+    static id_type group_id() noexcept {
+        return type_hash<basic_group<owned_t<>, get_t<std::remove_const_t<Get>...>, exclude_t<std::remove_const_t<Exclude>...>>>::value();
+    }
 
     /*! @brief Default constructor to use to create empty, invalid groups. */
     basic_group() noexcept
@@ -722,8 +727,13 @@ public:
     /*! @brief Group handler type. */
     using handler = internal::group_handler<common_type, sizeof...(Owned), sizeof...(Get), sizeof...(Exclude)>;
 
-    /*! @brief Group opaque marker. */
-    static constexpr id_type group_id = type_hash<basic_group<owned_t<std::remove_const_t<Owned>...>, get_t<std::remove_const_t<Get>...>, exclude_t<std::remove_const_t<Exclude>...>>>::value();
+    /**
+     * @brief Group opaque identifier.
+     * @return Group opaque identifier.
+     */
+    static id_type group_id() noexcept {
+        return type_hash<basic_group<owned_t<std::remove_const_t<Owned>...>, get_t<std::remove_const_t<Get>...>, exclude_t<std::remove_const_t<Exclude>...>>>::value();
+    }
 
     /*! @brief Default constructor to use to create empty, invalid groups. */
     basic_group() noexcept

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

@@ -1070,7 +1070,7 @@ public:
         using group_type = basic_group<owned_t<storage_for_type<Owned>...>, get_t<storage_for_type<Get>...>, exclude_t<storage_for_type<Exclude>...>>;
         using handler_type = typename group_type::handler;
 
-        if(auto it = groups.find(group_type::group_id); it != groups.cend()) {
+        if(auto it = groups.find(group_type::group_id()); it != groups.cend()) {
             return {*std::static_pointer_cast<handler_type>(it->second)};
         }
 
@@ -1084,7 +1084,7 @@ public:
             ENTT_ASSERT(std::all_of(groups.cbegin(), groups.cend(), [&elem](const auto &data) { return data.second->owned(elem, sizeof...(Owned)) == 0u; }), "Conflicting groups");
         }
 
-        groups.emplace(group_type::group_id, handler);
+        groups.emplace(group_type::group_id(), handler);
         return {*handler};
     }
 
@@ -1095,7 +1095,7 @@ public:
         using group_type = basic_group<owned_t<storage_for_type<const Owned>...>, get_t<storage_for_type<const Get>...>, exclude_t<storage_for_type<const Exclude>...>>;
         using handler_type = typename group_type::handler;
 
-        if(auto it = groups.find(group_type::group_id); it != groups.cend()) {
+        if(auto it = groups.find(group_type::group_id()); it != groups.cend()) {
             return {*std::static_pointer_cast<handler_type>(it->second)};
         }