File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 33
33
#include < cstddef>
34
34
#include < cstring>
35
35
#include < functional>
36
+ #include < memory>
36
37
#include < sodium/crypto_verify_32.h>
37
38
38
39
#define CRYPTO_MAKE_COMPARABLE (type ) \
@@ -60,14 +61,18 @@ namespace crypto { \
60
61
namespace crypto { \
61
62
static_assert (sizeof (std::size_t ) <= sizeof (type), " Size of " #type " must be at least that of size_t" ); \
62
63
inline std::size_t hash_value (const type &_v) { \
63
- return reinterpret_cast <const std::size_t &>(_v); \
64
+ std::size_t h; \
65
+ memcpy (&h, std::addressof (_v), sizeof (h)); \
66
+ return h; \
64
67
} \
65
68
} \
66
69
namespace std { \
67
70
template <> \
68
71
struct hash <crypto::type> { \
69
72
std::size_t operator ()(const crypto::type &_v) const { \
70
- return reinterpret_cast <const std::size_t &>(_v); \
73
+ std::size_t h; \
74
+ memcpy (&h, std::addressof (_v), sizeof (h)); \
75
+ return h; \
71
76
} \
72
77
}; \
73
78
}
You can’t perform that action at this time.
0 commit comments