Skip to content

Commit

Permalink
also fix crypto::rand
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffro256 committed Aug 23, 2024
1 parent 75f1810 commit 6382c9c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/crypto/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ namespace crypto {
/* Generate a value filled with random bytes.
*/
template<typename T>
typename std::enable_if<std::is_pod<T>::value, T>::type rand() {
T rand() {
static_assert(std::is_standard_layout_v<T>, "cannot write random bytes into non-standard layout type");
static_assert(std::is_trivially_copyable_v<T>, "cannot write random bytes into non-trivially copyable type");
typename std::remove_cv<T>::type res;
generate_random_bytes_thread_safe(sizeof(T), (uint8_t*)&res);
return res;
Expand Down

0 comments on commit 6382c9c

Please sign in to comment.