From be026136db94cae3e24f4befb0c52f35941ed0d6 Mon Sep 17 00:00:00 2001 From: skypjack Date: Thu, 16 Apr 2026 15:38:50 +0200 Subject: [PATCH] stl: std::addressof --- src/entt/container/dense_set.hpp | 4 ++-- src/entt/core/any.hpp | 2 +- src/entt/core/iterator.hpp | 2 +- src/entt/entity/helper.hpp | 2 +- src/entt/entity/registry.hpp | 2 +- src/entt/entity/sparse_set.hpp | 2 +- src/entt/entity/storage.hpp | 18 +++++++++--------- src/entt/resource/resource.hpp | 6 +++--- src/entt/stl/memory.hpp | 1 + 9 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/entt/container/dense_set.hpp b/src/entt/container/dense_set.hpp index f4169b140..b8428934c 100644 --- a/src/entt/container/dense_set.hpp +++ b/src/entt/container/dense_set.hpp @@ -93,7 +93,7 @@ public: } [[nodiscard]] constexpr pointer operator->() const noexcept { - return std::addressof(operator[](0)); + return stl::addressof(operator[](0)); } [[nodiscard]] constexpr reference operator*() const noexcept { @@ -155,7 +155,7 @@ public: } [[nodiscard]] constexpr pointer operator->() const noexcept { - return std::addressof(it[static_cast(offset)].second); + return stl::addressof(it[static_cast(offset)].second); } [[nodiscard]] constexpr reference operator*() const noexcept { diff --git a/src/entt/core/any.hpp b/src/entt/core/any.hpp index 0f383ce66..561e19f1c 100644 --- a/src/entt/core/any.hpp +++ b/src/entt/core/any.hpp @@ -142,7 +142,7 @@ class basic_any: private internal::basic_any_storage { mode = stl::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), ...); + this->instance = (stl::addressof(args), ...); } else if constexpr(in_situ_v) { if constexpr(stl::is_trivially_destructible_v) { deleter = nullptr; diff --git a/src/entt/core/iterator.hpp b/src/entt/core/iterator.hpp index c8c481b76..8cbf32ede 100644 --- a/src/entt/core/iterator.hpp +++ b/src/entt/core/iterator.hpp @@ -35,7 +35,7 @@ struct input_iterator_pointer final { * @return A pointer to the wrapped value. */ [[nodiscard]] constexpr pointer operator->() noexcept { - return std::addressof(value); + return stl::addressof(value); } /** diff --git a/src/entt/entity/helper.hpp b/src/entt/entity/helper.hpp index 15b1c9e1f..3a89c2ff7 100644 --- a/src/entt/entity/helper.hpp +++ b/src/entt/entity/helper.hpp @@ -130,7 +130,7 @@ basic_storage::entity_type to_entity(const basic_storage &stor // NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) for(stl::size_t pos{}, count = storage.size(); pos < count; pos += traits_type::page_size, ++page) { - if(const auto dist = (std::addressof(instance) - *page); dist >= 0 && dist < static_cast(traits_type::page_size)) { + if(const auto dist = (stl::addressof(instance) - *page); dist >= 0 && dist < static_cast(traits_type::page_size)) { return *(static_cast::base_type &>(storage).rbegin() + static_cast(pos) + dist); } } diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index 4668eb58b..bcc9ac039 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -898,7 +898,7 @@ public: [[nodiscard]] auto try_get([[maybe_unused]] const entity_type entt) const { if constexpr(sizeof...(Type) == 1u) { const auto *cpool = assure...>(); - return (cpool && cpool->contains(entt)) ? std::addressof(cpool->get(entt)) : nullptr; + return (cpool && cpool->contains(entt)) ? stl::addressof(cpool->get(entt)) : nullptr; } else { return stl::make_tuple(try_get(entt)...); } diff --git a/src/entt/entity/sparse_set.hpp b/src/entt/entity/sparse_set.hpp index 3fe5bfd00..b89aee9d8 100644 --- a/src/entt/entity/sparse_set.hpp +++ b/src/entt/entity/sparse_set.hpp @@ -79,7 +79,7 @@ struct sparse_set_iterator final { } [[nodiscard]] constexpr pointer operator->() const noexcept { - return std::addressof(operator[](0)); + return stl::addressof(operator[](0)); } [[nodiscard]] constexpr reference operator*() const noexcept { diff --git a/src/entt/entity/storage.hpp b/src/entt/entity/storage.hpp index c6d628a5b..5cc8a411f 100644 --- a/src/entt/entity/storage.hpp +++ b/src/entt/entity/storage.hpp @@ -98,7 +98,7 @@ public: } [[nodiscard]] constexpr pointer operator->() const noexcept { - return std::addressof(operator[](0)); + return stl::addressof(operator[](0)); } [[nodiscard]] constexpr reference operator*() const noexcept { @@ -263,10 +263,10 @@ class basic_storage: public basic_sparse_set) { elem = stl::move(element_at(base_type::size() - 1u)); base_type::swap_and_pop(*first); @@ -331,7 +331,7 @@ protected: auto &other = element_at(base_type::size() - 1u); // destroying on exit allows reentrant destructors [[maybe_unused]] auto unused = stl::exchange(elem, stl::move(other)); - alloc_traits::destroy(allocator, std::addressof(other)); + alloc_traits::destroy(allocator, stl::addressof(other)); base_type::swap_and_pop(*first); } } @@ -348,11 +348,11 @@ protected: if constexpr(traits_type::in_place_delete) { if(*first != tombstone) { base_type::in_place_pop(*first); - alloc_traits::destroy(allocator, std::addressof(element_at(static_cast(first.index())))); + alloc_traits::destroy(allocator, stl::addressof(element_at(static_cast(first.index())))); } } else { base_type::swap_and_pop(*first); - alloc_traits::destroy(allocator, std::addressof(element_at(static_cast(first.index())))); + alloc_traits::destroy(allocator, stl::addressof(element_at(static_cast(first.index())))); } } } diff --git a/src/entt/resource/resource.hpp b/src/entt/resource/resource.hpp index 36ea6f2f0..d6de82f21 100644 --- a/src/entt/resource/resource.hpp +++ b/src/entt/resource/resource.hpp @@ -55,7 +55,7 @@ public: */ template resource(const resource &other, element_type &res) noexcept - : value{other.value, std::addressof(res)} {} + : value{other.value, stl::addressof(res)} {} /** * @brief Copy constructs a handle which shares ownership of the resource. @@ -168,7 +168,7 @@ public: */ template [[nodiscard]] bool operator==(const resource &other) const noexcept { - return (std::addressof(*value) == std::addressof(*other.value)); + return (stl::addressof(*value) == stl::addressof(*other.value)); } /** @@ -179,7 +179,7 @@ public: */ template [[nodiscard]] auto operator<=>(const resource &other) const noexcept { - return (std::addressof(*value) <=> std::addressof(*other.value)); + return (stl::addressof(*value) <=> stl::addressof(*other.value)); } /*! @brief Releases the ownership of the managed resource. */ diff --git a/src/entt/stl/memory.hpp b/src/entt/stl/memory.hpp index 9c2c29ba0..058b13f45 100644 --- a/src/entt/stl/memory.hpp +++ b/src/entt/stl/memory.hpp @@ -8,6 +8,7 @@ /*! @cond ENTT_INTERNAL */ namespace entt::stl { +using std::addressof; using std::allocator; using std::allocator_arg; using std::allocator_arg_t;