changed return from choice to const ref
This commit is contained in:
parent
94043b3aac
commit
145a056a3b
@ -26,13 +26,13 @@ namespace sc {
|
|||||||
static double double_between(double from, double to);
|
static double double_between(double from, double to);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static T choice(const std::vector<T>& vec) {
|
static const T& choice(const std::vector<T>& vec) {
|
||||||
std::uniform_int_distribution<int> dist {0, static_cast<int>(vec.size()) - 1};
|
std::uniform_int_distribution<int> dist {0, static_cast<int>(vec.size()) - 1};
|
||||||
return vec[dist(instance()._reng)];
|
return vec[dist(instance()._reng)];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename Iter>
|
template <typename T, typename Iter>
|
||||||
static T choice(Iter from, Iter to) {
|
static const T& choice(Iter from, Iter to) {
|
||||||
std::uniform_int_distribution<int> dist {0, static_cast<int>(to - from) - 1};
|
std::uniform_int_distribution<int> dist {0, static_cast<int>(to - from) - 1};
|
||||||
return *(from + dist(instance()._reng));
|
return *(from + dist(instance()._reng));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user