This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Immediate status.

4450. std::atomic_ref<T>::store_key should be disabled for const T

Section: 32.5.7.3 [atomics.ref.int] Status: Immediate Submitter: Jonathan Wakely Opened: 2025-11-05 Last modified: 2025-11-05

Priority: Not Prioritized

View all issues with Immediate status.

Discussion:

Addresses US 193-311

The new store_key functions modify the object, so it can't be const.

[Kona 2025-11-05; approved by LWG. Status changed: New → Immediate.]

Proposed resolution:

This wording is relative to N5014.

  1. Modify 32.5.7.3 [atomics.ref.int], as indicated:

    constexpr void store_key(value_type operand,
                             memory_order order = memory_order::seq_cst) const noexcept;
    

    -?- Constraints: is_const_v<integral-type> is false.

    -10- Preconditions: order is memory_order::relaxed, memory_order::release, or memory_order::seq_cst.

    -11- Effects: Atomically replaces the value referenced by *ptr with the result of the computation applied to the value referenced by *ptr and the given operand. Memory is affected according to the value of order. These operations are atomic modify-write operations (32.5.4 [atomics.order]).

  2. Modify 32.5.7.4 [atomics.ref.float], as indicated:

    constexpr void store_key(value_type operand,
                             memory_order order = memory_order::seq_cst) const noexcept;
    

    -?- Constraints: is_const_v<floating-point-type> is false.

    -10- Preconditions: order is memory_order::relaxed, memory_order::release, or memory_order::seq_cst.

    -11- Effects: Atomically replaces the value referenced by *ptr with the result of the computation applied to the value referenced by *ptr and the given operand. Memory is affected according to the value of order. These operations are atomic modify-write operations (32.5.4 [atomics.order]).

  3. Modify 32.5.7.5 [atomics.ref.pointer], as indicated:

    constexpr void store_key(see above operand,
                             memory_order order = memory_order::seq_cst) const noexcept;
    

    -?- Constraints: is_const_v<pointer-type> is false.

    -11- Mandates: T is a complete object type.

    -12- Preconditions: order is memory_order::relaxed, memory_order::release, or memory_order::seq_cst.

    -13- Effects: Atomically replaces the value referenced by *ptr with the result of the computation applied to the value referenced by *ptr and the given operand. Memory is affected according to the value of order. These operations are atomic modify-write operations (32.5.4 [atomics.order]).