stl: std::addressof
This commit is contained in:
@@ -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<difference_type>(offset)].second);
|
||||
return stl::addressof(it[static_cast<difference_type>(offset)].second);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr reference operator*() const noexcept {
|
||||
|
||||
@@ -142,7 +142,7 @@ class basic_any: private internal::basic_any_storage<Len, Align> {
|
||||
mode = stl::is_const_v<stl::remove_reference_t<Type>> ? any_policy::cref : any_policy::ref;
|
||||
static_assert((stl::is_lvalue_reference_v<Args> && ...) && (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<plain_type>) {
|
||||
if constexpr(stl::is_trivially_destructible_v<plain_type>) {
|
||||
deleter = nullptr;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -130,7 +130,7 @@ basic_storage<Args...>::entity_type to_entity(const basic_storage<Args...> &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<decltype(dist)>(traits_type::page_size)) {
|
||||
if(const auto dist = (stl::addressof(instance) - *page); dist >= 0 && dist < static_cast<decltype(dist)>(traits_type::page_size)) {
|
||||
return *(static_cast<const basic_storage<Args...>::base_type &>(storage).rbegin() + static_cast<decltype(dist)>(pos) + dist);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<stl::remove_const_t<Type>...>();
|
||||
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<Type>(entt)...);
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<Entity, typename stl::allocator_tra
|
||||
for(auto pos = sz, length = base_type::size(); pos < length; ++pos) {
|
||||
if constexpr(traits_type::in_place_delete) {
|
||||
if(base_type::data()[pos] != tombstone) {
|
||||
alloc_traits::destroy(allocator, std::addressof(element_at(pos)));
|
||||
alloc_traits::destroy(allocator, stl::addressof(element_at(pos)));
|
||||
}
|
||||
} else {
|
||||
alloc_traits::destroy(allocator, std::addressof(element_at(pos)));
|
||||
alloc_traits::destroy(allocator, stl::addressof(element_at(pos)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,12 +288,12 @@ class basic_storage: public basic_sparse_set<Entity, typename stl::allocator_tra
|
||||
auto &elem = element_at(lhs);
|
||||
allocator_type allocator{get_allocator()};
|
||||
entt::uninitialized_construct_using_allocator(stl::to_address(assure_at_least(rhs)), allocator, stl::move(elem));
|
||||
alloc_traits::destroy(allocator, std::addressof(elem));
|
||||
alloc_traits::destroy(allocator, stl::addressof(elem));
|
||||
}
|
||||
|
||||
private:
|
||||
[[nodiscard]] const void *get_at(const stl::size_t pos) const final {
|
||||
return std::addressof(element_at(pos));
|
||||
return stl::addressof(element_at(pos));
|
||||
}
|
||||
|
||||
void swap_or_move([[maybe_unused]] const stl::size_t from, [[maybe_unused]] const stl::size_t to) override {
|
||||
@@ -323,7 +323,7 @@ protected:
|
||||
|
||||
if constexpr(traits_type::in_place_delete) {
|
||||
base_type::in_place_pop(*first);
|
||||
alloc_traits::destroy(allocator, std::addressof(elem));
|
||||
alloc_traits::destroy(allocator, stl::addressof(elem));
|
||||
} else if constexpr(stl::is_trivially_destructible_v<element_type>) {
|
||||
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<size_type>(first.index()))));
|
||||
alloc_traits::destroy(allocator, stl::addressof(element_at(static_cast<size_type>(first.index()))));
|
||||
}
|
||||
} else {
|
||||
base_type::swap_and_pop(*first);
|
||||
alloc_traits::destroy(allocator, std::addressof(element_at(static_cast<size_type>(first.index()))));
|
||||
alloc_traits::destroy(allocator, stl::addressof(element_at(static_cast<size_type>(first.index()))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
*/
|
||||
template<typename Other>
|
||||
resource(const resource<Other> &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<typename Other>
|
||||
[[nodiscard]] bool operator==(const resource<Other> &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<typename Other>
|
||||
[[nodiscard]] auto operator<=>(const resource<Other> &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. */
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user