diff --git a/src/random.hpp b/src/random.hpp index 15f4a69..a47181c 100644 --- a/src/random.hpp +++ b/src/random.hpp @@ -31,6 +31,12 @@ namespace sc { return vec[dist(instance()._reng)]; } + template + T choice(Iter from, Iter to) { + std::uniform_int_distribution dist {0, static_cast(to - from) - 1}; + return *(from + dist(instance()._reng)); + } + private: static random singleton;