|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4450" status="New"> |
| 5 | +<title><tt>std::atomic_ref<T>::store_<i>key</i></tt> should be disabled for const `T`</title> |
| 6 | +<section><sref ref="[atomics.ref.int]"/></section> |
| 7 | +<submitter>Jonathan Wakely</submitter> |
| 8 | +<date>05 Nov 2025</date> |
| 9 | +<priority>99</priority> |
| 10 | + |
| 11 | +<discussion> |
| 12 | +<b>Addresses <a href="https://github.com/cplusplus/nbballot/issues/886">US 193-311</a></b> |
| 13 | +<p> |
| 14 | +The new <tt>store_<i>key</i></tt> functions modify the object, |
| 15 | +so it can't be const. |
| 16 | +</p> |
| 17 | +</discussion> |
| 18 | + |
| 19 | +<resolution> |
| 20 | +<p> |
| 21 | +This wording is relative to <paper num="N5014"/>. |
| 22 | +</p> |
| 23 | + |
| 24 | +<ol> |
| 25 | +<li><p>Modify <sref ref="[atomics.ref.int]"/>, as indicated:</p> |
| 26 | + |
| 27 | +<blockquote> |
| 28 | +<pre> |
| 29 | +constexpr void store_<i>key</i>(value_type operand, |
| 30 | + memory_order order = memory_order::seq_cst) const noexcept; |
| 31 | +</pre> |
| 32 | +<blockquote> |
| 33 | +<p><ins>-?- <i>Constraints</i>: |
| 34 | +<tt>is_const_v<<i>integral-type</i>></tt> is `false`.</ins> |
| 35 | +</p> |
| 36 | +<p>-10- <i>Preconditions</i>: |
| 37 | +`order` is `memory_order::relaxed`, `memory_order::release`, |
| 38 | +or `memory_order::seq_cst`. |
| 39 | +</p> |
| 40 | +<p>-11- <i>Effects</i>: |
| 41 | +Atomically replaces the value referenced by `*ptr` with the result of |
| 42 | +the computation applied to the value referenced by `*ptr` |
| 43 | +and the given `operand`. |
| 44 | +Memory is affected according to the value of `order`. |
| 45 | +These operations are atomic modify-write operations |
| 46 | +(<sref ref="[atomics.order]"/>). |
| 47 | +</p> |
| 48 | +</blockquote> |
| 49 | +</blockquote> |
| 50 | +</li> |
| 51 | + |
| 52 | +<li><p>Modify <sref ref="[atomics.ref.float]"/>, as indicated:</p> |
| 53 | + |
| 54 | +<blockquote> |
| 55 | +<pre> |
| 56 | +constexpr void store_<i>key</i>(value_type operand, |
| 57 | + memory_order order = memory_order::seq_cst) const noexcept; |
| 58 | +</pre> |
| 59 | +<blockquote> |
| 60 | +<p><ins>-?- <i>Constraints</i>: |
| 61 | +<tt>is_const_v<<i>integral-type</i>></tt> is `false`.</ins> |
| 62 | +</p> |
| 63 | +<p>-10- <i>Preconditions</i>: |
| 64 | +`order` is `memory_order::relaxed`, `memory_order::release`, |
| 65 | +or `memory_order::seq_cst`. |
| 66 | +</p> |
| 67 | +<p>-11- <i>Effects</i>: |
| 68 | +Atomically replaces the value referenced by `*ptr` with the result of |
| 69 | +the computation applied to the value referenced by `*ptr` |
| 70 | +and the given `operand`. |
| 71 | +Memory is affected according to the value of `order`. |
| 72 | +These operations are atomic modify-write operations |
| 73 | +(<sref ref="[atomics.order]"/>). |
| 74 | +</p> |
| 75 | +</blockquote> |
| 76 | +</blockquote> |
| 77 | +</li> |
| 78 | + |
| 79 | +<li><p>Modify <sref ref="[atomics.ref.pointer]"/>, as indicated:</p> |
| 80 | + |
| 81 | +<blockquote> |
| 82 | +<pre> |
| 83 | +constexpr void store_<i>key</i>(<i>see above</i> operand, |
| 84 | + memory_order order = memory_order::seq_cst) const noexcept; |
| 85 | +</pre> |
| 86 | +<blockquote> |
| 87 | +<p><ins>-?- <i>Constraints</i>: |
| 88 | +<tt>is_const_v<<i>integral-type</i>></tt> is `false`.</ins> |
| 89 | +</p> |
| 90 | +<p>-11- <i>Mandates</i>: |
| 91 | +`T` is a complete object type. |
| 92 | +</p> |
| 93 | +<p>-12- <i>Preconditions</i>: |
| 94 | +`order` is `memory_order::relaxed`, `memory_order::release`, |
| 95 | +or `memory_order::seq_cst`. |
| 96 | +</p> |
| 97 | +<p>-13- <i>Effects</i>: |
| 98 | +Atomically replaces the value referenced by `*ptr` with the result of |
| 99 | +the computation applied to the value referenced by `*ptr` |
| 100 | +and the given `operand`. |
| 101 | +Memory is affected according to the value of `order`. |
| 102 | +These operations are atomic modify-write operations |
| 103 | +(<sref ref="[atomics.order]"/>). |
| 104 | +</p> |
| 105 | +</blockquote> |
| 106 | +</blockquote> |
| 107 | +</li> |
| 108 | +</ol> |
| 109 | + |
| 110 | +</resolution> |
| 111 | + |
| 112 | +</issue> |
0 commit comments