title: Assignment operator in struct after adding mutex in C++
body: <p>I had a struct type:</p>
  
  <pre><code>struct MyStruct {
      int field1;
      int field2;
  }
  </code></pre>
  
  <p>Then it became necessary to add a mutex to it to make it shared between threads:</p>
  
  <pre><code>struct MyStruct {
      std::mutex _mutex;
  
      int field1;
      int field2;
  }
  </code></pre>
  
  <p>But then the compiler (clang) give me these messages on lines where I assign one existing struct to variable of type MyStruct like <code>MyStruct mystruct = p_MyStructMap-&gt;at(clientId);</code>:</p>
  
  <p>(1) error: object of type 'MyStruct' cannot be assigned because its copy assignment operator is implicitly deleted</p>
  
  <p>(2) note: copy assignment operator of 'MyStruct' is implicitly deleted because field '_mutex' has a deleted copy assignment operator</p>
  
  <pre><code>std::mutex _mutex
             ^     
  </code></pre>
  
  <p>(3) /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/mutex:129:12: note: function has been explicitly marked deleted here</p>
  
  <pre><code>mutex&amp; operator=(const mutex&amp;) = delete;
         ^
  </code></pre>
  
  <p>Please, help: How can I rewrite struct or may be the program logic to use mutexes for this struct?</p>