- <para>All library objects are safe to use in a multithreaded program as
- long as each thread carefully locks out access by any other
- thread while it uses any object visible to another thread, i.e.,
- treat library objects like any other shared resource. In general,
- this requirement includes both read and write access to objects;
- unless otherwise documented as safe, do not assume that two threads
- may access a shared standard library object at the same time.
+
+ <para>All library types are safe to use in a multithreaded program
+ if objects are not shared between threads or as
+ long each thread carefully locks out access by any other
+ thread while it modifies any object visible to another thread.
+ Unless otherwise documented, the only exceptions to these rules
+ are atomic operations on the types in
+ <filename class="headerfile"><atomic></filename>
+ and lock/unlock operations on the standard mutex types in
+ <filename class="headerfile"><mutex></filename>. These
+ atomic operations allow concurrent accesses to the same object
+ without introducing data races.
+ </para>
+
+ <para>The following member functions of standard containers can be
+ considered to be const for the purposes of avoiding data races:
+ <code>begin</code>, <code>end</code>, <code>rbegin</code>, <code>rend</code>,
+ <code>front</code>, <code>back</code>, <code>data</code>,
+ <code>find</code>, <code>lower_bound</code>, <code>upper_bound</code>,
+ <code>equal_range</code>, <code>at</code>
+ and, except in associative or unordered associative containers,
+ <code>operator[]</code>. In other words, although they are non-const
+ so that they can return mutable iterators, those member functions
+ will not modify the container.
+ Accessing an iterator might cause a non-modifying access to
+ the container the iterator refers to (for example incrementing a
+ list iterator must access the pointers between nodes, which are part
+ of the container and so conflict with other accesses to the container).