diff --git a/src/random.hpp b/src/random.hpp index aada12e..a040802 100644 --- a/src/random.hpp +++ b/src/random.hpp @@ -2,6 +2,7 @@ #define RANDOM_H_ #include +#include namespace sc { @@ -24,10 +25,10 @@ namespace sc { double random_double(); double random_double(double from, double to); - template - T choice(Iter beg, Iter end) { - std::uniform_int_distribution dist {0, end - beg - 1}; - return beg + dist(_reng); + template + static T choice(const std::vector& vec) { + std::uniform_int_distribution dist {0, vec.size() - 1}; + return vec[dist(instance()._reng)]; } private: