I have a simple function to shuffle elements in an std::array
template <typename T, uint size>
void Shuffle(std::array<T, size> &arr) {
for (uint i = 0; i < arr.size() - 1; i++)
{
std::swap(arr[i], arr[Random(i, arr.size())]);
}
}
make/g++ doesn't like the way I'm declaring this, giving the error "variable or field Shuffle declared void." From what I've found, this is probably an irrelevant error message, but I can't figure out what's actually wrong here.
uinta defined type? Did you try replacing it withstd::size_t?arr.size() - 1will underflow and will lead to a very long loop and invalid array access. Consider writingi + 1 < arr.size()instead.