I was wondering if this implementation of bubble sort could be improved. Are there any things that I have done wrong?
template<typename Element>
void bubble_sort(Element arr[], size_t size) {
auto sorted_elements = 1u;
bool sorted = false;
while (!sorted) {
sorted = true;
for (auto index = 0u; index < size - sorted_elements; ++index) {
if (arr[index] > arr[index + 1]) {
auto temp = arr[index + 1];
arr[index + 1] = arr[index];
arr[index] = temp;
sorted = false;
}
}
++sorted_elements;
}
}