From 272b93c8fbcf5ff8dc561eb292ca17d26d2c6a7b Mon Sep 17 00:00:00 2001 From: skypjack Date: Thu, 2 Apr 2026 09:38:41 +0200 Subject: [PATCH] stl: std::remove_reference_t --- src/entt/core/any.hpp | 10 +++++----- src/entt/core/tuple.hpp | 2 +- src/entt/entity/handle.hpp | 2 +- src/entt/entity/organizer.hpp | 10 +++++----- src/entt/entity/registry.hpp | 2 +- src/entt/meta/container.hpp | 2 +- src/entt/meta/factory.hpp | 2 +- src/entt/meta/meta.hpp | 10 +++++----- src/entt/meta/node.hpp | 2 +- src/entt/meta/policy.hpp | 2 +- src/entt/meta/utility.hpp | 26 +++++++++++++------------- src/entt/stl/type_traits.hpp | 1 + 12 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/entt/core/any.hpp b/src/entt/core/any.hpp index 40100c4dd..3b8495e6c 100644 --- a/src/entt/core/any.hpp +++ b/src/entt/core/any.hpp @@ -138,7 +138,7 @@ class basic_any: private internal::basic_any_storage { this->instance = nullptr; } else if constexpr(stl::is_lvalue_reference_v) { deleter = nullptr; - mode = std::is_const_v> ? any_policy::cref : any_policy::ref; + mode = std::is_const_v> ? any_policy::cref : any_policy::ref; static_assert((stl::is_lvalue_reference_v && ...) && (sizeof...(Args) == 1u), "Invalid arguments"); // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) this->instance = (std::addressof(args), ...); @@ -542,7 +542,7 @@ private: */ template [[nodiscard]] std::remove_const_t any_cast(const basic_any &data) noexcept { - const auto *const instance = any_cast>(&data); + const auto *const instance = any_cast>(&data); ENTT_ASSERT(instance, "Invalid instance"); return static_cast(*instance); } @@ -551,7 +551,7 @@ template template [[nodiscard]] std::remove_const_t any_cast(basic_any &data) noexcept { // forces const on non-reference types to make them work also with wrappers for const references - auto *const instance = any_cast>(&data); + auto *const instance = any_cast>(&data); ENTT_ASSERT(instance, "Invalid instance"); return static_cast(*instance); } @@ -561,13 +561,13 @@ template // NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) [[nodiscard]] std::remove_const_t any_cast(basic_any &&data) noexcept { if constexpr(std::is_copy_constructible_v>) { - if(auto *const instance = any_cast>(&data); instance) { + if(auto *const instance = any_cast>(&data); instance) { return static_cast(stl::move(*instance)); } return any_cast(data); } else { - auto *const instance = any_cast>(&data); + auto *const instance = any_cast>(&data); ENTT_ASSERT(instance, "Invalid instance"); return static_cast(stl::move(*instance)); } diff --git a/src/entt/core/tuple.hpp b/src/entt/core/tuple.hpp index e2a7c245d..b41cfe94d 100644 --- a/src/entt/core/tuple.hpp +++ b/src/entt/core/tuple.hpp @@ -38,7 +38,7 @@ inline constexpr bool is_tuple_v = is_tuple::value; */ template constexpr decltype(auto) unwrap_tuple(Type &&value) noexcept { - if constexpr(stl::tuple_size_v> == 1u) { + if constexpr(stl::tuple_size_v> == 1u) { return std::get<0>(stl::forward(value)); } else { return stl::forward(value); diff --git a/src/entt/entity/handle.hpp b/src/entt/entity/handle.hpp index df1e5d9cb..0eb909aba 100644 --- a/src/entt/entity/handle.hpp +++ b/src/entt/entity/handle.hpp @@ -21,7 +21,7 @@ class handle_storage_iterator final { template friend class handle_storage_iterator; - using underlying_type = std::remove_reference_t; + using underlying_type = stl::remove_reference_t; using entity_type = underlying_type::entity_type; public: diff --git a/src/entt/entity/organizer.hpp b/src/entt/entity/organizer.hpp index 214f4e71e..f698d6cbf 100644 --- a/src/entt/entity/organizer.hpp +++ b/src/entt/entity/organizer.hpp @@ -91,16 +91,16 @@ struct resource_traits, type_list> { }; template -resource_traits...>, type_list> free_function_to_resource_traits(Ret (*)(Args...)); +resource_traits...>, type_list> free_function_to_resource_traits(Ret (*)(Args...)); template -resource_traits...>, type_list> constrained_function_to_resource_traits(Ret (*)(Type &, Args...)); +resource_traits...>, type_list> constrained_function_to_resource_traits(Ret (*)(Type &, Args...)); template -resource_traits...>, type_list> constrained_function_to_resource_traits(Ret (Class::*)(Args...)); +resource_traits...>, type_list> constrained_function_to_resource_traits(Ret (Class::*)(Args...)); template -resource_traits...>, type_list> constrained_function_to_resource_traits(Ret (Class::*)(Args...) const); +resource_traits...>, type_list> constrained_function_to_resource_traits(Ret (Class::*)(Args...) const); } // namespace internal /*! @endcond */ @@ -142,7 +142,7 @@ class basic_organizer final { } else if constexpr(internal::is_group_v) { return static_cast(as_group{reg}); } else { - return reg.ctx().template emplace>(); + return reg.ctx().template emplace>(); } } diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index 2ce2efa83..3b2555bad 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -41,7 +41,7 @@ class registry_storage_iterator final { template friend class registry_storage_iterator; - using mapped_type = std::remove_reference_t()->second)>; + using mapped_type = stl::remove_reference_t()->second)>; public: using value_type = stl::pair &>; diff --git a/src/entt/meta/container.hpp b/src/entt/meta/container.hpp index 3ba37d923..79e34f8c8 100644 --- a/src/entt/meta/container.hpp +++ b/src/entt/meta/container.hpp @@ -154,7 +154,7 @@ struct basic_meta_sequence_container_traits { auto *const non_const = any_cast(&it.base()); return {area, static_cast(container)->insert( non_const ? *non_const : any_cast(it.base()), - (value != nullptr) ? *static_cast(value) : *static_cast *>(cref))}; + (value != nullptr) ? *static_cast(value) : *static_cast *>(cref))}; } else { return iterator{}; } diff --git a/src/entt/meta/factory.hpp b/src/entt/meta/factory.hpp index 05b4aa6e6..ac07df456 100644 --- a/src/entt/meta/factory.hpp +++ b/src/entt/meta/factory.hpp @@ -363,7 +363,7 @@ public: id, name, /* this is never static */ - std::is_const_v> ? internal::meta_traits::is_const : internal::meta_traits::is_none, + std::is_const_v> ? internal::meta_traits::is_const : internal::meta_traits::is_none, 1u, &internal::resolve>, &meta_arg>>, diff --git a/src/entt/meta/meta.hpp b/src/entt/meta/meta.hpp index cfb6020e4..34ccf3614 100644 --- a/src/entt/meta/meta.hpp +++ b/src/entt/meta/meta.hpp @@ -459,7 +459,7 @@ public: */ template [[nodiscard]] std::remove_const_t cast() const { - auto *const instance = try_cast>(); + auto *const instance = try_cast>(); ENTT_ASSERT(instance, "Invalid instance"); return static_cast(*instance); } @@ -468,7 +468,7 @@ public: template [[nodiscard]] std::remove_const_t cast() { // forces const on non-reference types to make them work also with wrappers for const references - auto *const instance = try_cast>(); + auto *const instance = try_cast>(); ENTT_ASSERT(instance, "Invalid instance"); return static_cast(*instance); } @@ -494,7 +494,7 @@ public: */ template [[nodiscard]] meta_any allow_cast() const { - if constexpr(!std::is_reference_v || std::is_const_v>) { + if constexpr(!std::is_reference_v || std::is_const_v>) { if(storage.has_value>()) { return as_ref(); } else if(*this) { @@ -530,8 +530,8 @@ public: */ template [[nodiscard]] bool allow_cast() { - if constexpr(std::is_reference_v && !std::is_const_v>) { - return allow_cast &>() && (storage.policy() != any_policy::cref); + if constexpr(std::is_reference_v && !std::is_const_v>) { + return allow_cast &>() && (storage.policy() != any_policy::cref); } else { if(storage.has_value>()) { return true; diff --git a/src/entt/meta/node.hpp b/src/entt/meta/node.hpp index 64763f669..2ffd26b2a 100644 --- a/src/entt/meta/node.hpp +++ b/src/entt/meta/node.hpp @@ -165,7 +165,7 @@ template template [[nodiscard]] auto *look_for(const meta_context &context, const meta_type_node &node, const id_type id, bool recursive) { - using value_type = std::remove_reference_t*Member))>::value_type; + using value_type = stl::remove_reference_t*Member))>::value_type; if(node.details) { if(auto *member = find_member((node.details.get()->*Member), id); member != nullptr) { diff --git a/src/entt/meta/policy.hpp b/src/entt/meta/policy.hpp index b657a42d3..1059a382b 100644 --- a/src/entt/meta/policy.hpp +++ b/src/entt/meta/policy.hpp @@ -33,7 +33,7 @@ struct as_void_t final: private internal::meta_policy { struct as_ref_t final: private internal::meta_policy { /*! @cond ENTT_INTERNAL */ template - static constexpr bool value = std::is_reference_v && !std::is_const_v>; + static constexpr bool value = std::is_reference_v && !std::is_const_v>; /*! @endcond */ }; diff --git a/src/entt/meta/utility.hpp b/src/entt/meta/utility.hpp index 4296ce4b0..b7435a2e5 100644 --- a/src/entt/meta/utility.hpp +++ b/src/entt/meta/utility.hpp @@ -97,7 +97,7 @@ struct meta_function_descriptor type_list, type_list>, !(stl::is_same_v, Type> || std::is_base_of_v, Type>), - std::is_const_v> && (stl::is_same_v, Type> || std::is_base_of_v, Type>)> {}; + std::is_const_v> && (stl::is_same_v, Type> || std::is_base_of_v, Type>)> {}; /** * @brief Meta function descriptor. @@ -169,7 +169,7 @@ template [[nodiscard]] meta_any meta_dispatch(const meta_ctx &ctx, [[maybe_unused]] Type &&value) { if constexpr(stl::is_same_v) { static_assert(stl::is_lvalue_reference_v, "Invalid type"); - return meta_any{ctx, std::in_place_type &>, stl::as_const(value)}; + return meta_any{ctx, std::in_place_type &>, stl::as_const(value)}; } else if constexpr(stl::is_same_v || (stl::is_same_v && stl::is_lvalue_reference_v)) { return meta_any{ctx, std::in_place_type, value}; } else if constexpr(stl::is_same_v) { @@ -206,14 +206,14 @@ template template [[nodiscard]] meta_any meta_invoke(meta_any &instance, Candidate &&candidate, [[maybe_unused]] meta_any *const args, std::index_sequence) { - using descriptor = meta_function_helper_t>; + using descriptor = meta_function_helper_t>; // NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) - waiting for C++20 (and std::span) - if constexpr(std::is_invocable_v, const Type &, type_list_element_t...>) { + if constexpr(std::is_invocable_v, const Type &, type_list_element_t...>) { if(const auto *const clazz = instance.try_cast(); clazz && ((args + Index)->allow_cast>() && ...)) { return meta_invoke_with_args(instance.context(), stl::forward(candidate), *clazz, (args + Index)->cast>()...); } - } else if constexpr(std::is_invocable_v, Type &, type_list_element_t...>) { + } else if constexpr(std::is_invocable_v, Type &, type_list_element_t...>) { if(auto *const clazz = instance.try_cast(); clazz && ((args + Index)->allow_cast>() && ...)) { return meta_invoke_with_args(instance.context(), stl::forward(candidate), *clazz, (args + Index)->cast>()...); } @@ -275,7 +275,7 @@ template */ template [[nodiscard]] bool meta_setter([[maybe_unused]] meta_handle instance, [[maybe_unused]] meta_any value) { - if constexpr(std::is_member_function_pointer_v || std::is_function_v>>) { + if constexpr(std::is_member_function_pointer_v || std::is_function_v>>) { using descriptor = meta_function_helper_t; using data_type = type_list_element_t; @@ -284,7 +284,7 @@ template return true; } } else if constexpr(stl::is_member_object_pointer_v) { - using data_type = std::remove_reference_t::return_type>; + using data_type = stl::remove_reference_t::return_type>; if constexpr(!std::is_array_v && !std::is_const_v) { if(auto *const clazz = instance->try_cast(); clazz && value.allow_cast()) { @@ -293,7 +293,7 @@ template } } } else if constexpr(stl::is_pointer_v) { - using data_type = std::remove_reference_t; + using data_type = stl::remove_reference_t; if constexpr(!std::is_array_v && !std::is_const_v) { if(value.allow_cast()) { @@ -316,7 +316,7 @@ template */ template [[nodiscard]] meta_any meta_getter(meta_handle instance) { - if constexpr(std::is_member_pointer_v || std::is_function_v>>) { + if constexpr(std::is_member_pointer_v || std::is_function_v>>) { if constexpr(!std::is_array_v>>) { if constexpr(std::is_invocable_v) { if(auto *clazz = instance->try_cast(); clazz) { @@ -355,7 +355,7 @@ template */ template [[nodiscard]] meta_any meta_invoke(meta_handle instance, Candidate &&candidate, meta_any *const args) { - return internal::meta_invoke(*instance.operator->(), stl::forward(candidate), args, std::make_index_sequence>::args_type::size>{}); + return internal::meta_invoke(*instance.operator->(), stl::forward(candidate), args, std::make_index_sequence>::args_type::size>{}); } /** @@ -369,7 +369,7 @@ template */ template [[nodiscard]] meta_any meta_invoke(meta_handle instance, meta_any *const args) { - return internal::meta_invoke(*instance.operator->(), Candidate, args, std::make_index_sequence>::args_type::size>{}); + return internal::meta_invoke(*instance.operator->(), Candidate, args, std::make_index_sequence>::args_type::size>{}); } /** @@ -421,10 +421,10 @@ template [[nodiscard]] meta_any meta_construct(const meta_ctx &ctx, Candidate &&candidate, meta_any *const args) { if constexpr(meta_function_helper_t::is_static || std::is_class_v>) { meta_any placeholder{meta_ctx_arg, ctx}; - return internal::meta_invoke(placeholder, stl::forward(candidate), args, std::make_index_sequence>::args_type::size>{}); + return internal::meta_invoke(placeholder, stl::forward(candidate), args, std::make_index_sequence>::args_type::size>{}); } else { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - waiting for C++20 (and std::span) - return internal::meta_invoke(*args, stl::forward(candidate), args + 1u, std::make_index_sequence>::args_type::size>{}); + return internal::meta_invoke(*args, stl::forward(candidate), args + 1u, std::make_index_sequence>::args_type::size>{}); } } diff --git a/src/entt/stl/type_traits.hpp b/src/entt/stl/type_traits.hpp index 9803e211f..4ec1412e9 100644 --- a/src/entt/stl/type_traits.hpp +++ b/src/entt/stl/type_traits.hpp @@ -16,6 +16,7 @@ using std::is_same_v; using std::is_void_v; using std::remove_cvref_t; using std::remove_pointer_t; +using std::remove_reference_t; using std::true_type; } // namespace entt::stl