From 4f994cbec28f270fd2d694b6c8aab4bf9fd094cd Mon Sep 17 00:00:00 2001 From: skypjack Date: Thu, 18 Dec 2025 17:27:52 +0100 Subject: [PATCH] core: more consteval-ness --- src/entt/core/ident.hpp | 2 +- src/entt/core/type_info.hpp | 4 ++-- src/entt/core/type_traits.hpp | 24 ++++++++++++------------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/entt/core/ident.hpp b/src/entt/core/ident.hpp index 2ff602670..9028a83f1 100644 --- a/src/entt/core/ident.hpp +++ b/src/entt/core/ident.hpp @@ -16,7 +16,7 @@ namespace entt { template class ident { template - [[nodiscard]] static constexpr id_type get(std::index_sequence) noexcept { + [[nodiscard]] static consteval id_type get(std::index_sequence) noexcept { static_assert((std::is_same_v || ...), "Invalid type"); return (0 + ... + (std::is_same_v...>>> ? id_type{Index} : id_type{})); } diff --git a/src/entt/core/type_info.hpp b/src/entt/core/type_info.hpp index 0eeb4985f..9ce662d9c 100644 --- a/src/entt/core/type_info.hpp +++ b/src/entt/core/type_info.hpp @@ -42,7 +42,7 @@ template } template().find_first_of('.')> -[[nodiscard]] constexpr std::string_view type_name(int) noexcept { +[[nodiscard]] consteval std::string_view type_name(int) noexcept { constexpr auto value = stripped_type_name(); return value; } @@ -54,7 +54,7 @@ template } template().find_first_of('.')> -[[nodiscard]] constexpr id_type type_hash(int) noexcept { +[[nodiscard]] consteval id_type type_hash(int) noexcept { constexpr auto stripped = stripped_type_name(); constexpr auto value = hashed_string::value(stripped.data(), stripped.size()); return value; diff --git a/src/entt/core/type_traits.hpp b/src/entt/core/type_traits.hpp index 9408973f5..2bfb2ba0f 100644 --- a/src/entt/core/type_traits.hpp +++ b/src/entt/core/type_traits.hpp @@ -186,7 +186,7 @@ inline constexpr std::size_t type_list_index_v = type_list_index::va * @return A type list composed by the types of both the type lists. */ template -constexpr type_list operator+(type_list, type_list) { +consteval type_list operator+(type_list, type_list) { return {}; } @@ -451,7 +451,7 @@ inline constexpr std::size_t value_list_index_v = value_list_index: * @return A value list composed by the values of both the value lists. */ template -constexpr value_list operator+(value_list, value_list) { +consteval value_list operator+(value_list, value_list) { return {}; } @@ -731,25 +731,25 @@ template struct has_value_type>: std::true_type {}; template -[[nodiscard]] constexpr bool dispatch_is_equality_comparable(); +[[nodiscard]] consteval bool dispatch_is_equality_comparable(); template -[[nodiscard]] constexpr bool unpack_maybe_equality_comparable(std::index_sequence) { +[[nodiscard]] consteval bool unpack_maybe_equality_comparable(std::index_sequence) { return (dispatch_is_equality_comparable>() && ...); } template -[[nodiscard]] constexpr bool maybe_equality_comparable(char) { +[[nodiscard]] consteval bool maybe_equality_comparable(char) { return false; } template -[[nodiscard]] constexpr auto maybe_equality_comparable(int) -> decltype(std::declval() == std::declval()) { +[[nodiscard]] consteval auto maybe_equality_comparable(int) -> decltype(std::declval() == std::declval()) { return true; } template -[[nodiscard]] constexpr bool dispatch_is_equality_comparable() { +[[nodiscard]] consteval bool dispatch_is_equality_comparable() { // NOLINTBEGIN(modernize-use-transparent-functors) if constexpr(std::is_array_v) { return false; @@ -856,19 +856,19 @@ using member_class_t = member_class::type; template class nth_argument { template - static constexpr type_list pick_up(Ret (*)(Args...)); + static consteval type_list pick_up(Ret (*)(Args...)); template - static constexpr type_list pick_up(Ret (Class ::*)(Args...)); + static consteval type_list pick_up(Ret (Class ::*)(Args...)); template - static constexpr type_list pick_up(Ret (Class ::*)(Args...) const); + static consteval type_list pick_up(Ret (Class ::*)(Args...) const); template - static constexpr type_list pick_up(Type Class ::*); + static consteval type_list pick_up(Type Class ::*); template - static constexpr decltype(pick_up(&Type::operator())) pick_up(Type &&); + static consteval decltype(pick_up(&Type::operator())) pick_up(Type &&); public: /*! @brief N-th argument of the _callable_ type. */