tmp/tmp63bqjkzd/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Specializations for integers <a id="atomics.types.int">[[atomics.types.int]]</a>
|
| 2 |
+
|
| 3 |
+
There are specializations of the `atomic` template for the integral
|
| 4 |
+
types `char`, `signed char`, `unsigned char`, `short`, `unsigned short`,
|
| 5 |
+
`int`, `unsigned int`, `long`, `unsigned long`, `long long`,
|
| 6 |
+
`unsigned long long`, `char16_t`, `char32_t`, `wchar_t`, and any other
|
| 7 |
+
types needed by the typedefs in the header `<cstdint>`. For each such
|
| 8 |
+
integral type `integral`, the specialization `atomic<integral>` provides
|
| 9 |
+
additional atomic operations appropriate to integral types.
|
| 10 |
+
|
| 11 |
+
[*Note 1*: For the specialization `atomic<bool>`, see
|
| 12 |
+
[[atomics.types.generic]]. — *end note*]
|
| 13 |
+
|
| 14 |
+
``` cpp
|
| 15 |
+
namespace std {
|
| 16 |
+
template <> struct atomic<integral> {
|
| 17 |
+
using value_type = integral;
|
| 18 |
+
using difference_type = value_type;
|
| 19 |
+
static constexpr bool is_always_lock_free = implementation-defined // whether a given atomic type's operations are always lock free;
|
| 20 |
+
bool is_lock_free() const volatile noexcept;
|
| 21 |
+
bool is_lock_free() const noexcept;
|
| 22 |
+
void store(integral, memory_order = memory_order_seq_cst) volatile noexcept;
|
| 23 |
+
void store(integral, memory_order = memory_order_seq_cst) noexcept;
|
| 24 |
+
integral load(memory_order = memory_order_seq_cst) const volatile noexcept;
|
| 25 |
+
integral load(memory_order = memory_order_seq_cst) const noexcept;
|
| 26 |
+
operator integral() const volatile noexcept;
|
| 27 |
+
operator integral() const noexcept;
|
| 28 |
+
integral exchange(integral, memory_order = memory_order_seq_cst) volatile noexcept;
|
| 29 |
+
integral exchange(integral, memory_order = memory_order_seq_cst) noexcept;
|
| 30 |
+
bool compare_exchange_weak(integral&, integral,
|
| 31 |
+
memory_order, memory_order) volatile noexcept;
|
| 32 |
+
bool compare_exchange_weak(integral&, integral,
|
| 33 |
+
memory_order, memory_order) noexcept;
|
| 34 |
+
bool compare_exchange_strong(integral&, integral,
|
| 35 |
+
memory_order, memory_order) volatile noexcept;
|
| 36 |
+
bool compare_exchange_strong(integral&, integral,
|
| 37 |
+
memory_order, memory_order) noexcept;
|
| 38 |
+
bool compare_exchange_weak(integral&, integral,
|
| 39 |
+
memory_order = memory_order_seq_cst) volatile noexcept;
|
| 40 |
+
bool compare_exchange_weak(integral&, integral,
|
| 41 |
+
memory_order = memory_order_seq_cst) noexcept;
|
| 42 |
+
bool compare_exchange_strong(integral&, integral,
|
| 43 |
+
memory_order = memory_order_seq_cst) volatile noexcept;
|
| 44 |
+
bool compare_exchange_strong(integral&, integral,
|
| 45 |
+
memory_order = memory_order_seq_cst) noexcept;
|
| 46 |
+
integral fetch_add(integral, memory_order = memory_order_seq_cst) volatile noexcept;
|
| 47 |
+
integral fetch_add(integral, memory_order = memory_order_seq_cst) noexcept;
|
| 48 |
+
integral fetch_sub(integral, memory_order = memory_order_seq_cst) volatile noexcept;
|
| 49 |
+
integral fetch_sub(integral, memory_order = memory_order_seq_cst) noexcept;
|
| 50 |
+
integral fetch_and(integral, memory_order = memory_order_seq_cst) volatile noexcept;
|
| 51 |
+
integral fetch_and(integral, memory_order = memory_order_seq_cst) noexcept;
|
| 52 |
+
integral fetch_or(integral, memory_order = memory_order_seq_cst) volatile noexcept;
|
| 53 |
+
integral fetch_or(integral, memory_order = memory_order_seq_cst) noexcept;
|
| 54 |
+
integral fetch_xor(integral, memory_order = memory_order_seq_cst) volatile noexcept;
|
| 55 |
+
integral fetch_xor(integral, memory_order = memory_order_seq_cst) noexcept;
|
| 56 |
+
|
| 57 |
+
atomic() noexcept = default;
|
| 58 |
+
constexpr atomic(integral) noexcept;
|
| 59 |
+
atomic(const atomic&) = delete;
|
| 60 |
+
atomic& operator=(const atomic&) = delete;
|
| 61 |
+
atomic& operator=(const atomic&) volatile = delete;
|
| 62 |
+
integral operator=(integral) volatile noexcept;
|
| 63 |
+
integral operator=(integral) noexcept;
|
| 64 |
+
|
| 65 |
+
integral operator++(int) volatile noexcept;
|
| 66 |
+
integral operator++(int) noexcept;
|
| 67 |
+
integral operator--(int) volatile noexcept;
|
| 68 |
+
integral operator--(int) noexcept;
|
| 69 |
+
integral operator++() volatile noexcept;
|
| 70 |
+
integral operator++() noexcept;
|
| 71 |
+
integral operator--() volatile noexcept;
|
| 72 |
+
integral operator--() noexcept;
|
| 73 |
+
integral operator+=(integral) volatile noexcept;
|
| 74 |
+
integral operator+=(integral) noexcept;
|
| 75 |
+
integral operator-=(integral) volatile noexcept;
|
| 76 |
+
integral operator-=(integral) noexcept;
|
| 77 |
+
integral operator&=(integral) volatile noexcept;
|
| 78 |
+
integral operator&=(integral) noexcept;
|
| 79 |
+
integral operator|=(integral) volatile noexcept;
|
| 80 |
+
integral operator|=(integral) noexcept;
|
| 81 |
+
integral operator^=(integral) volatile noexcept;
|
| 82 |
+
integral operator^=(integral) noexcept;
|
| 83 |
+
};
|
| 84 |
+
}
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
The atomic integral specializations are standard-layout structs. They
|
| 88 |
+
each have a trivial default constructor and a trivial destructor.
|
| 89 |
+
|
| 90 |
+
Descriptions are provided below only for members that differ from the
|
| 91 |
+
primary template.
|
| 92 |
+
|
| 93 |
+
The following operations perform arithmetic computations. The key,
|
| 94 |
+
operator, and computation correspondence is:
|
| 95 |
+
|
| 96 |
+
**Table: Atomic arithmetic computations** <a id="tab:atomic.arithmetic.computations">[tab:atomic.arithmetic.computations]</a>
|
| 97 |
+
|
| 98 |
+
| | | | | | |
|
| 99 |
+
| ----- | --- | -------------------- | ----- | --- | -------------------- |
|
| 100 |
+
| `add` | `+` | addition | `sub` | `-` | subtraction |
|
| 101 |
+
| `or` | `|` | bitwise inclusive or | `xor` | `^` | bitwise exclusive or |
|
| 102 |
+
| `and` | `&` | bitwise and | | | |
|
| 103 |
+
|
| 104 |
+
``` cpp
|
| 105 |
+
T fetch_key(T operand, memory_order order = memory_order_seq_cst) volatile noexcept;
|
| 106 |
+
T fetch_key(T operand, memory_order order = memory_order_seq_cst) noexcept;
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
*Effects:* Atomically replaces the value pointed to by `this` with the
|
| 110 |
+
result of the computation applied to the value pointed to by `this` and
|
| 111 |
+
the given `operand`. Memory is affected according to the value of
|
| 112 |
+
`order`. These operations are atomic read-modify-write
|
| 113 |
+
operations ([[intro.multithread]]).
|
| 114 |
+
|
| 115 |
+
*Returns:* Atomically, the value pointed to by `this` immediately before
|
| 116 |
+
the effects.
|
| 117 |
+
|
| 118 |
+
*Remarks:* For signed integer types, arithmetic is defined to use two’s
|
| 119 |
+
complement representation. There are no undefined results.
|
| 120 |
+
|
| 121 |
+
``` cpp
|
| 122 |
+
T operator op=(T operand) volatile noexcept;
|
| 123 |
+
T operator op=(T operand) noexcept;
|
| 124 |
+
```
|
| 125 |
+
|
| 126 |
+
*Effects:* Equivalent to:
|
| 127 |
+
`return fetch_`*`key`*`(operand) `*`op`*` operand;`
|
| 128 |
+
|