Skip to content

Commit 6382c9c

Browse files
committed
also fix crypto::rand
1 parent 75f1810 commit 6382c9c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/crypto/crypto.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ namespace crypto {
171171
/* Generate a value filled with random bytes.
172172
*/
173173
template<typename T>
174-
typename std::enable_if<std::is_pod<T>::value, T>::type rand() {
174+
T rand() {
175+
static_assert(std::is_standard_layout_v<T>, "cannot write random bytes into non-standard layout type");
176+
static_assert(std::is_trivially_copyable_v<T>, "cannot write random bytes into non-trivially copyable type");
175177
typename std::remove_cv<T>::type res;
176178
generate_random_bytes_thread_safe(sizeof(T), (uint8_t*)&res);
177179
return res;

0 commit comments

Comments
 (0)