Skip to content

Commit 38d439a

Browse files
committed
add std::launder
1 parent 097c433 commit 38d439a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ExcaliburHash/ExcaliburHash.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ template <typename TKey, typename TValue, unsigned kNumInlineItems = 1, typename
7474

7575
static inline constexpr uint32_t k_MinNumberOfBuckets = 16;
7676

77-
template <typename T, class... Args> static void construct(void* EXLBR_RESTRICT ptr, Args&&... args)
77+
template <typename T, class... Args> static T* construct(void* EXLBR_RESTRICT ptr, Args&&... args)
7878
{
79-
new (ptr) T(std::forward<Args>(args)...);
79+
return new (ptr) T(std::forward<Args>(args)...);
8080
}
8181
template <typename T> static void destruct(T* EXLBR_RESTRICT ptr) { ptr->~T(); }
8282

@@ -105,7 +105,7 @@ template <typename TKey, typename TValue, unsigned kNumInlineItems = 1, typename
105105
[[nodiscard]] inline TValue* value() noexcept
106106
{
107107
TValue* value = reinterpret_cast<TValue*>(&m_value);
108-
return value;
108+
return std::launder(value);
109109
}
110110
};
111111
};
@@ -278,7 +278,7 @@ template <typename TKey, typename TValue, unsigned kNumInlineItems = 1, typename
278278
TItem* otherInlineItem = (otherInlineItems + i);
279279
const bool hasValidValue = otherInlineItem->isValid();
280280
// move construct key
281-
construct<TItem>((inlineItems + i), std::move(*otherInlineItem->key()));
281+
inlineItem = construct<TItem>(inlineItem, std::move(*otherInlineItem->key()));
282282

283283
// move inline storage value (if any)
284284
if (hasValidValue)

0 commit comments

Comments
 (0)