Преглед на файлове

entity: make get_t, exclude_t and owned_t constexpr constructible

Michele Caini преди 3 години
родител
ревизия
710fff0e3f
променени са 3 файла, в които са добавени 19 реда и са изтрити 10 реда
  1. 12 3
      src/entt/entity/fwd.hpp
  2. 3 3
      src/entt/entity/observer.hpp
  3. 4 4
      src/entt/entity/registry.hpp

+ 12 - 3
src/entt/entity/fwd.hpp

@@ -102,7 +102,10 @@ class basic_continuous_loader;
  * @tparam Type List of types.
  */
 template<typename... Type>
-struct exclude_t final: type_list<Type...> {};
+struct exclude_t final: type_list<Type...> {
+    /*! @brief Default constructor. */
+    explicit constexpr exclude_t() {}
+};
 
 /**
  * @brief Variable template for exclusion lists.
@@ -116,7 +119,10 @@ inline constexpr exclude_t<Type...> exclude{};
  * @tparam Type List of types.
  */
 template<typename... Type>
-struct get_t final: type_list<Type...> {};
+struct get_t final: type_list<Type...> {
+    /*! @brief Default constructor. */
+    explicit constexpr get_t() {}
+};
 
 /**
  * @brief Variable template for lists of observed components.
@@ -130,7 +136,10 @@ inline constexpr get_t<Type...> get{};
  * @tparam Type List of types.
  */
 template<typename... Type>
-struct owned_t final: type_list<Type...> {};
+struct owned_t final: type_list<Type...> {
+    /*! @brief Default constructor. */
+    explicit constexpr owned_t() {}
+};
 
 /**
  * @brief Variable template for lists of owned components.

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

@@ -43,7 +43,7 @@ struct basic_collector<> {
      * @return The updated collector.
      */
     template<typename... AllOf, typename... NoneOf>
-    static constexpr auto group(exclude_t<NoneOf...> = {}) noexcept {
+    static constexpr auto group(exclude_t<NoneOf...> = exclude_t{}) noexcept {
         return basic_collector<matcher<type_list<>, type_list<>, type_list<NoneOf...>, AllOf...>>{};
     }
 
@@ -78,7 +78,7 @@ struct basic_collector<matcher<type_list<Reject...>, type_list<Require...>, Rule
      * @return The updated collector.
      */
     template<typename... AllOf, typename... NoneOf>
-    static constexpr auto group(exclude_t<NoneOf...> = {}) noexcept {
+    static constexpr auto group(exclude_t<NoneOf...> = exclude_t{}) noexcept {
         return basic_collector<matcher<type_list<>, type_list<>, type_list<NoneOf...>, AllOf...>, current_type, Other...>{};
     }
 
@@ -99,7 +99,7 @@ struct basic_collector<matcher<type_list<Reject...>, type_list<Require...>, Rule
      * @return The updated collector.
      */
     template<typename... AllOf, typename... NoneOf>
-    static constexpr auto where(exclude_t<NoneOf...> = {}) noexcept {
+    static constexpr auto where(exclude_t<NoneOf...> = exclude_t{}) noexcept {
         using extended_type = matcher<type_list<Reject..., NoneOf...>, type_list<Require..., AllOf...>, Rule...>;
         return basic_collector<extended_type, Other...>{};
     }

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

@@ -1176,14 +1176,14 @@ public:
      */
     template<typename Type, typename... Other, typename... Exclude>
     [[nodiscard]] basic_view<get_t<storage_for_type<const Type>, storage_for_type<const Other>...>, exclude_t<storage_for_type<const Exclude>...>>
-    view(exclude_t<Exclude...> = {}) const {
+    view(exclude_t<Exclude...> = exclude_t{}) const {
         return {assure<std::remove_const_t<Type>>(), assure<std::remove_const_t<Other>>()..., assure<std::remove_const_t<Exclude>>()...};
     }
 
     /*! @copydoc view */
     template<typename Type, typename... Other, typename... Exclude>
     [[nodiscard]] basic_view<get_t<storage_for_type<Type>, storage_for_type<Other>...>, exclude_t<storage_for_type<Exclude>...>>
-    view(exclude_t<Exclude...> = {}) {
+    view(exclude_t<Exclude...> = exclude_t{}) {
         return {assure<std::remove_const_t<Type>>(), assure<std::remove_const_t<Other>>()..., assure<std::remove_const_t<Exclude>>()...};
     }
 
@@ -1201,7 +1201,7 @@ public:
      */
     template<typename... Owned, typename... Get, typename... Exclude>
     basic_group<owned_t<storage_for_type<Owned>...>, get_t<storage_for_type<Get>...>, exclude_t<storage_for_type<Exclude>...>>
-    group(get_t<Get...> = {}, exclude_t<Exclude...> = {}) {
+    group(get_t<Get...> = get_t{}, exclude_t<Exclude...> = exclude_t{}) {
         using handler_type = typename basic_group<owned_t<storage_for_type<Owned>...>, get_t<storage_for_type<Get>...>, exclude_t<storage_for_type<Exclude>...>>::handler;
 
         if(auto it = groups.find(type_hash<handler_type>::value()); it != groups.cend()) {
@@ -1248,7 +1248,7 @@ public:
     /*! @copydoc group */
     template<typename... Owned, typename... Get, typename... Exclude>
     basic_group<owned_t<storage_for_type<const Owned>...>, get_t<storage_for_type<const Get>...>, exclude_t<storage_for_type<const Exclude>...>>
-    group_if_exists(get_t<Get...> = {}, exclude_t<Exclude...> = {}) const {
+    group_if_exists(get_t<Get...> = get_t{}, exclude_t<Exclude...> = exclude_t{}) const {
         using handler_type = typename basic_group<owned_t<storage_for_type<const Owned>...>, get_t<storage_for_type<const Get>...>, exclude_t<storage_for_type<const Exclude>...>>::handler;
 
         if(auto it = groups.find(type_hash<handler_type>::value()); it == groups.cend()) {