title: error: assignment of read-only reference ‘__b’
body: <pre><code>void customsort()
  {
      int a = 0;
      int b = 0;
      vector&lt;pair&lt;int, int&gt; &gt;::const_iterator it1,it2;
      for(it1 = temp.begin();it1&lt;temp.end();it1++)
          for(it2 = temp.begin()+1;it2&lt;temp.end();it2++)
              {
                  a = it1-&gt;first+it1-&gt;second;
                  b = it2-&gt;first+it2-&gt;second;     
                  if(a&gt;b)
                  {   
                      swap(it1-&gt;first, it2-&gt;first);
                      swap(it1-&gt;second, it2-&gt;second);
                  }
              }   
  }
  </code></pre>
  
  <p>this is the code </p>
  
  <p>what i am trying to do is swap a paired vector</p>
  
  <p>for example </p>
  
  <p>say i have a [1,1], [1,2], [2,0], [3,2]</p>
  
  <p>i want to sort them based on their sum (ascending order)</p>
  
  <p>BUT 
  i am getting an error</p>
  
  <blockquote>
  <pre><code>In file included from /usr/include/c++/4.8/bits/stl_pair.h:59:0,
                   from /usr/include/c++/4.8/bits/stl_algobase.h:64,
                   from /usr/include/c++/4.8/bits/char_traits.h:39,
                   from /usr/include/c++/4.8/ios:40,
                   from /usr/include/c++/4.8/ostream:38,
                   from /usr/include/c++/4.8/iostream:39,
                   from prog1.cpp:1:
  /usr/include/c++/4.8/bits/move.h: In instantiation of ‘void std::swap(_Tp&amp;, _Tp&amp;) [with _Tp = const int]’:
  prog1.cpp:23:34:   required from here
  /usr/include/c++/4.8/bits/move.h:176:11: error: assignment of read-only reference ‘__a’
         __a = _GLIBCXX_MOVE(__b);
             ^
  /usr/include/c++/4.8/bits/move.h:177:11: error: assignment of read-only reference ‘__b’
         __b = _GLIBCXX_MOVE(__tmp);
  </code></pre>
  </blockquote>
  
  <p>Thanks in Advance </p>