generate_random_number = c++20 now 💪

master
CompiledCode 3 years ago
parent 9e4b176950
commit db933b9f20

@ -5,7 +5,10 @@ This repo contains a list of utils that will probably need to be implimented for
* llo::utils::generate_random_number, generate a random numerical value. * llo::utils::generate_random_number, generate a random numerical value.
```cpp ```cpp
template<typename number_t, typename = std::enable_if_t<std::is_arithmetic_v<number_t>, number_t>> template <typename number_t>
concept is_arithmetic_t = std::is_arithmetic_v<number_t>;
template <is_arithmetic_t number_t>
number_t generate_random_number(const number_t minimum, const number_t maximum) number_t generate_random_number(const number_t minimum, const number_t maximum)
{ {
using uniform_distribution_t = std::conditional_t<std::is_integral_v<number_t>, std::uniform_int_distribution<number_t>, std::uniform_real_distribution<number_t>>; using uniform_distribution_t = std::conditional_t<std::is_integral_v<number_t>, std::uniform_int_distribution<number_t>, std::uniform_real_distribution<number_t>>;

Loading…
Cancel
Save