From Jason Turner

[atomics.types.operations]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpo_7kdcqb/{from.md → to.md} +19 -19
tmp/tmpo_7kdcqb/{from.md → to.md} RENAMED
@@ -1,6 +1,6 @@
1
- ### Operations on atomic types <a id="atomics.types.operations">[[atomics.types.operations]]</a>
2
 
3
  ``` cpp
4
  constexpr atomic() noexcept(is_nothrow_default_constructible_v<T>);
5
  ```
6
 
@@ -49,17 +49,17 @@ type. — *end note*]
49
  ``` cpp
50
  void store(T desired, memory_order order = memory_order::seq_cst) volatile noexcept;
51
  void store(T desired, memory_order order = memory_order::seq_cst) noexcept;
52
  ```
53
 
 
 
 
54
  *Preconditions:* The `order` argument is neither
55
  `memory_order::consume`, `memory_order::acquire`, nor
56
  `memory_order::acq_rel`.
57
 
58
- *Constraints:* For the `volatile` overload of this function,
59
- `is_always_lock_free` is `true`.
60
-
61
  *Effects:* Atomically replaces the value pointed to by `this` with the
62
  value of `desired`. Memory is affected according to the value of
63
  `order`.
64
 
65
  ``` cpp
@@ -77,16 +77,16 @@ T operator=(T desired) noexcept;
77
  ``` cpp
78
  T load(memory_order order = memory_order::seq_cst) const volatile noexcept;
79
  T load(memory_order order = memory_order::seq_cst) const noexcept;
80
  ```
81
 
 
 
 
82
  *Preconditions:* The `order` argument is neither `memory_order::release`
83
  nor `memory_order::acq_rel`.
84
 
85
- *Constraints:* For the `volatile` overload of this function,
86
- `is_always_lock_free` is `true`.
87
-
88
  *Effects:* Memory is affected according to the value of `order`.
89
 
90
  *Returns:* Atomically returns the value pointed to by `this`.
91
 
92
  ``` cpp
@@ -132,16 +132,16 @@ bool compare_exchange_strong(T& expected, T desired,
132
  memory_order order = memory_order::seq_cst) volatile noexcept;
133
  bool compare_exchange_strong(T& expected, T desired,
134
  memory_order order = memory_order::seq_cst) noexcept;
135
  ```
136
 
 
 
 
137
  *Preconditions:* The `failure` argument is neither
138
  `memory_order::release` nor `memory_order::acq_rel`.
139
 
140
- *Constraints:* For the `volatile` overload of this function,
141
- `is_always_lock_free` is `true`.
142
-
143
  *Effects:* Retrieves the value in `expected`. It then atomically
144
  compares the value representation of the value pointed to by `this` for
145
  equality with that previously retrieved from `expected`, and if true,
146
  replaces the value pointed to by `this` with that in `desired`. If and
147
  only if the comparison is `true`, memory is affected according to the
@@ -161,17 +161,17 @@ Otherwise, these operations are atomic load operations on that memory.
161
  *Returns:* The result of the comparison.
162
 
163
  [*Note 4*:
164
 
165
  For example, the effect of `compare_exchange_strong` on objects without
166
- padding bits [[basic.types]] is
167
 
168
  ``` cpp
169
  if (memcmp(this, &expected, sizeof(*this)) == 0)
170
  memcpy(this, &desired, sizeof(*this));
171
  else
172
- memcpy(expected, this, sizeof(*this));
173
  ```
174
 
175
  — *end note*]
176
 
177
  [*Example 1*:
@@ -222,17 +222,17 @@ compare-and-exchange is in a loop, the weak version will yield better
222
  performance on some platforms. When a weak compare-and-exchange would
223
  require a loop and a strong one would not, the strong one is
224
  preferable. — *end note*]
225
 
226
  [*Note 6*: Under cases where the `memcpy` and `memcmp` semantics of the
227
- compare-and-exchange operations apply, the outcome might be failed
228
- comparisons for values that compare equal with `operator==` if the value
229
- representation has trap bits or alternate representations of the same
230
- value. Notably, on implementations conforming to ISO/IEC/IEEE 60559,
231
- floating-point `-0.0` and `+0.0` will not compare equal with `memcmp`
232
- but will compare equal with `operator==`, and NaNs with the same payload
233
- will compare equal with `memcmp` but will not compare equal with
234
  `operator==`. — *end note*]
235
 
236
  [*Note 7*:
237
 
238
  Because compare-and-exchange acts on an object’s value representation,
 
1
+ #### Operations on atomic types <a id="atomics.types.operations">[[atomics.types.operations]]</a>
2
 
3
  ``` cpp
4
  constexpr atomic() noexcept(is_nothrow_default_constructible_v<T>);
5
  ```
6
 
 
49
  ``` cpp
50
  void store(T desired, memory_order order = memory_order::seq_cst) volatile noexcept;
51
  void store(T desired, memory_order order = memory_order::seq_cst) noexcept;
52
  ```
53
 
54
+ *Constraints:* For the `volatile` overload of this function,
55
+ `is_always_lock_free` is `true`.
56
+
57
  *Preconditions:* The `order` argument is neither
58
  `memory_order::consume`, `memory_order::acquire`, nor
59
  `memory_order::acq_rel`.
60
 
 
 
 
61
  *Effects:* Atomically replaces the value pointed to by `this` with the
62
  value of `desired`. Memory is affected according to the value of
63
  `order`.
64
 
65
  ``` cpp
 
77
  ``` cpp
78
  T load(memory_order order = memory_order::seq_cst) const volatile noexcept;
79
  T load(memory_order order = memory_order::seq_cst) const noexcept;
80
  ```
81
 
82
+ *Constraints:* For the `volatile` overload of this function,
83
+ `is_always_lock_free` is `true`.
84
+
85
  *Preconditions:* The `order` argument is neither `memory_order::release`
86
  nor `memory_order::acq_rel`.
87
 
 
 
 
88
  *Effects:* Memory is affected according to the value of `order`.
89
 
90
  *Returns:* Atomically returns the value pointed to by `this`.
91
 
92
  ``` cpp
 
132
  memory_order order = memory_order::seq_cst) volatile noexcept;
133
  bool compare_exchange_strong(T& expected, T desired,
134
  memory_order order = memory_order::seq_cst) noexcept;
135
  ```
136
 
137
+ *Constraints:* For the `volatile` overload of this function,
138
+ `is_always_lock_free` is `true`.
139
+
140
  *Preconditions:* The `failure` argument is neither
141
  `memory_order::release` nor `memory_order::acq_rel`.
142
 
 
 
 
143
  *Effects:* Retrieves the value in `expected`. It then atomically
144
  compares the value representation of the value pointed to by `this` for
145
  equality with that previously retrieved from `expected`, and if true,
146
  replaces the value pointed to by `this` with that in `desired`. If and
147
  only if the comparison is `true`, memory is affected according to the
 
161
  *Returns:* The result of the comparison.
162
 
163
  [*Note 4*:
164
 
165
  For example, the effect of `compare_exchange_strong` on objects without
166
+ padding bits [[term.padding.bits]] is
167
 
168
  ``` cpp
169
  if (memcmp(this, &expected, sizeof(*this)) == 0)
170
  memcpy(this, &desired, sizeof(*this));
171
  else
172
+ memcpy(&expected, this, sizeof(*this));
173
  ```
174
 
175
  — *end note*]
176
 
177
  [*Example 1*:
 
222
  performance on some platforms. When a weak compare-and-exchange would
223
  require a loop and a strong one would not, the strong one is
224
  preferable. — *end note*]
225
 
226
  [*Note 6*: Under cases where the `memcpy` and `memcmp` semantics of the
227
+ compare-and-exchange operations apply, the comparisons can fail for
228
+ values that compare equal with `operator==` if the value representation
229
+ has trap bits or alternate representations of the same value. Notably,
230
+ on implementations conforming to ISO/IEC/IEEE 60559, floating-point
231
+ `-0.0` and `+0.0` will not compare equal with `memcmp` but will compare
232
+ equal with `operator==`, and NaNs with the same payload will compare
233
+ equal with `memcmp` but will not compare equal with
234
  `operator==`. — *end note*]
235
 
236
  [*Note 7*:
237
 
238
  Because compare-and-exchange acts on an object’s value representation,