title: what makes c++ atomic atomic
body: <p>I just know that even the code <code>int64_t_variable = 10</code> is not an atomic operation.  for example</p>
  
  <pre><code>int64_t i = 0;
  i = 100;
  </code></pre>
  
  <p>in another thread (say T2) it may read the value which is not <code>0</code> or <code>100</code>.</p>
  
  <ol>
  <li>is the above true?</li>
  <li><code>std::atomic&lt;int64_t&gt; i;  i.store(100, std::memory_order_relaxed)</code> is atomic.  so what magic does atomic use to make it happen based on Q1 is true?</li>
  <li>I always think any operation which handles less than 64 bits is atomic (assume 64 bit cpu), looks I was wrong.  so for  <code>v = n</code>,  how I can know if it is atomic or not?  for example,  if v is <code>void *</code>, is it atomic or not?</li>
  </ol>
  
  <p>==================================</p>
  
  <p>Update:   In my question:  when T2 read the <code>i</code>,  both 0 and 100 are ok for me.  but any other result is not reasonable.  This is the point.  so I don't think cpu cache or compiler stuff can make this happen. </p>