Bubble Sort Implementation | C-ish and Modern C++ For practice purpose, I wrote bubble sort in C++ two styles: C-ish and modern C++ compliant. I would like to have your comments on any point on these implementations.

Sorting.h


#ifndef SORTING_ALGORITHMS_H
#define SORTING_ALGORITHMS_H

#include &lt;utility&gt;
#include &lt;vector&gt;
//#include &lt;iterator&gt;
#include &lt;algorithm&gt;

namespace etpc
{
    template &lt;class T&gt;
    void sortBubble(T* pArrHead, std::size_t sArrSize)
    {
        for(std::size_t i=0; i&lt;sArrSize-1; i++)
        {
            for(std::size_t j=0; j&lt;sArrSize-i-1; j++)
            {
                if(pArrHead[j]&gt;pArrHead[j+1])
                    std::swap(pArrHead[j], pArrHead[j+1]);
            }
        }
    }

    // May 2, 2020
    // Based on the following link
    // https://rosettacode.org/wiki/Sorting_algorithms/Bubble_sort#C.2B.2B
    // typename vs class
    // https://stackoverflow.com/questions/2023977/difference-of-keywords-typename-and-class-in-templates
    template &lt;class T&gt;
    void sortBubble(std::vector&lt;T&gt;&amp; vArrHead)
    {
        typename std::vector&lt;T&gt;::iterator begin = std::begin(vArrHead);
        typename std::vector&lt;T&gt;::iterator end = std::end(vArrHead);
        while (begin != end--) {
            for (auto it = begin; it != end; ++it) {
                if (*(it + 1) &lt; *it) {
                    std::iter_swap(it, it + 1);
                }
            }
        }
    }
}
#endif // SORTING_ALGORITHMS_H


Main.cpp


#include "Sorting/include/Sorting.h"

#include &lt;iostream&gt;
#include &lt;chrono&gt;
#include &lt;iterator&gt;

int main()
{
    std::chrono::steady_clock::time_point begin;
    std::chrono::steady_clock::time_point end;
    std::ostream_iterator&lt;int&gt; out_it (std::cout,", ");

    static const int i32Size = 50;
    int arr[i32Size] = {7804, 50398, 14945, 1814, 51383, 63156, 8432, 58103, 28175, 4339, 8361, 37158, 1529, 43066, 62052, 9591, 13168, 332, 55913, 2418, 48066, 46504, 52922, 39523, 36653, 30402, 9373, 56202, 50539, 41187, 42606, 32278, 63902, 41668, 7505, 46534, 25846, 49739, 63411, 45933, 15042, 6544, 35718, 17035, 34647, 15212, 52690, 64299, 61535, 45071};
    begin = std::chrono::steady_clock::now();
    etpc::sortBubble&lt;int&gt;(arr, i32Size);
    end = std::chrono::steady_clock::now();
    std::cout &lt;&lt; "Time difference impArray = " &lt;&lt; std::chrono::duration_cast&lt;std::chrono::nanoseconds&gt;(end - begin).count() &lt;&lt; "[ns]" &lt;&lt; std::endl;
    std::copy(std::begin(arr), std::end(arr), out_it);
    std::cout &lt;&lt; '\n';

    std::vector&lt;int&gt; v = {7804, 50398, 14945, 1814, 51383, 63156, 8432, 58103, 28175, 4339, 8361, 37158, 1529, 43066, 62052, 9591, 13168, 332, 55913, 2418, 48066, 46504, 52922, 39523, 36653, 30402, 9373, 56202, 50539, 41187, 42606, 32278, 63902, 41668, 7505, 46534, 25846, 49739, 63411, 45933, 15042, 6544, 35718, 17035, 34647, 15212, 52690, 64299, 61535, 45071};
    begin = std::chrono::steady_clock::now();
    etpc::sortBubble&lt;int&gt;(v);
    end = std::chrono::steady_clock::now();
    std::cout &lt;&lt; "Time difference impVector = " &lt;&lt; std::chrono::duration_cast&lt;std::chrono::nanoseconds&gt;(end - begin).count() &lt;&lt; "[ns]" &lt;&lt; std::endl;
    std::copy(std::begin(v), std::end(v), out_it);
    std::cout &lt;&lt; '\n';

    return 0;
}
```
As you're already working with iterators you might as well accept iterators as arguments instead of the std::vector (as all STL algorithms do). That way it will work with other containers as well, even with raw pointers.

The comparison can also be customized like in std::sort. Maybe the caller wants to sort in descending order or compare structures by some field.