PrevUpHomeNext

utx::uniform_distribution


utx::uniform_distribution

template <utx::kspt::real_number real_type=utx::i32>
using uniform_distribution = utx::mean_t<
	std::integral<real_type>,
	std::uniform_int_distribution<real_type>,
	utx::mean_t<
		std::floating_point<real_type>,
		std::uniform_real_distribution<real_type>,
		void
	>
>;

If std::integral<real_type>, utx::uniform_distribution is the same as std::uniform_int_distribution;

if std::floating_point<real_type>, utx::uniform_distribution is the same as std::uniform_real_distribution.

Example

#include <utxcpp/core.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::f32>{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::f32>();
}

PrevUpHomeNext