Skip to content

Commit

Permalink
fix msvc compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian LALU committed Jan 14, 2025
1 parent 51d761b commit 60de51e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion interface/core/containers/hashset.h
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ namespace hud
group_type group {ctrl};
for (u32 full_index : group.mask_of_full_slot())
{
hud::memory::destroy(slot_ptr_[full_index]);
hud::memory::destroy(slot_ptr_ + full_index);
--remaining_slots;
}
ctrl += group_type::SLOT_PER_GROUP;
Expand Down
4 changes: 2 additions & 2 deletions interface/core/containers/optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace hud
{
if (this_as_base_t()->some)
{
hud::memory::destroy(this_as_base_t()->some_value);
hud::memory::destroy(&this_as_base_t()->some_value);
this_as_base_t()->some = false;
}
}
Expand Down Expand Up @@ -224,7 +224,7 @@ namespace hud
{
if (some)
{
hud::memory::destroy(some_value);
hud::memory::destroy(&some_value);
}
}

Expand Down
2 changes: 1 addition & 1 deletion interface/core/containers/shared_pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ namespace hud
/** Destroy the object by calling the destructor. */
constexpr void destroy_object() noexcept final
{
hud::memory::destroy(*pointer());
hud::memory::destroy(pointer());
}

private:
Expand Down
8 changes: 4 additions & 4 deletions interface/core/memory/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -925,12 +925,12 @@ namespace hud
*/
template<typename type_t>
requires(is_destructible_v<type_t> && !hud::is_pointer_v<type_t>)
static constexpr void destroy(type_t &obj) noexcept
static constexpr void destroy(type_t *obj) noexcept
{
if constexpr (!hud::is_trivially_destructible_v<type_t>)
{
static_assert(hud::is_nothrow_destructible_v<type_t>, "type_t destructor is throwable.hud::memory::destroy is not designed to allow throwable destructible type");
obj.~type_t();
obj->~type_t();
}
}

Expand All @@ -949,7 +949,7 @@ namespace hud
{
while (count)
{
hud::memory::destroy<type_t>(*address);
hud::memory::destroy<type_t>(address);
address++;
count--;
}
Expand Down Expand Up @@ -1128,7 +1128,7 @@ namespace hud
static constexpr void move_or_copy_construct_then_destroy(type_t *destination, u_type_t &&source) noexcept
{
hud::memory::construct_at<type_t, u_type_t>(destination, hud::forward<u_type_t>(source));
hud::memory::destroy<u_type_t>(source);
hud::memory::destroy<u_type_t>(&source);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions test/memory/memory_destroy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GTEST_TEST(memory, destroy_trivial_type)
auto test = []() -> ResultType
{
type to_destroy = 15;
hud::memory::destroy(to_destroy);
hud::memory::destroy(&to_destroy);
return to_destroy;
};

Expand Down Expand Up @@ -46,7 +46,7 @@ GTEST_TEST(memory, destroy_trivially_destructible_type)
{
type to_destroy;
to_destroy.i = 15;
hud::memory::destroy(to_destroy);
hud::memory::destroy(&to_destroy);
return to_destroy.i;
};

Expand Down Expand Up @@ -77,7 +77,7 @@ GTEST_TEST(memory, destroy_non_trivially_destructible_type)
type *to_destroy = hud::memory::allocate_array<type>(1);
hud_test::LeakArrayGuard guard(to_destroy, 1);
hud::memory::construct_at(to_destroy, &is_destructor_called);
hud::memory::destroy(*to_destroy);
hud::memory::destroy(to_destroy);
return is_destructor_called;
};

Expand Down

0 comments on commit 60de51e

Please sign in to comment.