tmp/tmpk99013zb/{from.md → to.md}
RENAMED
|
@@ -1,89 +1,91 @@
|
|
| 1 |
-
### Specializations for integral types <a id="atomics.ref.int">[[atomics.ref.int]]</a>
|
| 2 |
|
| 3 |
There are specializations of the `atomic_ref` class template for the
|
| 4 |
integral types `char`, `signed char`, `unsigned char`, `short`,
|
| 5 |
`unsigned short`, `int`, `unsigned int`, `long`, `unsigned long`,
|
| 6 |
`long long`, `unsigned long long`, `char8_t`, `char16_t`, `char32_t`,
|
| 7 |
`wchar_t`, and any other types needed by the typedefs in the header
|
| 8 |
-
`<cstdint>`. For each such type `integral`, the specialization
|
| 9 |
-
`atomic_ref<integral>` provides additional atomic operations
|
| 10 |
-
to integral types.
|
| 11 |
|
| 12 |
[*Note 1*: The specialization `atomic_ref<bool>` uses the primary
|
| 13 |
template [[atomics.ref.generic]]. — *end note*]
|
| 14 |
|
| 15 |
``` cpp
|
| 16 |
namespace std {
|
| 17 |
-
template<> struct atomic_ref<integral> {
|
| 18 |
private:
|
| 19 |
-
integral* ptr;
|
|
|
|
| 20 |
public:
|
| 21 |
-
using value_type = integral;
|
| 22 |
using difference_type = value_type;
|
| 23 |
static constexpr size_t required_alignment = implementation-defined // required alignment for atomic_ref type's operations;
|
| 24 |
|
| 25 |
static constexpr bool is_always_lock_free = implementation-defined // whether a given atomic_ref type's operations are always lock free;
|
| 26 |
bool is_lock_free() const noexcept;
|
| 27 |
|
| 28 |
-
explicit atomic_ref(integral&);
|
| 29 |
atomic_ref(const atomic_ref&) noexcept;
|
| 30 |
atomic_ref& operator=(const atomic_ref&) = delete;
|
| 31 |
|
| 32 |
-
void store(integral, memory_order = memory_order::seq_cst) const noexcept;
|
| 33 |
-
integral operator=(integral) const noexcept;
|
| 34 |
-
integral load(memory_order = memory_order::seq_cst) const noexcept;
|
| 35 |
-
operator integral() const noexcept;
|
| 36 |
|
| 37 |
-
integral exchange(integral,
|
| 38 |
memory_order = memory_order::seq_cst) const noexcept;
|
| 39 |
-
bool compare_exchange_weak(integral&, integral,
|
| 40 |
memory_order, memory_order) const noexcept;
|
| 41 |
-
bool compare_exchange_strong(integral&, integral,
|
| 42 |
memory_order, memory_order) const noexcept;
|
| 43 |
-
bool compare_exchange_weak(integral&, integral,
|
| 44 |
memory_order = memory_order::seq_cst) const noexcept;
|
| 45 |
-
bool compare_exchange_strong(integral&, integral,
|
| 46 |
memory_order = memory_order::seq_cst) const noexcept;
|
| 47 |
|
| 48 |
-
integral fetch_add(integral,
|
| 49 |
memory_order = memory_order::seq_cst) const noexcept;
|
| 50 |
-
integral fetch_sub(integral,
|
| 51 |
memory_order = memory_order::seq_cst) const noexcept;
|
| 52 |
-
integral fetch_and(integral,
|
| 53 |
memory_order = memory_order::seq_cst) const noexcept;
|
| 54 |
-
integral fetch_or(integral,
|
| 55 |
memory_order = memory_order::seq_cst) const noexcept;
|
| 56 |
-
integral fetch_xor(integral,
|
| 57 |
memory_order = memory_order::seq_cst) const noexcept;
|
| 58 |
|
| 59 |
-
integral operator++(int) const noexcept;
|
| 60 |
-
integral operator--(int) const noexcept;
|
| 61 |
-
integral operator++() const noexcept;
|
| 62 |
-
integral operator--() const noexcept;
|
| 63 |
-
integral operator+=(integral) const noexcept;
|
| 64 |
-
integral operator-=(integral) const noexcept;
|
| 65 |
-
integral operator&=(integral) const noexcept;
|
| 66 |
-
integral operator|=(integral) const noexcept;
|
| 67 |
-
integral operator^=(integral) const noexcept;
|
| 68 |
|
| 69 |
-
void wait(integral, memory_order = memory_order::seq_cst) const noexcept;
|
| 70 |
void notify_one() const noexcept;
|
| 71 |
void notify_all() const noexcept;
|
| 72 |
};
|
| 73 |
}
|
| 74 |
```
|
| 75 |
|
| 76 |
Descriptions are provided below only for members that differ from the
|
| 77 |
primary template.
|
| 78 |
|
| 79 |
-
The following operations perform arithmetic computations. The
|
| 80 |
-
operator, and computation
|
| 81 |
[[atomic.types.int.comp]].
|
| 82 |
|
| 83 |
``` cpp
|
| 84 |
-
integral fetch_key(integral operand,
|
|
|
|
| 85 |
```
|
| 86 |
|
| 87 |
*Effects:* Atomically replaces the value referenced by `*ptr` with the
|
| 88 |
result of the computation applied to the value referenced by `*ptr` and
|
| 89 |
the given operand. Memory is affected according to the value of `order`.
|
|
@@ -100,11 +102,11 @@ converted back to the signed type.
|
|
| 100 |
|
| 101 |
[*Note 1*: There are no undefined results arising from the
|
| 102 |
computation. — *end note*]
|
| 103 |
|
| 104 |
``` cpp
|
| 105 |
-
integral operator op=(integral operand) const noexcept;
|
| 106 |
```
|
| 107 |
|
| 108 |
*Effects:* Equivalent to:
|
| 109 |
`return fetch_`*`key`*`(operand) `*`op`*` operand;`
|
| 110 |
|
|
|
|
| 1 |
+
#### Specializations for integral types <a id="atomics.ref.int">[[atomics.ref.int]]</a>
|
| 2 |
|
| 3 |
There are specializations of the `atomic_ref` class template for the
|
| 4 |
integral types `char`, `signed char`, `unsigned char`, `short`,
|
| 5 |
`unsigned short`, `int`, `unsigned int`, `long`, `unsigned long`,
|
| 6 |
`long long`, `unsigned long long`, `char8_t`, `char16_t`, `char32_t`,
|
| 7 |
`wchar_t`, and any other types needed by the typedefs in the header
|
| 8 |
+
`<cstdint>`. For each such type `integral-type`, the specialization
|
| 9 |
+
`atomic_ref<integral-type>` provides additional atomic operations
|
| 10 |
+
appropriate to integral types.
|
| 11 |
|
| 12 |
[*Note 1*: The specialization `atomic_ref<bool>` uses the primary
|
| 13 |
template [[atomics.ref.generic]]. — *end note*]
|
| 14 |
|
| 15 |
``` cpp
|
| 16 |
namespace std {
|
| 17 |
+
template<> struct atomic_ref<integral-type> {
|
| 18 |
private:
|
| 19 |
+
integral-type* ptr; // exposition only
|
| 20 |
+
|
| 21 |
public:
|
| 22 |
+
using value_type = integral-type;
|
| 23 |
using difference_type = value_type;
|
| 24 |
static constexpr size_t required_alignment = implementation-defined // required alignment for atomic_ref type's operations;
|
| 25 |
|
| 26 |
static constexpr bool is_always_lock_free = implementation-defined // whether a given atomic_ref type's operations are always lock free;
|
| 27 |
bool is_lock_free() const noexcept;
|
| 28 |
|
| 29 |
+
explicit atomic_ref(integral-type&);
|
| 30 |
atomic_ref(const atomic_ref&) noexcept;
|
| 31 |
atomic_ref& operator=(const atomic_ref&) = delete;
|
| 32 |
|
| 33 |
+
void store(integral-type, memory_order = memory_order::seq_cst) const noexcept;
|
| 34 |
+
integral-type operator=(integral-type) const noexcept;
|
| 35 |
+
integral-type load(memory_order = memory_order::seq_cst) const noexcept;
|
| 36 |
+
operator integral-type() const noexcept;
|
| 37 |
|
| 38 |
+
integral-type exchange(integral-type,
|
| 39 |
memory_order = memory_order::seq_cst) const noexcept;
|
| 40 |
+
bool compare_exchange_weak(integral-type&, integral-type,
|
| 41 |
memory_order, memory_order) const noexcept;
|
| 42 |
+
bool compare_exchange_strong(integral-type&, integral-type,
|
| 43 |
memory_order, memory_order) const noexcept;
|
| 44 |
+
bool compare_exchange_weak(integral-type&, integral-type,
|
| 45 |
memory_order = memory_order::seq_cst) const noexcept;
|
| 46 |
+
bool compare_exchange_strong(integral-type&, integral-type,
|
| 47 |
memory_order = memory_order::seq_cst) const noexcept;
|
| 48 |
|
| 49 |
+
integral-type fetch_add(integral-type,
|
| 50 |
memory_order = memory_order::seq_cst) const noexcept;
|
| 51 |
+
integral-type fetch_sub(integral-type,
|
| 52 |
memory_order = memory_order::seq_cst) const noexcept;
|
| 53 |
+
integral-type fetch_and(integral-type,
|
| 54 |
memory_order = memory_order::seq_cst) const noexcept;
|
| 55 |
+
integral-type fetch_or(integral-type,
|
| 56 |
memory_order = memory_order::seq_cst) const noexcept;
|
| 57 |
+
integral-type fetch_xor(integral-type,
|
| 58 |
memory_order = memory_order::seq_cst) const noexcept;
|
| 59 |
|
| 60 |
+
integral-type operator++(int) const noexcept;
|
| 61 |
+
integral-type operator--(int) const noexcept;
|
| 62 |
+
integral-type operator++() const noexcept;
|
| 63 |
+
integral-type operator--() const noexcept;
|
| 64 |
+
integral-type operator+=(integral-type) const noexcept;
|
| 65 |
+
integral-type operator-=(integral-type) const noexcept;
|
| 66 |
+
integral-type operator&=(integral-type) const noexcept;
|
| 67 |
+
integral-type operator|=(integral-type) const noexcept;
|
| 68 |
+
integral-type operator^=(integral-type) const noexcept;
|
| 69 |
|
| 70 |
+
void wait(integral-type, memory_order = memory_order::seq_cst) const noexcept;
|
| 71 |
void notify_one() const noexcept;
|
| 72 |
void notify_all() const noexcept;
|
| 73 |
};
|
| 74 |
}
|
| 75 |
```
|
| 76 |
|
| 77 |
Descriptions are provided below only for members that differ from the
|
| 78 |
primary template.
|
| 79 |
|
| 80 |
+
The following operations perform arithmetic computations. The
|
| 81 |
+
correspondence among key, operator, and computation is specified in
|
| 82 |
[[atomic.types.int.comp]].
|
| 83 |
|
| 84 |
``` cpp
|
| 85 |
+
integral-type fetch_key(integral-type operand,
|
| 86 |
+
memory_order order = memory_order::seq_cst) const noexcept;
|
| 87 |
```
|
| 88 |
|
| 89 |
*Effects:* Atomically replaces the value referenced by `*ptr` with the
|
| 90 |
result of the computation applied to the value referenced by `*ptr` and
|
| 91 |
the given operand. Memory is affected according to the value of `order`.
|
|
|
|
| 102 |
|
| 103 |
[*Note 1*: There are no undefined results arising from the
|
| 104 |
computation. — *end note*]
|
| 105 |
|
| 106 |
``` cpp
|
| 107 |
+
integral-type operator op=(integral-type operand) const noexcept;
|
| 108 |
```
|
| 109 |
|
| 110 |
*Effects:* Equivalent to:
|
| 111 |
`return fetch_`*`key`*`(operand) `*`op`*` operand;`
|
| 112 |
|