title: Can we make S[x++] = str atomic using std::atomic?
body: <p>I have the following singleton class:</p>
  <pre><code>class RecordKeeper {
  public:
    ...
    RecordKeeper* get();
    void addRecord(std::string &amp;rec);
  private:
    std::string records[MAX]; // this has to be a fixed size circular array
    int len;
  };
  
  void RecordKeeper::addRecord(std::string rec) {
    ...
    records[len++] = rec;
    ...
  }
  
  
  </code></pre>
  <p>I want to do the following from multiple threads:</p>
  <pre><code>RecordKeeper::get()-&gt;addRecord(str);
  </code></pre>
  <p>Can I do it as an atomic operation using <code>std::atomic</code>?
  Currently I am using std::mutex and lock_guard like <code>std::lock_guard&lt;std::mutex&gt; lg(lock)</code>. But is there a better way that will be more efficient and faster?</p>