mirror of
https://github.com/FEX-Emu/robin-map.git
synced 2024-11-27 00:10:45 +00:00
When using C++17, std::launder the reinterpreted pointer from std::aligned_storage to adapt to the change of object model introduced in P0137R1. Fix potential undefined behaviour.
C++17 introduced a change in the object model with P0137R1 which now requires the reinterpreted pointer from std::aligned_storage to be laundered. See the following discussion for some details https://stackoverflow.com/questions/47735657/does-reinterpret-casting-stdaligned-storage-to-t-without-stdlaunder-violat
This commit is contained in:
parent
c77f80b1b3
commit
4abcc978b9
@ -33,6 +33,7 @@
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <stdexcept>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
@ -249,12 +250,22 @@ class bucket_entry : public bucket_entry_hash<StoreHash> {
|
||||
|
||||
value_type& value() noexcept {
|
||||
tsl_rh_assert(!empty());
|
||||
#if defined(__cplusplus) && __cplusplus >= 201703L
|
||||
return *std::launder(
|
||||
reinterpret_cast<value_type*>(std::addressof(m_value)));
|
||||
#else
|
||||
return *reinterpret_cast<value_type*>(std::addressof(m_value));
|
||||
#endif
|
||||
}
|
||||
|
||||
const value_type& value() const noexcept {
|
||||
tsl_rh_assert(!empty());
|
||||
#if defined(__cplusplus) && __cplusplus >= 201703L
|
||||
return *std::launder(
|
||||
reinterpret_cast<const value_type*>(std::addressof(m_value)));
|
||||
#else
|
||||
return *reinterpret_cast<const value_type*>(std::addressof(m_value));
|
||||
#endif
|
||||
}
|
||||
|
||||
distance_type dist_from_ideal_bucket() const noexcept {
|
||||
|
Loading…
Reference in New Issue
Block a user