title: Atomic Assignment Operator
body: <p>I'm implementing a very light atomic wrapper as a learning exercise for primitive data types in C++ for Windows, and I have a few simple questions about implementing the assignment operator. Consider the two implementations below:</p>
  
  <pre><code>// Simple assignment
  Atomic&amp; Atomic::operator=(const Atomic&amp; other)
  {
      mValue = other.mValue;
      return *this;
  }
  
  // Interlocked assignment
  Atomic&amp; Atomic::operator=(const Atomic&amp; other)
  {
      _InterlockedExchange(&amp;mValue, other.mValue);
      return *this;
  }
  </code></pre>
  
  <p>Assume that <code>mValue</code> is the correct type and that the <strong>Atomic</strong> class has it as a member.</p>
  
  <ol>
  <li>Is <code>_InterlockedExchange</code> needed for a thread-safe assignment operator, or is the simple implementation enough to guarantee thread-safety?</li>
  <li>If the simple assignment is thread-safe, then is it even needed to implement the assignment operator for this class? The compiler default should suffice, no?</li>
  <li>If the simple assignment is thread-safe in Windows, is it also thread-safe in other platforms? Is the equivalent of <code>_InterlockedExchange</code> required to guarantee thread safety on other platforms?</li>
  </ol>