Add random::uniform<bool>(RNG)
This commit is contained in:
parent
fd336dfde2
commit
abb95f87ae
1 changed files with 8 additions and 1 deletions
|
|
@ -30,7 +30,14 @@ namespace psemek::random
|
|||
template <typename T, typename RNG>
|
||||
T uniform(RNG && rng)
|
||||
{
|
||||
return uniform<T>(rng, T{0}, T{1});
|
||||
if constexpr (std::is_same_v<T, bool>)
|
||||
{
|
||||
return uniform<char>(rng, 0, 1) == 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return uniform<T>(rng, T{0}, T{1});
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, std::size_t N, typename RNG>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue