diff --git a/src/random.hpp b/src/random.hpp index 894f458..cb7c3d4 100644 --- a/src/random.hpp +++ b/src/random.hpp @@ -26,13 +26,13 @@ namespace sc { static double double_between(double from, double to); template - static T choice(const std::vector& vec) { + static const T& choice(const std::vector& vec) { std::uniform_int_distribution dist {0, static_cast(vec.size()) - 1}; return vec[dist(instance()._reng)]; } template - static T choice(Iter from, Iter to) { + static const T& choice(Iter from, Iter to) { std::uniform_int_distribution dist {0, static_cast(to - from) - 1}; return *(from + dist(instance()._reng)); }