Aller au contenu
Bienvenue sur la nouvelle documentation de CppUtils !

Constexpr-capable zero-overhead atomic wrapper.

Provides standard atomic semantics in runtime execution while remaining fully functional in compile-time (constexpr / consteval) contexts.

In runtime contexts, delegates directly to std::atomic<T> without extra overhead. In consteval contexts, maintains the state as a plain scalar T.

Paramètre templateDescription
TThe trivially copyable underlying value type.
using CppUtils::Thread::Atomic<T>::ValueType = T;
static constexpr bool is_always_lock_free = std::atomic<T>::is_always_lock_free;
std::atomic<T> m_atomic;
T m_value;
constexpr explicit Atomic::Atomic(T desired = T{}) noexcept;
Atomic::Atomic(const Atomic&) = delete;
auto Atomic::operator=(const Atomic&) -> Atomic& = delete;
[[nodiscard]] constexpr auto Atomic::is_lock_free() const noexcept -> bool;
[[nodiscard]] constexpr auto Atomic::load([[maybe_unused]] std::memory_order order = std::memory_order_seq_cst) const noexcept -> T;
constexpr auto Atomic::store(T desired, [[maybe_unused]] std::memory_order order = std::memory_order_seq_cst) noexcept -> void;
constexpr auto Atomic::operator=(T desired) noexcept -> T;
[[nodiscard]] constexpr Atomic::operator T() const noexcept;
[[nodiscard]] constexpr auto Atomic::exchange(T desired, [[maybe_unused]] std::memory_order order = std::memory_order_seq_cst) noexcept -> T;
[[nodiscard]] constexpr auto Atomic::compare_exchange_strong( T& expected, T desired, [[maybe_unused]] std::memory_order successOrder, [[maybe_unused]] std::memory_order failureOrder) noexcept -> bool;
[[nodiscard]] constexpr auto Atomic::compare_exchange_strong( T& expected, T desired, [[maybe_unused]] std::memory_order order = std::memory_order_seq_cst) noexcept -> bool;
[[nodiscard]] constexpr auto Atomic::compare_exchange_weak( T& expected, T desired, [[maybe_unused]] std::memory_order successOrder, [[maybe_unused]] std::memory_order failureOrder) noexcept -> bool;
[[nodiscard]] constexpr auto Atomic::compare_exchange_weak( T& expected, T desired, [[maybe_unused]] std::memory_order order = std::memory_order_seq_cst) noexcept -> bool;
constexpr auto Atomic::wait([[maybe_unused]] T old, [[maybe_unused]] std::memory_order order = std::memory_order_seq_cst) const noexcept -> void;
constexpr auto Atomic::notify_one() noexcept -> void;
constexpr auto Atomic::notify_all() noexcept -> void;
constexpr auto Atomic::fetch_add(T argument, [[maybe_unused]] std::memory_order order = std::memory_order_seq_cst) noexcept -> T requires std::integral<T> or std::floating_point<T> or std::is_pointer_v<T>;
constexpr auto Atomic::fetch_sub(T argument, [[maybe_unused]] std::memory_order order = std::memory_order_seq_cst) noexcept -> T requires std::integral<T> or std::floating_point<T> or std::is_pointer_v<T>;
constexpr auto Atomic::fetch_and(T argument, [[maybe_unused]] std::memory_order order = std::memory_order_seq_cst) noexcept -> T requires std::integral<T>;
constexpr auto Atomic::fetch_or(T argument, [[maybe_unused]] std::memory_order order = std::memory_order_seq_cst) noexcept -> T requires std::integral<T>;
constexpr auto Atomic::fetch_xor(T argument, [[maybe_unused]] std::memory_order order = std::memory_order_seq_cst) noexcept -> T requires std::integral<T>;
constexpr auto Atomic::operator++() noexcept -> T requires std::integral<T> or std::is_pointer_v<T>;
constexpr auto Atomic::operator++(int) noexcept -> T requires std::integral<T> or std::is_pointer_v<T>;
constexpr auto Atomic::operator--() noexcept -> T requires std::integral<T> or std::is_pointer_v<T>;
constexpr auto Atomic::operator--(int) noexcept -> T requires std::integral<T> or std::is_pointer_v<T>;
constexpr auto Atomic::operator+=(T argument) noexcept -> T requires std::integral<T> or std::floating_point<T> or std::is_pointer_v<T>;
constexpr auto Atomic::operator-=(T argument) noexcept -> T requires std::integral<T> or std::floating_point<T> or std::is_pointer_v<T>;
constexpr auto Atomic::operator&=(T argument) noexcept -> T requires std::integral<T>;
constexpr auto Atomic::operator|=(T argument) noexcept -> T requires std::integral<T>;
constexpr auto Atomic::operator^=(T argument) noexcept -> T requires std::integral<T>;