Add choose implementation for fixed size arrays

This commit is contained in:
Danny Robson 2013-08-06 12:24:00 +10:00
parent c3a268b2c3
commit d6c0a821f4

View File

@ -43,6 +43,12 @@ namespace util {
return *cursor;
}
template <typename T, size_t N>
T&
choose (T (&v)[N]) {
return v[static_cast<size_t> (random<float> () * N)];
}
template <typename T>
typename T::value_type&
choose (T begin, T end) {