title: Why is it impossible to assign to a vector of objects that themselves lack copy operator?
body: <p>I have a vector of structures that are copy-constructible, but non-assignable:</p>
  
  <pre><code>struct Struct
  {
      inline Struct(const std::string&amp; text, int n) : _text(text), _n(n) {}
      inline Struct(const Struct&amp; other) : _text(other._text), _n(other._n) {}
  
      const std::string _text;
      const int _n;
  
      Struct&amp; operator=(const Struct&amp;) = delete;
  };
  </code></pre>
  
  <p>It all worked fine. In fact, I could even pass the <code>std::vector&lt;Struct&gt;</code> around by value as a return value of a function. And yet, this fails:</p>
  
  <pre><code>std::vector&lt;TextFragment&gt; v1, v2;
  v2 = v1;
  </code></pre>
  
  <p>The error, of course, is:</p>
  
  <blockquote>
    <p>error: C2280: 'Struct &amp;Struct ::operator =(const Struct &amp;)' :
    attempting to reference a deleted function</p>
  </blockquote>
  
  <p>I don't understand why it tries to invoke that. Is that some kind of an optimization to avoid re-allocating the vector's memory block?..</p>