From Jason Turner

[atomics.ref.int]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp3sto5601/{from.md → to.md} +110 -0
tmp/tmp3sto5601/{from.md → to.md} RENAMED
@@ -0,0 +1,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`, the specialization
9
+ `atomic_ref<integral>` provides additional atomic operations appropriate
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; // exposition only
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 key,
80
+ operator, and computation correspondence is identified in
81
+ [[atomic.types.int.comp]].
82
+
83
+ ``` cpp
84
+ integral fetch_key(integral operand, memory_order order = memory_order::seq_cst) const noexcept;
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`.
90
+ These operations are atomic read-modify-write
91
+ operations [[intro.races]].
92
+
93
+ *Returns:* Atomically, the value referenced by `*ptr` immediately before
94
+ the effects.
95
+
96
+ *Remarks:* For signed integer types, the result is as if the object
97
+ value and parameters were converted to their corresponding unsigned
98
+ types, the computation performed on those types, and the result
99
+ 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
+