We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 75f1810 commit 6382c9cCopy full SHA for 6382c9c
src/crypto/crypto.h
@@ -171,7 +171,9 @@ namespace crypto {
171
/* Generate a value filled with random bytes.
172
*/
173
template<typename T>
174
- typename std::enable_if<std::is_pod<T>::value, T>::type rand() {
+ 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");
177
typename std::remove_cv<T>::type res;
178
generate_random_bytes_thread_safe(sizeof(T), (uint8_t*)&res);
179
return res;
0 commit comments