29 Atomic operations library [atomics]

29.7 Class template atomic [atomics.types.generic]

29.7.3 Specializations for floating-point types [atomics.types.float]

There are specializations of the atomic class template for the floating-point types float, double, and long double.
For each such type floating-point, the specialization atomic<floating-point> provides additional atomic operations appropriate to floating-point types.
namespace std {
  template<> struct atomic<floating-point> {
    using value_type = floating-point;
    using difference_type = value_type;
    static constexpr bool is_always_lock_free = implementation-defined;
    bool is_lock_free() const volatile noexcept;
    bool is_lock_free() const noexcept;
    void store(floating-point, memory_order = memory_order_seq_cst) volatile noexcept;
    void store(floating-point, memory_order = memory_order_seq_cst) noexcept;
    floating-point load(memory_order = memory_order_seq_cst) volatile noexcept;
    floating-point load(memory_order = memory_order_seq_cst) noexcept;
    operator floating-point() volatile noexcept;
    operator floating-point() noexcept;
    floating-point exchange(floating-point,
                            memory_order = memory_order_seq_cst) volatile noexcept;
    floating-point exchange(floating-point,
                            memory_order = memory_order_seq_cst) noexcept;
    bool compare_exchange_weak(floating-point&, floating-point,
                               memory_order, memory_order) volatile noexcept;
    bool compare_exchange_weak(floating-point&, floating-point,
                               memory_order, memory_order) noexcept;
    bool compare_exchange_strong(floating-point&, floating-point,
                                 memory_order, memory_order) volatile noexcept;
    bool compare_exchange_strong(floating-point&, floating-point,
                                 memory_order, memory_order) noexcept;
    bool compare_exchange_weak(floating-point&, floating-point,
                               memory_order = memory_order_seq_cst) volatile noexcept;
    bool compare_exchange_weak(floating-point&, floating-point,
                               memory_order = memory_order_seq_cst) noexcept;
    bool compare_exchange_strong(floating-point&, floating-point,
                                 memory_order = memory_order_seq_cst) volatile noexcept;
    bool compare_exchange_strong(floating-point&, floating-point,
                                 memory_order = memory_order_seq_cst) noexcept;

    floating-point fetch_add(floating-point,
                             memory_order = memory_order_seq_cst) volatile noexcept;
    floating-point fetch_add(floating-point,
                             memory_order = memory_order_seq_cst) noexcept;
    floating-point fetch_sub(floating-point,
                             memory_order = memory_order_seq_cst) volatile noexcept;
    floating-point fetch_sub(floating-point,
                             memory_order = memory_order_seq_cst) noexcept;

    atomic() noexcept = default;
    constexpr atomic(floating-point) noexcept;
    atomic(const atomic&) = delete;
    atomic& operator=(const atomic&) = delete;
    atomic& operator=(const atomic&) volatile = delete;
    floating-point operator=(floating-point) volatile noexcept;
    floating-point operator=(floating-point) noexcept;

    floating-point operator+=(floating-point) volatile noexcept;
    floating-point operator+=(floating-point) noexcept;
    floating-point operator-=(floating-point) volatile noexcept;
    floating-point operator-=(floating-point) noexcept;
  };
}
The atomic floating-point specializations are standard-layout structs.
They each have a trivial default constructor and a trivial destructor.
Descriptions are provided below only for members that differ from the primary template.
The following operations perform arithmetic addition and subtraction computations.
The key, operator, and computation correspondence are identified in Table 133.
T A::fetch_key(T operand, memory_order order = memory_order_seq_cst) volatile noexcept; T A::fetch_key(T operand, memory_order order = memory_order_seq_cst) noexcept;
Effects: Atomically replaces the value pointed to by this with the result of the computation applied to the value pointed to by this and the given operand.
Memory is affected according to the value of order.
These operations are atomic read-modify-write operations ([intro.multithread]).
Returns: Atomically, the value pointed to by this immediately before the effects.
Remarks: If the result is not a representable value for its type ([expr.pre]) the result is unspecified, but the operations otherwise have no undefined behavior.
Atomic arithmetic operations on floating-point should conform to the std::numeric_­limits<floating-point> traits associated with the floating-point type ([limits.syn]).
The floating-point environment ([cfenv]) for atomic arithmetic operations on floating-point may be different than the calling thread's floating-point environment.
T operator op=(T operand) volatile noexcept; T operator op=(T operand) noexcept;
Effects: Equivalent to: return fetch_­key(operand) op operand;
Remarks: If the result is not a representable value for its type ([expr.pre]) the result is unspecified, but the operations otherwise have no undefined behavior.
Atomic arithmetic operations on floating-point should conform to the std::numeric_­limits<floating-point> traits associated with the floating-point type ([limits.syn]).
The floating-point environment ([cfenv]) for atomic arithmetic operations on floating-point may be different than the calling thread's floating-point environment.