utx::uniform_distribution is a class derived from std::uniform_int_distribution or std::uniform_real_distribution. Which base_type is is choosed is determined by template specialization.
The advantage of using utx::uniform_distribution is that it does not only unify std::uniform_int_distribution and std::uniform_real_distribution in one class, but also supports utx::real_meric types.
utx::uniform_distribution has almost the same usage of std::uniform_int_distribution or std::uniform_real_distribution, all of the methods are derived from them properly.
template <utx::real_meric type_xt = utx::i32> requires (sizeof (type_xt) > 1) class uniform_distribution: public ...;
If std::integral_meric<real_type>, utx::uniform_distribution is derived from std::uniform_int_distribution;
if std::floating_meric<real_type>, utx::uniform_distribution is derived from std::uniform_real_distribution.
#include <utxcpp/core.hpp> #include <utxcpp/random.hpp> int main() { // std::mt19937 works too. auto rng = std::mt19937_64{std::random_device{}()}; auto dist1 = utx::uniform_distribution<>{100,200}; auto dist2 = utx::uniform_distribution<utx::i64>{50,150}; auto dist3 = utx::uniform_distribution<utx::fx32>{300,400}; utx::print(dist1(rng), dist2(rng), dist3(rng)); utx::same_strip_assert<decltype(dist1(rng)), utx::i32>(); utx::same_strip_assert<decltype(dist2(rng)), utx::i64>(); utx::same_strip_assert<decltype(dist3(rng)), utx::fx32>(); }