Imagine the following scenario:
std::atomic<int> values[10];
std::size_t indices[10];
void sort() {
std::iota(indices, indices+10, 0);
std::sort(indices, indices+10,
[&](size_t lhs, size_t rhs) { return values[lhs] < values[rhs]; });
}
While running the sort()
, another thread is changing values
. Will this merely result in indices not being correctly ordered afterwards, or is it actually undefined behaviour?