From Jason Turner

[atomics.ref.float]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp0zqf2w2r/{from.md → to.md} +94 -0
tmp/tmp0zqf2w2r/{from.md → to.md} RENAMED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Specializations for floating-point types <a id="atomics.ref.float">[[atomics.ref.float]]</a>
2
+
3
+ There are specializations of the `atomic_ref` class template for the
4
+ floating-point types `float`, `double`, and `long double`. For each such
5
+ type `floating-point`, the specialization `atomic_ref<floating-point>`
6
+ provides additional atomic operations appropriate to floating-point
7
+ types.
8
+
9
+ ``` cpp
10
+ namespace std {
11
+ template<> struct atomic_ref<floating-point> {
12
+ private:
13
+ floating-point* ptr; // exposition only
14
+ public:
15
+ using value_type = floating-point;
16
+ using difference_type = value_type;
17
+ static constexpr size_t required_alignment = implementation-defined // required alignment for atomic_ref type's operations;
18
+
19
+ static constexpr bool is_always_lock_free = implementation-defined // whether a given atomic_ref type's operations are always lock free;
20
+ bool is_lock_free() const noexcept;
21
+
22
+ explicit atomic_ref(floating-point&);
23
+ atomic_ref(const atomic_ref&) noexcept;
24
+ atomic_ref& operator=(const atomic_ref&) = delete;
25
+
26
+ void store(floating-point, memory_order = memory_order::seq_cst) const noexcept;
27
+ floating-point operator=(floating-point) const noexcept;
28
+ floating-point load(memory_order = memory_order::seq_cst) const noexcept;
29
+ operator floating-point() const noexcept;
30
+
31
+ floating-point exchange(floating-point,
32
+ memory_order = memory_order::seq_cst) const noexcept;
33
+ bool compare_exchange_weak(floating-point&, floating-point,
34
+ memory_order, memory_order) const noexcept;
35
+ bool compare_exchange_strong(floating-point&, floating-point,
36
+ memory_order, memory_order) const noexcept;
37
+ bool compare_exchange_weak(floating-point&, floating-point,
38
+ memory_order = memory_order::seq_cst) const noexcept;
39
+ bool compare_exchange_strong(floating-point&, floating-point,
40
+ memory_order = memory_order::seq_cst) const noexcept;
41
+
42
+ floating-point fetch_add(floating-point,
43
+ memory_order = memory_order::seq_cst) const noexcept;
44
+ floating-point fetch_sub(floating-point,
45
+ memory_order = memory_order::seq_cst) const noexcept;
46
+
47
+ floating-point operator+=(floating-point) const noexcept;
48
+ floating-point operator-=(floating-point) const noexcept;
49
+
50
+ void wait(floating-point, memory_order = memory_order::seq_cst) const noexcept;
51
+ void notify_one() const noexcept;
52
+ void notify_all() const noexcept;
53
+ };
54
+ }
55
+ ```
56
+
57
+ Descriptions are provided below only for members that differ from the
58
+ primary template.
59
+
60
+ The following operations perform arithmetic computations. The key,
61
+ operator, and computation correspondence are identified in
62
+ [[atomic.types.int.comp]].
63
+
64
+ ``` cpp
65
+ floating-point fetch_key(floating-point operand,
66
+ memory_order order = memory_order::seq_cst) const noexcept;
67
+ ```
68
+
69
+ *Effects:* Atomically replaces the value referenced by `*ptr` with the
70
+ result of the computation applied to the value referenced by `*ptr` and
71
+ the given operand. Memory is affected according to the value of `order`.
72
+ These operations are atomic read-modify-write
73
+ operations [[intro.races]].
74
+
75
+ *Returns:* Atomically, the value referenced by `*ptr` immediately before
76
+ the effects.
77
+
78
+ *Remarks:* If the result is not a representable value for its
79
+ type [[expr.pre]], the result is unspecified, but the operations
80
+ otherwise have no undefined behavior. Atomic arithmetic operations on
81
+ *`floating-point`* should conform to the
82
+ `std::numeric_limits<`*`floating-point`*`>` traits associated with the
83
+ floating-point type [[limits.syn]]. The floating-point
84
+ environment [[cfenv]] for atomic arithmetic operations on
85
+ *`floating-point`* may be different than the calling thread’s
86
+ floating-point environment.
87
+
88
+ ``` cpp
89
+ floating-point operator op=(floating-point operand) const noexcept;
90
+ ```
91
+
92
+ *Effects:* Equivalent to:
93
+ `return fetch_`*`key`*`(operand) `*`op`*` operand;`
94
+