title: error: implicitly deleted because the default definition would be ill-formed (vector of structs)
body: <p>I'm having trouble getting my C++ program to compile. Would really appreciate some help with this error. In the header file, I have this:</p>
  
  <pre><code>struct workerT{
   workerT() : status(true), threadSem(0){}
   bool status;
   std::function&lt;void(void)&gt; func;
   semaphore threadSem;
  };
  
  std::vector&lt;workerT&gt; workers;
  </code></pre>
  
  <p>In my .cc file, I am trying to initialize that vector like this:</p>
  
  <pre><code>fill(workers.begin(), workers.end(), workerT());
  </code></pre>
  
  <p>This fails with the error:
  error: ‘TP::workerT&amp; TP::workerT::operator=(const TP::workerT&amp;)’ is implicitly deleted because the default definition would be ill-formed:
  It points to the semaphore.h file. Semaphore.h is defined like this:</p>
  
  <pre><code> public:
    semaphore(int value = 0);
    ....
  
  private:
    int value;
    ....
    semaphore(const semaphore&amp; orig) = delete;
    const semaphore&amp; operator=(const semaphore&amp; rhs) const = delete;
  </code></pre>
  
  <p>The program compiles if I remove the "fill" line, but I really need that because I want to initialize the vector. I get the same error message when I make a dummy struct and try to push_back into the vector. </p>
  
  <p>Update: thanks @DyP! I still need help compiling. Replaced the "fill" line with this:</p>
  
  <pre><code>std::generate(workers.begin(), workers.end(), free_func);
  </code></pre>
  
  <p>Added exactly this to my header:</p>
  
  <pre><code>workerT free_func(){
   return {};
  }
  </code></pre>
  
  <p>Getting these errors:</p>
  
  <p>thread-pool.cc: In constructor ‘ThreadPool::ThreadPool(size_t)’:
  thread-pool.cc:33:58: error: argument of type ‘ThreadPool::workerT (ThreadPool::)()’ does not match ‘ThreadPool::workerT (ThreadPool::*)()’
  In file included from /usr/include/c++/4.6/algorithm:63:0,
                   from thread-pool.cc:15:
  /usr/include/c++/4.6/bits/stl_algo.h: In function ‘void std::generate(_FIter, _FIter, _Generator) [with _FIter = __gnu_cxx::__normal_iterator >, _Generator = ThreadPool::workerT (ThreadPool::*)()]’:
  thread-pool.cc:33:58:   instantiated from here
  /usr/include/c++/4.6/bits/stl_algo.h:5013:2: error: must use ‘.<em>’ or ‘-></em>’ to call pointer-to-member function in ‘__gen (...)’, e.g. ‘(... ->* __gen) (...)’
  make: <em>*</em> [thread-pool.o] Error 1</p>
  
  <p>Update-- In my .cc file:</p>
  
  <pre><code> using namespace std;
  
   static workerT free_func(){
     return {};
   }
  
   ThreadPool(...args...){
     std::generate(workers.begin(), workers.end(), free_func);
   }
  </code></pre>
  
  <p>Errors:</p>
  
  <pre><code>thread-pool.cc:19:10: error: ‘workerT’ does not name a type
  thread-pool.cc: In constructor ‘ThreadPool::ThreadPool(size_t)’:
  thread-pool.cc:39:49: error: ‘free_func’ was not declared in this scope
  make: *** [thread-pool.o] Error 1
  </code></pre>
  
  <p>Update again:</p>
  
  <pre><code> static ThreadPool::workerT free_func(){
      return {};
   }
  
   ThreadPool(...args...){
     std::generate(workers.begin(), workers.end(), free_func);
   }
  </code></pre>
  
  <p>In thread-pool.h:</p>
  
  <pre><code> struct workerT{
   workerT() : status(true), threadSem(0){}
   bool status;
   std::function&lt;void(void)&gt; func;
   semaphore threadSem;
  };
  </code></pre>