Przeglądaj źródła

entity: more consteval-ness

skypjack 3 miesięcy temu
rodzic
commit
b35045ac78
2 zmienionych plików z 9 dodań i 11 usunięć
  1. 6 8
      src/entt/entity/entity.hpp
  2. 3 3
      src/entt/entity/fwd.hpp

+ 6 - 8
src/entt/entity/entity.hpp

@@ -211,8 +211,7 @@ struct null_t {
     template<typename Entity>
     [[nodiscard]] constexpr operator Entity() const noexcept {
         using traits_type = entt_traits<Entity>;
-        constexpr auto value = traits_type::construct(traits_type::entity_mask, traits_type::version_mask);
-        return value;
+        return traits_type::construct(traits_type::entity_mask, traits_type::version_mask);
     }
 
     /**
@@ -220,7 +219,7 @@ struct null_t {
      * @param other A null object.
      * @return True in all cases.
      */
-    [[nodiscard]] constexpr bool operator==([[maybe_unused]] const null_t other) const noexcept {
+    [[nodiscard]] consteval bool operator==([[maybe_unused]] const null_t other) const noexcept {
         return true;
     }
 
@@ -229,7 +228,7 @@ struct null_t {
      * @param other A null object.
      * @return False in all cases.
      */
-    [[nodiscard]] constexpr bool operator!=([[maybe_unused]] const null_t other) const noexcept {
+    [[nodiscard]] consteval bool operator!=([[maybe_unused]] const null_t other) const noexcept {
         return false;
     }
 
@@ -291,8 +290,7 @@ struct tombstone_t {
     template<typename Entity>
     [[nodiscard]] constexpr operator Entity() const noexcept {
         using traits_type = entt_traits<Entity>;
-        constexpr auto value = traits_type::construct(traits_type::entity_mask, traits_type::version_mask);
-        return value;
+        return traits_type::construct(traits_type::entity_mask, traits_type::version_mask);
     }
 
     /**
@@ -300,7 +298,7 @@ struct tombstone_t {
      * @param other A tombstone object.
      * @return True in all cases.
      */
-    [[nodiscard]] constexpr bool operator==([[maybe_unused]] const tombstone_t other) const noexcept {
+    [[nodiscard]] consteval bool operator==([[maybe_unused]] const tombstone_t other) const noexcept {
         return true;
     }
 
@@ -309,7 +307,7 @@ struct tombstone_t {
      * @param other A tombstone object.
      * @return False in all cases.
      */
-    [[nodiscard]] constexpr bool operator!=([[maybe_unused]] const tombstone_t other) const noexcept {
+    [[nodiscard]] consteval bool operator!=([[maybe_unused]] const tombstone_t other) const noexcept {
         return false;
     }
 

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

@@ -139,7 +139,7 @@ using const_runtime_view = basic_runtime_view<const sparse_set>;
 template<typename... Type>
 struct exclude_t final: type_list<Type...> {
     /*! @brief Default constructor. */
-    explicit constexpr exclude_t() = default;
+    explicit consteval exclude_t() = default;
 };
 
 /**
@@ -156,7 +156,7 @@ inline constexpr exclude_t<Type...> exclude{};
 template<typename... Type>
 struct get_t final: type_list<Type...> {
     /*! @brief Default constructor. */
-    explicit constexpr get_t() = default;
+    explicit consteval get_t() = default;
 };
 
 /**
@@ -173,7 +173,7 @@ inline constexpr get_t<Type...> get{};
 template<typename... Type>
 struct owned_t final: type_list<Type...> {
     /*! @brief Default constructor. */
-    explicit constexpr owned_t() = default;
+    explicit consteval owned_t() = default;
 };
 
 /**