tmp/tmphco5te3l/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Partial specialization for pointers <a id="atomics.types.pointer">[[atomics.types.pointer]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std {
|
| 5 |
+
template <class T> struct atomic<T*> {
|
| 6 |
+
using value_type = T*;
|
| 7 |
+
using difference_type = ptrdiff_t;
|
| 8 |
+
static constexpr bool is_always_lock_free = implementation-defined // whether a given atomic type's operations are always lock free;
|
| 9 |
+
bool is_lock_free() const volatile noexcept;
|
| 10 |
+
bool is_lock_free() const noexcept;
|
| 11 |
+
void store(T*, memory_order = memory_order_seq_cst) volatile noexcept;
|
| 12 |
+
void store(T*, memory_order = memory_order_seq_cst) noexcept;
|
| 13 |
+
T* load(memory_order = memory_order_seq_cst) const volatile noexcept;
|
| 14 |
+
T* load(memory_order = memory_order_seq_cst) const noexcept;
|
| 15 |
+
operator T*() const volatile noexcept;
|
| 16 |
+
operator T*() const noexcept;
|
| 17 |
+
T* exchange(T*, memory_order = memory_order_seq_cst) volatile noexcept;
|
| 18 |
+
T* exchange(T*, memory_order = memory_order_seq_cst) noexcept;
|
| 19 |
+
bool compare_exchange_weak(T*&, T*, memory_order, memory_order) volatile noexcept;
|
| 20 |
+
bool compare_exchange_weak(T*&, T*, memory_order, memory_order) noexcept;
|
| 21 |
+
bool compare_exchange_strong(T*&, T*, memory_order, memory_order) volatile noexcept;
|
| 22 |
+
bool compare_exchange_strong(T*&, T*, memory_order, memory_order) noexcept;
|
| 23 |
+
bool compare_exchange_weak(T*&, T*, memory_order = memory_order_seq_cst) volatile noexcept;
|
| 24 |
+
bool compare_exchange_weak(T*&, T*, memory_order = memory_order_seq_cst) noexcept;
|
| 25 |
+
bool compare_exchange_strong(T*&, T*, memory_order = memory_order_seq_cst) volatile noexcept;
|
| 26 |
+
bool compare_exchange_strong(T*&, T*, memory_order = memory_order_seq_cst) noexcept;
|
| 27 |
+
T* fetch_add(ptrdiff_t, memory_order = memory_order_seq_cst) volatile noexcept;
|
| 28 |
+
T* fetch_add(ptrdiff_t, memory_order = memory_order_seq_cst) noexcept;
|
| 29 |
+
T* fetch_sub(ptrdiff_t, memory_order = memory_order_seq_cst) volatile noexcept;
|
| 30 |
+
T* fetch_sub(ptrdiff_t, memory_order = memory_order_seq_cst) noexcept;
|
| 31 |
+
|
| 32 |
+
atomic() noexcept = default;
|
| 33 |
+
constexpr atomic(T*) noexcept;
|
| 34 |
+
atomic(const atomic&) = delete;
|
| 35 |
+
atomic& operator=(const atomic&) = delete;
|
| 36 |
+
atomic& operator=(const atomic&) volatile = delete;
|
| 37 |
+
T* operator=(T*) volatile noexcept;
|
| 38 |
+
T* operator=(T*) noexcept;
|
| 39 |
+
|
| 40 |
+
T* operator++(int) volatile noexcept;
|
| 41 |
+
T* operator++(int) noexcept;
|
| 42 |
+
T* operator--(int) volatile noexcept;
|
| 43 |
+
T* operator--(int) noexcept;
|
| 44 |
+
T* operator++() volatile noexcept;
|
| 45 |
+
T* operator++() noexcept;
|
| 46 |
+
T* operator--() volatile noexcept;
|
| 47 |
+
T* operator--() noexcept;
|
| 48 |
+
T* operator+=(ptrdiff_t) volatile noexcept;
|
| 49 |
+
T* operator+=(ptrdiff_t) noexcept;
|
| 50 |
+
T* operator-=(ptrdiff_t) volatile noexcept;
|
| 51 |
+
T* operator-=(ptrdiff_t) noexcept;
|
| 52 |
+
};
|
| 53 |
+
}
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
There is a partial specialization of the `atomic` class template for
|
| 57 |
+
pointers. Specializations of this partial specialization are
|
| 58 |
+
standard-layout structs. They each have a trivial default constructor
|
| 59 |
+
and a trivial destructor.
|
| 60 |
+
|
| 61 |
+
Descriptions are provided below only for members that differ from the
|
| 62 |
+
primary template.
|
| 63 |
+
|
| 64 |
+
The following operations perform pointer arithmetic. The key, operator,
|
| 65 |
+
and computation correspondence is:
|
| 66 |
+
|
| 67 |
+
**Table: Atomic pointer computations** <a id="tab:atomic.pointer.computations">[tab:atomic.pointer.computations]</a>
|
| 68 |
+
|
| 69 |
+
| | | | | | |
|
| 70 |
+
| ----- | --- | -------- | ----- | --- | ----------- |
|
| 71 |
+
| `add` | `+` | addition | `sub` | `-` | subtraction |
|
| 72 |
+
|
| 73 |
+
``` cpp
|
| 74 |
+
T* fetch_key(ptrdiff_t operand, memory_order order = memory_order_seq_cst) volatile noexcept;
|
| 75 |
+
T* fetch_key(ptrdiff_t operand, memory_order order = memory_order_seq_cst) noexcept;
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
*Requires:* T shall be an object type, otherwise the program is
|
| 79 |
+
ill-formed.
|
| 80 |
+
|
| 81 |
+
[*Note 1*: Pointer arithmetic on `void*` or function pointers is
|
| 82 |
+
ill-formed. — *end note*]
|
| 83 |
+
|
| 84 |
+
*Effects:* Atomically replaces the value pointed to by `this` with the
|
| 85 |
+
result of the computation applied to the value pointed to by `this` and
|
| 86 |
+
the given `operand`. Memory is affected according to the value of
|
| 87 |
+
`order`. These operations are atomic read-modify-write
|
| 88 |
+
operations ([[intro.multithread]]).
|
| 89 |
+
|
| 90 |
+
*Returns:* Atomically, the value pointed to by `this` immediately before
|
| 91 |
+
the effects.
|
| 92 |
+
|
| 93 |
+
*Remarks:* The result may be an undefined address, but the operations
|
| 94 |
+
otherwise have no undefined behavior.
|
| 95 |
+
|
| 96 |
+
``` cpp
|
| 97 |
+
T* operator op=(ptrdiff_t operand) volatile noexcept;
|
| 98 |
+
T* operator op=(ptrdiff_t operand) noexcept;
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
*Effects:* Equivalent to:
|
| 102 |
+
`return fetch_`*`key`*`(operand) `*`op`*` operand;`
|
| 103 |
+
|