Selection sort implementation in C++ I was wondering if this implementation of selection sort could be improved. Are there any things that I have done wrong?

template&lt;typename Element&gt;
void selection_sort(Element arr[], size_t size) {
    auto index_toSort = 0u;
    while (index_toSort &lt; size) {
        auto index_smallest = index_toSort;
        for (auto index = index_toSort; index &lt; size; ++index) {
            if (arr[index] &lt; arr[index_smallest]) {
                index_smallest = index;
            }
        }
        std::swap(arr[index_toSort], arr[index_smallest]);
        ++index_toSort;
    }
}
In all three of your examples you limit yourself to using arrays.

This is not very C++ like (even if you templatize the object). I would change the interface to use iterators. That way your sort can be applied to any container with a random access iterator.

template&lt;typename I&gt;
void selection_sort(I begin, I end) {
    std::size_t size = std::distance(begin, end);