tmp/tmph_73h46j/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### General <a id="atomics.ref.generic.general">[[atomics.ref.generic.general]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std {
|
| 5 |
+
template<class T> struct atomic_ref {
|
| 6 |
+
private:
|
| 7 |
+
T* ptr; // exposition only
|
| 8 |
+
|
| 9 |
+
public:
|
| 10 |
+
using value_type = T;
|
| 11 |
+
static constexpr size_t required_alignment = implementation-defined // required alignment for atomic_ref type's operations;
|
| 12 |
+
|
| 13 |
+
static constexpr bool is_always_lock_free = implementation-defined // whether a given atomic_ref type's operations are always lock free;
|
| 14 |
+
bool is_lock_free() const noexcept;
|
| 15 |
+
|
| 16 |
+
explicit atomic_ref(T&);
|
| 17 |
+
atomic_ref(const atomic_ref&) noexcept;
|
| 18 |
+
atomic_ref& operator=(const atomic_ref&) = delete;
|
| 19 |
+
|
| 20 |
+
void store(T, memory_order = memory_order::seq_cst) const noexcept;
|
| 21 |
+
T operator=(T) const noexcept;
|
| 22 |
+
T load(memory_order = memory_order::seq_cst) const noexcept;
|
| 23 |
+
operator T() const noexcept;
|
| 24 |
+
|
| 25 |
+
T exchange(T, memory_order = memory_order::seq_cst) const noexcept;
|
| 26 |
+
bool compare_exchange_weak(T&, T,
|
| 27 |
+
memory_order, memory_order) const noexcept;
|
| 28 |
+
bool compare_exchange_strong(T&, T,
|
| 29 |
+
memory_order, memory_order) const noexcept;
|
| 30 |
+
bool compare_exchange_weak(T&, T,
|
| 31 |
+
memory_order = memory_order::seq_cst) const noexcept;
|
| 32 |
+
bool compare_exchange_strong(T&, T,
|
| 33 |
+
memory_order = memory_order::seq_cst) const noexcept;
|
| 34 |
+
|
| 35 |
+
void wait(T, memory_order = memory_order::seq_cst) const noexcept;
|
| 36 |
+
void notify_one() const noexcept;
|
| 37 |
+
void notify_all() const noexcept;
|
| 38 |
+
};
|
| 39 |
+
}
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
An `atomic_ref` object applies atomic operations [[atomics.general]] to
|
| 43 |
+
the object referenced by `*ptr` such that, for the lifetime
|
| 44 |
+
[[basic.life]] of the `atomic_ref` object, the object referenced by
|
| 45 |
+
`*ptr` is an atomic object [[intro.races]].
|
| 46 |
+
|
| 47 |
+
The program is ill-formed if `is_trivially_copyable_v<T>` is `false`.
|
| 48 |
+
|
| 49 |
+
The lifetime [[basic.life]] of an object referenced by `*ptr` shall
|
| 50 |
+
exceed the lifetime of all `atomic_ref`s that reference the object.
|
| 51 |
+
While any `atomic_ref` instances exist that reference the `*ptr` object,
|
| 52 |
+
all accesses to that object shall exclusively occur through those
|
| 53 |
+
`atomic_ref` instances. No subobject of the object referenced by
|
| 54 |
+
`atomic_ref` shall be concurrently referenced by any other `atomic_ref`
|
| 55 |
+
object.
|
| 56 |
+
|
| 57 |
+
Atomic operations applied to an object through a referencing
|
| 58 |
+
`atomic_ref` are atomic with respect to atomic operations applied
|
| 59 |
+
through any other `atomic_ref` referencing the same object.
|
| 60 |
+
|
| 61 |
+
[*Note 1*: Atomic operations or the `atomic_ref` constructor can
|
| 62 |
+
acquire a shared resource, such as a lock associated with the referenced
|
| 63 |
+
object, to enable atomic operations to be applied to the referenced
|
| 64 |
+
object. — *end note*]
|
| 65 |
+
|