Quicksort application What do you think about this code?

#include &lt;iostream&gt;
using std::cout;
using std::endl;

#include &lt;vector&gt;
using std::vector;

#include &lt;ctime&gt;
#include &lt;cstdlib&gt;

template &lt; typename T &gt;
vector &lt; T &gt; concatenate( vector &lt; T &gt; _a_, T piv, vector &lt; T &gt; _b_ )
{
  vector &lt; T &gt; v_list;
  v_list.insert( v_list.begin(), _a_.begin(), _a_.end() );
  v_list.push_back( piv );
  v_list.insert( v_list.end(), _b_.begin(), _b_.end() );
  return v_list;
}

template &lt; typename T &gt; 
vector&lt; T &gt; quick( vector&lt; T &gt; vec )
{
  vector&lt; T &gt; v_less, v_greater, v_list;
  vector&lt; T &gt; aux1, aux2;
  typename vector &lt; T &gt;::const_iterator iter_Const;
  if( vec.size() &lt;= 1 )
    return vec;
  int piv = *(vec.end() - 1);
  vec.pop_back();
  for( iter_Const = vec.begin(); iter_Const != vec.end(); ++iter_Const )
  {
    if( *iter_Const &lt; piv )
      v_less.push_back( *iter_Const );
    else
      v_greater.push_back( *iter_Const );  
  }
  return concatenate( quick( v_less ), piv, quick( v_greater ) );  
}

int main() {
  vector &lt; int &gt; lista;
  srand( 1 );
  cout &lt;&lt; "VECTOR" &lt;&lt; endl;
  for( int i = 0; i &lt; 10000; i++ )
  {
      lista.push_back( rand() % 100 );
      cout &lt;&lt; lista[i] &lt;&lt; " | ";
  }
  cout &lt;&lt; endl;
  cout &lt;&lt; "******" &lt;&lt; endl;
  cout &lt;&lt; "QUICKSORT" &lt;&lt; endl;
  lista = quick( lista );
  vector &lt; int &gt; :: const_iterator it;
  for( it = lista.begin(); it != lista.end(); ++it )
    cout &lt;&lt; *it &lt;&lt; " | ";
  cout &lt;&lt; endl;
}
If this is not just a learning exercise, I have to point out that C++ already has a sorting function in its standard library and in real code you should use that. So for the rest of this answer I'm going to assume that this is in fact just a learning exercise.

Now first a note on the algorithm: Usually quicksort is implemented in-place for better performance. Even if you want a sorting function which does not modify its argument, it's quicker to just copy the argument and then run an in-place quicksort on the argument.

Further you're creating a lot more copies of your vectors than you need to, even when using this choice of algorithm: Every time you pass a vector by value, it is copied. Every time you pass a vector, which you do not want to modify, you should rather pass it by const reference, so as not to create an unnecessary copy.

On the same note concatenate also creates an unnecessary copy by returning the result vector by value. This can be avoided by passing an empty vector by non-const reference and filling that instead of using a return value.

Lastly there is a bit of code duplication in your main function: You're printing a vector separated by pipes twice - once during its creation and once after sorting. I would define a helper function print_vector, which prints a vector separated by pipes, and call that twice: once after creating the vector and once after sorting it. This way the first printing will have to happen after the vector creation, not during, but that's okay as doing it during the creation gives very little performance benefit (if any) and having the creation be a separate step from printing the vector improves code cleanliness.