title: Unexpected compilation problem with g++ -std=c++0x
body: <p>I have some compilation problems pushing back elements of type T to a vector when compiling with g++ -std=c++0x.</p>
  
  <p>This is a minimal example:</p>
  
  <pre><code>#include &lt;vector&gt;
  
  using namespace std;
  
  class A {
  public:
      A() { }
  
      A&amp; operator=(A &amp;orig) {
          return *this;
      }
  };
  
  int main(int argc, char **argv) {
      A a;
      vector&lt;A&gt; b;
      A c = a; // This is fine
      b.push_back(a); // This is not, but only when compiling with -std=c++0x!
      return 0;
  }
  </code></pre>
  
  <p>It compiles fine with g++ -Wall -pedantic, but it gives this error when compiling with g++ -Wall -pedantic -std=c++0x:</p>
  
  <pre><code> In file included from /usr/include/c++/4.4/vector:69,
                   from min.cpp:1:
  /usr/include/c++/4.4/bits/vector.tcc: In member function ‘void std::vector&lt;_Tp, _Alloc&gt;::_M_insert_aux(__gnu_cxx::__normal_iterator&lt;typename std::_Vector_base&lt;_Tp, _Alloc&gt;::_Tp_alloc_type::pointer, std::vector&lt;_Tp, _Alloc&gt; &gt;, _Args&amp;&amp; ...) [with _Args = const A&amp;, _Tp = A, _Alloc = std::allocator&lt;A&gt;]’:
  /usr/include/c++/4.4/bits/stl_vector.h:741:   instantiated from ‘void std::vector&lt;_Tp, _Alloc&gt;::push_back(const _Tp&amp;) [with _Tp = A, _Alloc = std::allocator&lt;A&gt;]’
  min.cpp:20:   instantiated from here
  /usr/include/c++/4.4/bits/vector.tcc:314: error: no match for ‘operator=’ in ‘__position.__gnu_cxx::__normal_iterator&lt;_Iterator, _Container&gt;::operator* [with _Iterator = A*, _Container = std::vector&lt;A, std::allocator&lt;A&gt; &gt;]() = ((const A&amp;)((const A*)std::forward [with _Tp = const A&amp;](((const A&amp;)((const A*)__args#0)))))’
  min.cpp:11: note: candidates are: A&amp; A::operator=(A&amp;)
  In file included from /usr/include/c++/4.4/vector:61,
                   from min.cpp:1:
  /usr/include/c++/4.4/bits/stl_algobase.h: In static member function ‘static _BI2 std::__copy_move_backward&lt;true, false, std::random_access_iterator_tag&gt;::__copy_move_b(_BI1, _BI1, _BI2) [with _BI1 = A*, _BI2 = A*]’:
  /usr/include/c++/4.4/bits/stl_algobase.h:595:   instantiated from ‘_BI2 std::__copy_move_backward_a(_BI1, _BI1, _BI2) [with bool _IsMove = true, _BI1 = A*, _BI2 = A*]’
  /usr/include/c++/4.4/bits/stl_algobase.h:605:   instantiated from ‘_BI2 std::__copy_move_backward_a2(_BI1, _BI1, _BI2) [with bool _IsMove = true, _BI1 = A*, _BI2 = A*]’
  /usr/include/c++/4.4/bits/stl_algobase.h:676:   instantiated from ‘_BI2 std::move_backward(_BI1, _BI1, _BI2) [with _BI1 = A*, _BI2 = A*]’
  /usr/include/c++/4.4/bits/vector.tcc:308:   instantiated from ‘void std::vector&lt;_Tp, _Alloc&gt;::_M_insert_aux(__gnu_cxx::__normal_iterator&lt;typename std::_Vector_base&lt;_Tp, _Alloc&gt;::_Tp_alloc_type::pointer, std::vector&lt;_Tp, _Alloc&gt; &gt;, _Args&amp;&amp; ...) [with _Args = const A&amp;, _Tp = A, _Alloc = std::allocator&lt;A&gt;]’
  /usr/include/c++/4.4/bits/stl_vector.h:741:   instantiated from ‘void std::vector&lt;_Tp, _Alloc&gt;::push_back(const _Tp&amp;) [with _Tp = A, _Alloc = std::allocator&lt;A&gt;]’
  min.cpp:20:   instantiated from here
  /usr/include/c++/4.4/bits/stl_algobase.h:561: error: no match for ‘operator=’ in ‘* -- __result = std::move [with _Tp = A&amp;](((A&amp;)(-- __last)))’
  min.cpp:11: note: candidates are: A&amp; A::operator=(A&amp;)
  </code></pre>
  
  <p>So it seems that it doesn't find the right operator= of A. Why? Why it states <code>with _Iterator = A*</code> when I'm passing A?</p>