title: swap() function not working on a vector object passed by reference c++
body: <p>When I try to use swap() in in the function partitionk(), I get the error</p>
  
  <p>" error: request for member 'swap' in '(&amp; num_list)->std::vector&lt;_Tp, _Alloc>::operator[] >(((std::vector::size_type)endn))', which is of non-class type '__gnu_cxx::__alloc_traits >::value_type {aka int}'|  " `</p>
  
  <pre><code>enter code here
  
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;unordered_map&gt;
  #include &lt;cstdlib&gt;
  using namespace std;
  
  int partitionk(vector&lt;int&gt;&amp; num_list , int start, int endn  ) {
          int pindex = start;
          int rand_num  = rand( ) % endn;
          num_list[endn].swap(num_list[rand_num]);    // getting error
  
          for (int i = 1 ; i &lt; endn ; i++){
              if ( num_list[i] &lt; num_list[endn] ){
                  num_list[i].swap( num_list[pindex] );   // getting error
                  pindex += 1;
              }
          }
          num_list[endn].swap(num_list[pindex]);      // getting error
          return pindex;
  }
  
  void quick_sort( vector&lt;int&gt;&amp; num_list , int start,  int endn   ){
         if (start &gt;= endn) return ;
  
         else{
               int index = partitionk(  num_list ,  start, endn  )   ;
  
                quick_sort( num_list ,  start, index );
               quick_sort( num_list , index+1,  endn  );
  
         }
  }
  
  int main()
  {
      vector &lt;int&gt; nums= {4,7,1,3,9,5};
      quick_sort(nums , 0 , nums.size()-1 );
  
      for (auto i : nums){
          cout &lt;&lt; i &lt;&lt; " ";
      }
  
  }
  </code></pre>