From 145a056a3b3f3604215cedfb3fc364332d2840de Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Thu, 2 Dec 2021 18:14:34 +0100 Subject: [PATCH] changed return from choice to const ref --- src/random.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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)); }