title: C++ Error: use of deleted function during constructor call of custom class
body: <p>I have a custom class <code>producer</code> which inherits from SystemC class <code>sc_module</code>:</p>
  
  <pre><code>class producer: public sc_module {
      public:
          int counter;
          sc_in&lt;bool&gt; clock;
          sc_out&lt;msg&gt; out;
          int speed;
  
          producer(sc_module_name name, int speed) : 
              sc_module(name), 
              speed(speed) 
          {
              SC_HAS_PROCESS(producer);
              SC_METHOD(produce);
  
              sensitive &lt;&lt; clock.pos();
              counter = 0;
          }
  
          void produce() {
              ...
          }
  
  };
  </code></pre>
  
  <p>Later in the SystemC <code>sc_main</code>-class I want to put a bunch of objects in a <code>std::vector&lt;producer&gt;</code>:</p>
  
  <pre><code>std::vector&lt;producer&gt; producers;
  for(int i = 0; i &lt; numIn; i++){
      producers.at(i) = producer("Producer " + i, genSpeed); // &lt;- Here the error occurs
  }
  </code></pre>
  
  <p>And here is the compiler error:</p>
  
  <pre><code>error: use of deleted function ‘producer&amp; producer::operator=(producer&amp;&amp;)’
           producers.at(i) = producer("Producer " + i, genSpeed);
                                                               ^
  dist.cpp:103:7: note: ‘producer&amp; producer::operator=(producer&amp;&amp;)’ is implicitly deleted because the default definition would be ill-formed:
   class producer: public sc_module {
         ^~~~~~~~
  </code></pre>
  
  <p>Why does the error occur? How can I fix it?</p>