Tessil / robin-map

C++ implementation of a fast hash map and hash set using robin hood hashing
MIT License
1.28k stars 118 forks source link

aligned_storage is deprecated by C++23 #57

Closed qdztxc closed 1 year ago

qdztxc commented 2 years ago

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

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 commented 2 years ago

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 commented 2 years ago

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

Tessil commented 1 year ago

Thanks, I fixed the issue.