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; 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> template <typename T>
typename T::value_type& typename T::value_type&
choose (T begin, T end) { choose (T begin, T end) {