Title
std::atomic_ref<T>::store_key should be disabled for const `T`
Status
wp
Section
[atomics.ref.int]
Submitter
Jonathan Wakely

Created on 2025-11-05.00:00:00 last changed 1 month ago

Messages

Date: 2025-11-11.10:48:55

Proposed resolution:

This wording is relative to N5014.

  1. Modify [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 ([atomics.order]).

  2. Modify [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 ([atomics.order]).

  3. Modify [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 ([atomics.order]).

Date: 2025-11-11.10:48:55

[ Kona 2025-11-08; Status changed: Immediate → WP. ]

Date: 2025-11-05.20:54:03

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

Date: 2025-11-05.00:00:00
Addresses US 193-311

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

History
Date User Action Args
2025-11-11 10:48:55adminsetmessages: + msg15703
2025-11-11 10:48:55adminsetstatus: immediate -> wp
2025-11-05 20:54:03adminsetmessages: + msg15529
2025-11-05 20:54:03adminsetstatus: new -> immediate
2025-11-05 19:28:12adminsetmessages: + msg15523
2025-11-05 00:00:00admincreate