title: How to implement a reader/writer lock in C++14
body: <p>I have a hash table data structure that I wish to make thread safe by use of a reader/writer lock (my read:write ratio is likely somewhere in the region of 100:1).</p>
  
  <p>I have been looking around for how to implement this lock using C++11 (<a href="https://stackoverflow.com/questions/12033188/how-would-a-readers-writer-lock-be-implemented-in-c11">such as the method here</a>), but it has come to my attention that it should be possible to use C++14's <code>shared_lock</code> to accomplish the same thing. However, after looking on <a href="http://en.cppreference.com/w/cpp/thread/shared_lock" rel="nofollow noreferrer">cppreference</a> I have found both <code>std::shared_lock</code> and <code>std::unique_lock</code> but I don't understand how to use them together (compared to the Boost way which <a href="https://stackoverflow.com/a/4820461/1618592">has simple method calls</a> for locking both uniquely and in shared mode).</p>
  
  <p>How can I recreate this relatively simple reader/writer lock interface in C++14 using only the standard library?</p>