robin-map icon indicating copy to clipboard operation
robin-map copied to clipboard

aligned_storage is deprecated by C++23

Open qdztxc opened this issue 2 years ago • 2 comments

template <typename ValueType, bool StoreHash> class bucket_entry : public bucket_entry_hash<StoreHash> { using bucket_hash = bucket_entry_hash<StoreHash>;

public: using value_type = ValueType; using distance_type = std::int16_t;

..................................................................................

private: using storage = typename std::aligned_storage<sizeof(value_type), alignof(value_type)>::type;

distance_type m_dist_from_ideal_bucket; bool m_last_bucket; storage m_value; };

visual studio 2022 v17.3.0 preview reported this as error.

Severity Code Description Project File Line Suppression State Error C4996 'std::aligned_storage<8,4>': warning STL4034: std::aligned_storage and std::aligned_storage_t are deprecated in C++23. Prefer alignas(T) std::byte t_buff[sizeof(T)]. You can define _SILENCE_CXX23_ALIGNED_STORAGE_DEPRECATION_WARNING or _SILENCE_ALL_CXX23_DEPRECATION_WARNINGS to acknowledge that you have received this warning. MDTest D:\STHFT\3rd\include\tsl\robin_hash.h 334

qdztxc avatar Aug 05 '22 09:08 qdztxc

may change to

private: distance_type m_dist_from_ideal_bucket; bool m_last_bucket; alignas(value_type) std::byte m_value[sizeof(value_type)];

qdztxc avatar Aug 05 '22 09:08 qdztxc

reference: https://www.editcode.net/ask/245020.html

qdztxc avatar Aug 05 '22 09:08 qdztxc

Thanks, I fixed the issue.

Tessil avatar Dec 18 '22 18:12 Tessil