Quick Sort on C++ vector I've seen other implementations around, but they seem pretty complicated. This seems to work for me, but is there anything I'm missing? Also, any tips on how I can improve the quality of the code is appreciated.

#include &lt;iostream&gt;
#include &lt;vector&gt;

template&lt;typename Iter&gt;
void quickSort(std::vector&lt;typename Iter::value_type&gt;&amp; vec, Iter left, 
    Iter right) {

    auto size = std::distance(left, right);
    if (size &lt;= 1) {
        return;
    }
    auto pivot = std::next(right, -1);
    if (size == 2 &amp;&amp; *pivot &lt; *left) {
        std::iter_swap(left, pivot);
    }
    auto wall = left;
    auto curr = left;

    while (curr != right) {
        if (*curr &lt; *pivot) {
            std::iter_swap(wall, curr);
            wall++;
        }
        curr++;
    }

    std::iter_swap(pivot, wall);
    quickSort(vec, left, wall);
    quickSort(vec, wall + 1, right);

}

int main() {
    std::vector&lt;int&gt; myVec = { 6, 5, 2, 3, 2, 4, 34, 2434, 251, 4, 12, 4, 5,
        634, 523, 5, 4, 353, 3, 5, 345, 7, 86786, 8, 7, 9, 1 };
    quickSort(myVec, myVec.begin(), myVec.end());
    return 0;
}
You don't need to pass the vector itself. left and right iterators provide all the necessary information.

That said, you pass a correct right: too often people pass it as .end() - 1 which indeed leads to unnecessary complications.
Partitioning is an important algorithm on its own right and deserves to be factored out.
The lines

if (size == 2 &amp;&amp; *pivot &lt; *left) {
    std::iter_swap(left, pivot);
}


serve no purpose. The code works fine without them.
The trickiest part is achieving best performance.


The poor choice of pivot may result in quadratic time complexity. In a professional implementation choosing pivot is the most complex part.
In general, C++ is very good in eliminating tail recursion, but in this particular case it may use some help. Specifically, you'd want to recurse into smaller partition, and iterate over the larger one.
Another optimization is a timely switch to insertion sort. Instead of descending all the way to size &lt;= 1 it is beneficial to stop recursion earlier (say, when size &lt;= 16). Once the recursions are completed, the range is almost sorted, and insertion sort runs in linear time.