Last active
November 3, 2020 21:20
-
-
Save klmr/62863c3d9f5827df23ae2e1415b0cb1b to your computer and use it in GitHub Desktop.
Revisions
-
klmr revised this gist
Aug 18, 2020 . 1 changed file with 4 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,14 @@ #include <algorithm> #include <array> #include <functional> #include <random> template <typename T = std::mt19937> auto get_random_generator() -> T { auto constexpr seed_bytes = sizeof(typename T::result_type) * T::state_size; auto constexpr seed_len = seed_bytes / sizeof(std::seed_seq::result_type); auto seed = std::array<std::seed_seq::result_type, seed_len>(); auto dev = std::random_device(); std::generate_n(begin(seed), seed_len, std::ref(dev)); auto seed_seq = std::seed_seq(begin(seed), end(seed)); return T{seed_seq}; -
klmr revised this gist
Aug 18, 2020 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,13 @@ #include <algorithm> #include <climits> #include <array> #include <functional> #include <limits> #include <random> template <typename T = std::mt19937> auto get_random_generator() -> T { auto constexpr seed_bits = sizeof(typename T::result_type) * CHAR_BIT * T::state_size; auto constexpr seed_len = seed_bits / std::numeric_limits<std::seed_seq::result_type>::digits; auto seed = std::array<std::seed_seq::result_type, seed_len>{}; auto dev = std::random_device{}; -
klmr created this gist
Mar 17, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ #include <algorithm> #include <array> #include <functional> #include <limits> #include <random> template <typename T = std::mt19937> auto get_random_generator() -> T { auto constexpr seed_bits = sizeof(typename T::result_type) * T::state_size; auto constexpr seed_len = seed_bits / std::numeric_limits<std::seed_seq::result_type>::digits; auto seed = std::array<std::seed_seq::result_type, seed_len>{}; auto dev = std::random_device{}; std::generate_n(begin(seed), seed_len, std::ref(dev)); auto seed_seq = std::seed_seq(begin(seed), end(seed)); return T{seed_seq}; }