title: Copy or Move Constructor for a class with a member std::mutex (or other non-copyable object)?
body: <pre><code>class A
  {
  private:
      class B
      {
      private:
          std::mutex mu;
          A* parent = NULL;
      public:
          B(A* const parent_ptr): parent(parent_ptr) {}
          B(const A::B &amp; b_copy) { /* I thought I needed code here */  }
      };
  public:
      B b = B(this); //...to make this copy instruction work. 
                     // (Copy constructor is deleted, need to declare a new one?)
  };
  </code></pre>
  
  <p>I have a class  <code>B</code> that is basically a thread-safe task queue. It contains a <code>deque</code>, a <code>mutex</code>, and a <code>condition_variable</code>. It facilitates a consumer/producer relationship between any two threads that are started by the class <code>A</code>. I have simplified the code as much as possible.</p>
  
  <p>The problem starts with having a <code>mutex</code> as a member: this deletes the default copy constructor. This just means I can construct using <code>B(this)</code> but I am not able to construct <em>and</em> copy using <code>B b = B(this)</code>, which is what I need to do in the last line in order to give class <code>A</code> members of class <code>B</code>. What is the best way to solve this problem?</p>