C++11 Quicksort any container As the title says, simple quicksort to help myself get used to C++ templates and iterators.  Main concern is whether there's a better way to template so that you can have a simple function (e.g. quicksort) that accepts any container type (specifically should I have some kind of assert or more complicated template to make sure the arguments are in fact iterators?)  Also note that it is inclusive of the end value, so to sort a whole container the call is qsort(c.begin(), c.end()-1).  

template &lt;typename Iter&gt; Iter partition(Iter start, Iter end){
    Iter pivot = start;
    Iter cur = start;
    while (cur &lt; end) {
        if(*cur &lt;= *end){
            std::swap(*cur,*pivot);
            pivot++;
        }
        cur++;
    }
    std::swap(*pivot, *end);
    return pivot;
}

template &lt;typename Iter&gt; void qsort(Iter start, Iter end){
    if(end &gt; start) {
        Iter p = partition(start, end);
        qsort(start, p - 1);
        qsort(p + 1, end);
    }   
}
If you make restriction only for ForwardIterators you can't call c.end()-1 from your question. It would be probably difficult to sort the whole container.