atomic_shared_ptr.h provides a lock-free, thread-safe shared pointer implementation for high-throughput user-mode applications across Windows, Linux, and macOS (x64 and ARM64). Based on Anthony Williams' Split Reference Counting algorithm, it pairs a 128-bit atomic publication anchor (AtomicSharedPtr<T>) with a zero-indirection thread-local handle (LocalSharedPtr<T>) and a wait-free 64-bit packed control block (ControlBlock<T>), achieving full std::atomic<std::shared_ptr<T>> semantic parity without mutexes or lock tables.
- Component & Concurrency Summary
- Single-Allocation Cache-Aligned Factory
- Shared Lock-Free Anchor (
AtomicSharedPtr<T>) - Thread-Local Reference-Counted Handle (
LocalSharedPtr<T>) - Pluggable Fatal Error Handling
Both AtomicSharedPtr<T> and ControlBlock<T> are automatically aligned to CACHE_LINE_SIZE (64 bytes on x64; 128 bytes on ARM64 and Apple Silicon) to eliminate false sharing across adjacent anchors, control blocks, and embedded payloads.
| Component / Function | Role | Exception Specification | Progress Guarantee |
|---|---|---|---|
MakeLocalShared |
Single-allocation cache-isolated object factory | Propagates std::bad_alloc and T ctor exceptions |
Heap-allocated (single aligned allocation) |
AtomicSharedPtr<T>::is_lock_free |
Queries hardware 128-bit lock-free support | noexcept |
Wait-free |
AtomicSharedPtr<T>::load |
Atomically checks out a LocalSharedPtr<T> handle |
noexcept |
Lock-free (128-bit CAS + wait-free 64-bit fetch_add) |
AtomicSharedPtr<T>::store (LocalSharedPtr) |
Atomically replaces anchor and reconciles old counts | noexcept |
Lock-free (128-bit CAS + wait-free 64-bit fetch_add) |
AtomicSharedPtr<T>::store (T*) |
Wraps raw pointer and replaces anchor | Propagates std::bad_alloc |
Lock-free after control block allocation |
AtomicSharedPtr<T>::exchange (LocalSharedPtr) |
Atomically swaps anchor and returns displaced handle | noexcept |
Lock-free (128-bit CAS + wait-free 64-bit fetch_add) |
AtomicSharedPtr<T>::exchange (T*) |
Wraps raw pointer, swaps anchor, returns old handle | Propagates std::bad_alloc |
Lock-free after control block allocation |
AtomicSharedPtr<T>::compare_exchange_weak |
Single-attempt conditional anchor replacement | noexcept |
Wait-free on pointer mismatch; lock-free on reload |
AtomicSharedPtr<T>::compare_exchange_strong |
Spurious-immune conditional anchor replacement | noexcept |
Lock-free (hoisted refcount increment; retries spurious reader collisions) |
LocalSharedPtr<T> (Copy / Move / Destroy) |
Thread-local handle with cached T* payload pointer |
noexcept (except T* ctor/reset) |
Wait-free (0 atomic ops on move/deref; single 64-bit fetch_add on copy/destroy) |
SetAtomicPtrErrorHandler |
Registers custom invariant-violation panic callback | noexcept |
Wait-free |
template <typename T, typename... Args>
[[nodiscard]] LocalSharedPtr<T> MakeLocalShared(Args&&... args);- Purpose: Allocates and constructs a
ControlBlock<T>and an embedded payload object of typeTwithin a single cache-aligned memory block, returning aLocalSharedPtr<T>with initial split reference counts{internal = 1, external = 0}. - Restrictions & Guarantees:
- Aligns the allocation to
std::max(CACHE_LINE_SIZE, alignof(T))(_aligned_mallocon Windows,posix_memalignon POSIX). - Places
ControlBlock<T>at offset0and embedsTat a cache-aligned offset ((sizeof(ControlBlock<T>) + alloc_align - 1) & ~(alloc_align - 1)), preventing atomic reference-count updates onControlBlock<T>::countsfrom invalidating the CPU cache line holding the payloadT. - Pre-populates
LocalSharedPtr<T>::ptrwith the resolved payload address so subsequentget(),operator->(), andoperator*()calls execute with zero control-block pointer indirection. - Exception Safety: Throws
std::bad_allocif memory allocation fails. IfT's constructor throws an exception, the aligned memory block is automatically freed viaControlBlock<T>::operator deletebefore the exception propagates.
- Aligns the allocation to
- Parameters:
args: Constructor arguments perfectly forwarded toT's constructor.
- Return Value:
- A
LocalSharedPtr<T>managing the newly constructed object.
- A
AtomicSharedPtr<T> is a cache-line-isolated (alignas(CACHE_LINE_SIZE)) shared publication anchor wrapping a 16-byte CountedPtr<T> state ({ControlBlock<T>* cb, int32_t external_count, uint32_t generation}). Multiple threads may concurrently invoke load(), store(), exchange(), compare_exchange_weak(), and compare_exchange_strong() on the same AtomicSharedPtr<T> instance without external synchronization.
constexpr AtomicSharedPtr() noexcept = default;- Purpose: Initializes an empty anchor (
{cb = nullptr, external_count = 0, generation = 0}). - Restrictions:
AtomicSharedPtr<T>is neither copyable nor movable (AtomicSharedPtr(const AtomicSharedPtr&) = deleteandoperator=(const AtomicSharedPtr&) = delete).
- Parameters:
- None.
- Return Value:
- None.
explicit AtomicSharedPtr(LocalSharedPtr<T> desired) noexcept;- Purpose: Initializes the anchor by adopting baseline ownership directly from
desired(external_count = 0, generation = 0) without performing any atomic reference-count operations. - Restrictions:
- Pass
desiredviastd::move()to avoid an unnecessary copy increment/decrement pair.
- Pass
- Parameters:
desired: TheLocalSharedPtr<T>whose control block ownership is transferred into the anchor.
- Return Value:
- None.
explicit AtomicSharedPtr(T* ptr);- Purpose: Allocates a standalone
ControlBlock<T>wrappingptr(if non-null) and initializes the anchor to manage it. - Restrictions & Guarantees:
ptrmust be a valid heap-allocated pointer suitable fordelete ptr(ornullptr).- Exception Safety: If
new ControlBlock<T>(ptr)throwsstd::bad_alloc,delete ptris automatically invoked before rethrowing to prevent memory leaks.
- Parameters:
ptr: Raw pointer to take ownership of, ornullptr.
- Return Value:
- None.
~AtomicSharedPtr();- Purpose: Releases the currently anchored control block (if non-null) by atomically applying
{int_add = -1, ext_add = old_val.external_count}viaapply_counts()withstd::memory_order_acq_rel, destroying the control block and payload if bothinternalandexternalcounts reach zero. - Restrictions:
- No other threads may concurrently access the
AtomicSharedPtr<T>instance while its destructor is executing. ExistingLocalSharedPtr<T>handles previously checked out from the anchor remain valid and independently keep the payload alive.
- No other threads may concurrently access the
- Parameters:
- None.
- Return Value:
- None.
void operator=(LocalSharedPtr<T> desired) noexcept;- Purpose: Atomically replaces the anchored object with
desiredby forwardingstd::move(desired)tostore(). - Parameters:
desired: NewLocalSharedPtr<T>handle to publish into the anchor.
- Return Value:
- None.
operator LocalSharedPtr<T>() const noexcept;- Purpose: Implicitly checks out a
LocalSharedPtr<T>snapshot of the currently anchored object by callingload(std::memory_order_acquire). - Parameters:
- None.
- Return Value:
- A
LocalSharedPtr<T>owning an independent internal reference to the active object, or an empty handle if the anchor is null.
- A
[[nodiscard]] bool is_lock_free() const noexcept;- Purpose: Reports whether 128-bit atomic operations on this anchor execute lock-free in hardware (
CMPXCHG16Bon x64,CASP/LDXP+STXPon ARM64). - Parameters:
- None.
- Return Value:
trueif 128-bit atomics are lock-free on the target platform/compiler;falseotherwise.
[[nodiscard]] LocalSharedPtr<T> load(std::memory_order order = std::memory_order_acquire) const noexcept;-
Purpose: Atomically checks out a thread-local
LocalSharedPtr<T>handle referencing the currently anchored object. -
Restrictions & Guarantees:
-
Two-Phase Split Reference Checkout:
- Increments
external_countinside the 128-bitCountedPtr<T>anchor via 128-bit CAS (usingAdaptiveBackoffon contention), preventing any concurrent writer from destroying theControlBlock<T>while the checkout is in progress. - Converts the transient external checkout into a pinned internal reference on the control block via
apply_counts(cb->counts, +1, -1, std::memory_order_relaxed).
- Increments
-
Overflow Flush Protection (
EXT_COUNT_FLUSH_THRESHOLD): Ifexternal_countin the anchor reaches$2^{29}$ (1 << 29) under sustained read-only load without intervening writes, the reader attempts a 128-bit CAS to reset the anchor'sexternal_countto0(incrementinggeneration) and flushes+expected_flush.external_countintocb->counts.externalwhile holding its pinned internal reference. Ifexternal_countever reachesINT32_MAX, triggersfatal_panic(). -
Memory Order Rules:
std::memory_order_relaxedis automatically promoted tostd::memory_order_acquireso control-block dereferences are always safely synchronized with publishing writers. Passingstd::memory_order_releaseorstd::memory_order_acq_relis invalid and triggersfatal_panic("Invalid load memory order").
-
Two-Phase Split Reference Checkout:
-
Parameters:
-
order: Memory ordering constraint (acquire,consume,seq_cst, orrelaxedwhich promotes toacquire). Defaults tostd::memory_order_acquire.
-
-
Return Value:
- A
LocalSharedPtr<T>managing the checked-out object, or an emptyLocalSharedPtr<T>(nullptr) if the anchor is empty.
- A
void store(LocalSharedPtr<T> desired,
std::memory_order order = std::memory_order_release) noexcept;
void store(T* ptr,
std::memory_order order = std::memory_order_release);- Purpose: Atomically replaces the currently anchored object with
desired(or a newly constructedLocalSharedPtr<T>(ptr)), increments the anchor's 32-bitgenerationcounter to prevent ABA collisions, and reconciles the displaced anchor's reference counts. - Restrictions & Guarantees:
- Adopts baseline internal ownership directly from
desired(new_val.external_count = 0, new_val.generation = old_val.generation + 1). - On the displaced control block
old_val.cb(if non-null), atomically applies{int_add = -1, ext_add = old_val.external_count}withstd::memory_order_acq_rel, deletingold_val.cbif bothinternalandexternalcounts reach zero. - Memory Order Normalization: Since
store()both publishesdesiredand acquires responsibility for reconciling/destroying the displacedold_val.cb, the 128-bit CAS order is normalized viaeffective_rmw_order(order)to at leaststd::memory_order_acq_rel(orstd::memory_order_seq_cstif requested). - Exception Safety: The
LocalSharedPtr<T>overload isnoexcept. The raw pointerT*overload allocates aControlBlock<T>; ifstd::bad_allocis thrown,delete ptris called automatically and the anchor remains unmodified.
- Adopts baseline internal ownership directly from
- Parameters:
desired/ptr: The newLocalSharedPtr<T>handle or raw pointerT*to install into the anchor.order: Memory ordering constraint (defaults tostd::memory_order_release, normalized internally toacq_relorseq_cst).
- Return Value:
- None.
[[nodiscard]] LocalSharedPtr<T> exchange(LocalSharedPtr<T> desired,
std::memory_order order = std::memory_order_acq_rel) noexcept;
[[nodiscard]] LocalSharedPtr<T> exchange(T* ptr,
std::memory_order order = std::memory_order_acq_rel);- Purpose: Atomically replaces the currently anchored object with
desired(orLocalSharedPtr<T>(ptr)) and returns the displaced object as aLocalSharedPtr<T>. - Restrictions & Guarantees:
- Transfers the displaced anchor's baseline internal reference (
1) directly into the returnedLocalSharedPtr<T>without decrementinginternal. - If
old_val.external_count > 0, flushes{int_add = 0, ext_add = old_val.external_count}intoold_val.cb->countswithstd::memory_order_acq_relbefore returning the handle. - Normalizes
orderviaeffective_rmw_order(order)to at leaststd::memory_order_acq_rel(orstd::memory_order_seq_cst). - Exception Safety: The
LocalSharedPtr<T>overload isnoexcept. TheT*overload deletesptrand leaves the anchor unchanged ifControlBlock<T>allocation throwsstd::bad_alloc.
- Transfers the displaced anchor's baseline internal reference (
- Parameters:
desired/ptr: The newLocalSharedPtr<T>handle or raw pointerT*to install into the anchor.order: Memory ordering constraint (defaults tostd::memory_order_acq_rel).
- Return Value:
- A
LocalSharedPtr<T>owning the previously anchored object, or an emptyLocalSharedPtr<T>(nullptr) if the anchor was empty.
- A
// (1) Lvalue desired, dual memory order
[[nodiscard]] bool compare_exchange_weak(LocalSharedPtr<T>& expected,
const LocalSharedPtr<T>& desired,
std::memory_order succ,
std::memory_order fail) noexcept;
// (2) Rvalue desired, dual memory order
[[nodiscard]] bool compare_exchange_weak(LocalSharedPtr<T>& expected,
LocalSharedPtr<T>&& desired,
std::memory_order succ,
std::memory_order fail) noexcept;
// (3) Lvalue desired, single memory order
[[nodiscard]] bool compare_exchange_weak(LocalSharedPtr<T>& expected,
const LocalSharedPtr<T>& desired,
std::memory_order order = std::memory_order_acq_rel) noexcept;
// (4) Rvalue desired, single memory order
[[nodiscard]] bool compare_exchange_weak(LocalSharedPtr<T>& expected,
LocalSharedPtr<T>&& desired,
std::memory_order order = std::memory_order_acq_rel) noexcept;- Purpose: Conditionally replaces the anchored object with
desiredif the anchor's currentControlBlock<T>*matchesexpected.cb. Allowed to fail spuriously if a concurrent reader incrementsexternal_countor flushes counts on the anchor during the CAS window. - Restrictions & Guarantees:
- On Success (
returns true):- The anchor points to
desired's control block with{external_count = 0, generation = current.generation + 1}. expectedis not modified.- For Lvalue
desired(1, 3):desiredretains its ownership and the anchor acquires an additional internal reference (+1 internal). - For Rvalue
desired(2, 4): Ownership is moved directly fromdesiredinto the anchor without any atomic increment ondesired.cb->counts, leavingdesiredempty (nullptr). - The displaced control block
current.cb(if non-null) has{int_add = -1, ext_add = current.external_count}applied withstd::memory_order_acq_reland is deleted if both counts reach zero.
- The anchor points to
- On Failure (
returns false):- If the failure was due to a true pointer mismatch (
current.cb != expected.cb),expectedis updated to hold a checked-outLocalSharedPtr<T>of the current anchor (or reset to empty ifcurrent.cb == nullptr). - If the failure was spurious (
current.cb == expected.cb, caused by a concurrent reader changingexternal_countorgeneration),expectedremains valid and unchanged. - For Rvalue
desired(2, 4):desiredis not moved from or modified on failure, preserving its original ownership and reference count.
- If the failure was due to a true pointer mismatch (
- Memory Order Normalization:
succis normalized to at leaststd::memory_order_acq_rel. Invalid failure ordersacq_relandreleaseare mapped toacquireandrelaxedrespectively, andrelaxedfailure loads are promoted toacquirewhen checking outexpected.
- On Success (
- Parameters:
expected: In/out reference to theLocalSharedPtr<T>expected to match the anchor's current control block. Updated to the actual anchored object on pointer mismatch.desired: Lvalue or rvalueLocalSharedPtr<T>to install on match.succ/fail/order: Memory ordering constraints for success and failure paths (defaults tostd::memory_order_acq_rel).
- Return Value:
trueif the anchor was successfully swapped;falseon pointer mismatch or spurious 128-bit CAS collision.
// (1) Lvalue desired, dual memory order
[[nodiscard]] bool compare_exchange_strong(LocalSharedPtr<T>& expected,
const LocalSharedPtr<T>& desired,
std::memory_order succ,
std::memory_order fail) noexcept;
// (2) Rvalue desired, dual memory order
[[nodiscard]] bool compare_exchange_strong(LocalSharedPtr<T>& expected,
LocalSharedPtr<T>&& desired,
std::memory_order succ,
std::memory_order fail) noexcept;
// (3) Lvalue desired, single memory order
[[nodiscard]] bool compare_exchange_strong(LocalSharedPtr<T>& expected,
const LocalSharedPtr<T>& desired,
std::memory_order order = std::memory_order_acq_rel) noexcept;
// (4) Rvalue desired, single memory order
[[nodiscard]] bool compare_exchange_strong(LocalSharedPtr<T>& expected,
LocalSharedPtr<T>&& desired,
std::memory_order order = std::memory_order_acq_rel) noexcept;- Purpose: Atomically compares the anchor's
ControlBlock<T>*againstexpected.cband replaces the anchor withdesiredon match, retrying internally on spuriousexternal_countorgenerationupdates so it only returnsfalsewhen the anchoredControlBlock<T>*genuinely differs fromexpected.cb. - Restrictions & Guarantees:
- Spurious-Failure Immunity: Concurrent readers calling
load()(which mutatesexternal_countandgenerationin the 128-bit anchor whilecurrent.cb == expected.cb) never causecompare_exchange_strong()to returnfalse. When a 128-bit CAS fails withcurrent.cb == expected.cb, the loop retries immediately without backoff while the cache line is already held in Modified (M) state by the failedCMPXCHG16B. - Hoisted Reference Increment (Lvalue Overloads 1, 3): If
current.cb == expected.cbon initial inspection,desired.cb->countsis incremented at most once outside the retry loop (and rolled back viaapply_counts(desired_cb->counts, -1, 0, acq_rel)only if a concurrent writer replacescurrent.cbbefore the CAS commits). - Move-Only-On-Success Guarantee (Rvalue Overloads 2, 4): Ownership of
desiredis transferred into the anchor strictly upon 128-bit CAS success. Ifcompare_exchange_strong()returnsfalse,desiredremains intact and unmodified with zero atomic operations performed ondesired.cb->counts. - On Failure (
returns false):expectedis updated to a checked-outLocalSharedPtr<T>of the actual anchored object (or reset to empty if the anchor isnullptr).
- Spurious-Failure Immunity: Concurrent readers calling
- Parameters:
expected: In/out reference to theLocalSharedPtr<T>expected to match the anchor's current control block. Updated to the actual anchored object on failure.desired: Lvalue or rvalueLocalSharedPtr<T>to install on match.succ/fail/order: Memory ordering constraints for success and failure paths (defaults tostd::memory_order_acq_rel).
- Return Value:
trueif the anchor was replaced;falseif and only if the anchor's control block pointer did not matchexpected.cb.
LocalSharedPtr<T> is a lightweight handle holding both the ControlBlock<T>* pointer and a cached T* payload pointer. Like std::shared_ptr<T>, distinct LocalSharedPtr<T> instances referencing the same control block may be copied, moved, read, and destroyed concurrently across threads, while concurrent mutation of a single LocalSharedPtr<T> variable requires synchronization or AtomicSharedPtr<T>.
constexpr LocalSharedPtr() noexcept;
constexpr LocalSharedPtr(std::nullptr_t) noexcept;- Purpose: Initializes an empty handle (
cb == nullptr, ptr == nullptr). - Parameters: None (or
nullptr). - Return Value: None.
explicit LocalSharedPtr(T* p);- Purpose: Takes ownership of a heap-allocated raw pointer
p(if non-null) by allocating a standaloneControlBlock<T>(p)with initial split reference counts{internal = 1, external = 0}. - Restrictions & Guarantees:
pmust be a valid pointer allocated with single-objectnew(ornullptr). PreferMakeLocalShared<T>()whenever possible to co-locate the control block and payload in a single cache-isolated allocation.- Exception Safety: If
new ControlBlock<T>(p)throwsstd::bad_alloc,delete pis automatically invoked andptris cleared before the exception propagates.
- Parameters:
p: Raw pointer to take ownership of, ornullptr.
- Return Value: None.
LocalSharedPtr(const LocalSharedPtr& other) noexcept;- Purpose: Shares ownership of the object managed by
other, copying bothcband the cachedptrand atomically incrementinginternalby+1viaapply_counts(cb->counts, 1, 0, std::memory_order_relaxed). - Restrictions:
- Calls
fatal_panic("Internal count overflow")ifinternalexceedsINT32_MAX.
- Calls
- Parameters:
other: Source handle to copy.
- Return Value: None.
LocalSharedPtr(LocalSharedPtr&& other) noexcept;- Purpose: Transfers ownership of
other's control block and cachedT*pointer to*thiswith zero atomic operations, leavingotherempty (nullptr). - Parameters:
other: Rvalue reference to the source handle.
- Return Value: None.
~LocalSharedPtr();- Purpose: Atomically decrements the control block's
internalcount by-1viaapply_counts(cb->counts, -1, 0, std::memory_order_acq_rel). If bothinternalandexternalcounts reach0, destroys the payload object and frees the control block. - Parameters: None.
- Return Value: None.
LocalSharedPtr& operator=(const LocalSharedPtr& other) noexcept;
LocalSharedPtr& operator=(LocalSharedPtr&& other) noexcept;
LocalSharedPtr& operator=(std::nullptr_t) noexcept;- Purpose:
- Copy Assignment: Shares ownership with
othervia copy-and-swap and releases any previously held reference. Safe against self-assignment (this == &other). - Move Assignment: Transfers ownership from
othervia move-and-swap without atomic increments, releasing any previously held reference and leavingotherempty. Safe against self-assignment. nullptrAssignment: Releases any currently managed object viareset()and sets*thisto empty.
- Copy Assignment: Shares ownership with
- Parameters:
other: Source handle to copy or move from (ornullptr).
- Return Value:
- Reference to
*this.
- Reference to
void swap(LocalSharedPtr& other) noexcept;- Purpose: Exchanges both the
ControlBlock<T>*and cachedT*pointers between*thisandotherwith zero atomic operations. - Parameters:
other: Handle to swap state with.
- Return Value:
- None.
void reset() noexcept;
void reset(T* p);- Purpose:
reset(): Releases ownership of the managed object (destroying it if this was the last internal and external reference) and resets*thisto empty (nullptr).reset(T* p): Replaces the managed object with a newly allocatedControlBlock<T>wrappingp(or resets to empty ifp == nullptr). IfControlBlock<T>allocation throwsstd::bad_alloc,delete pis called and*thisremains unchanged.
- Parameters:
p(optional): Raw pointer to take ownership of.
- Return Value:
- None.
[[nodiscard]] long use_count() const noexcept;- Purpose: Returns an approximate snapshot of the active reference count (
internal + max(0, external)) for diagnostics, testing, and debugging. - Restrictions:
- Loaded with
std::memory_order_relaxed. Since transient reader checkouts incrementexternal_countinsideAtomicSharedPtr<T>and convert them via{+1 internal, -1 external}inControlBlock<T>::counts(which can momentarily makec.externalnegative before the anchor flushes or is replaced), negativec.externalvalues are clamped to0Lwhen computing the approximate count.
- Loaded with
- Parameters:
- None.
- Return Value:
- Approximate reference count as
long, or0if*thisis empty.
- Approximate reference count as
[[nodiscard]] FORCE_INLINE T* get() const noexcept;- Purpose: Returns the cached raw pointer
ptrto the managed payload object with zero control-block indirection, ornullptrif empty. - Parameters:
- None.
- Return Value:
- Raw pointer
T*to the managed object, ornullptr.
- Raw pointer
FORCE_INLINE T* operator->() const noexcept;
FORCE_INLINE T& operator*() const noexcept;- Purpose: Provides direct zero-indirection member access (
operator->) and dereferencing (operator*) using the cachedT*pointer. - Restrictions:
- Behavior is undefined if
*thisis empty (get() == nullptr); check validity viaoperator bool()before dereferencing.
- Behavior is undefined if
- Parameters:
- None.
- Return Value:
operator->: ReturnsT*(ptr).operator*: ReturnsT&(*ptr).
FORCE_INLINE explicit operator bool() const noexcept;- Purpose: Checks whether
*thismanages a non-null control block and object. - Parameters:
- None.
- Return Value:
trueifcb != nullptr;falseotherwise.
atomic_shared_ptr.h continuously validates split-reference invariants (such as 32-bit signed counter overflow/underflow, double-free detection when new_internal < 0, reader saturation at INT32_MAX, and invalid memory order arguments).
using FatalErrorHandler = void(*)(const char* reason) noexcept;- Purpose: Function pointer signature for custom process-wide fatal error notifications invoked before
std::abort().
inline void SetAtomicPtrErrorHandler(FatalErrorHandler handler) noexcept;- Purpose: Registers (or clears) a custom process-wide callback invoked by
fatal_panic()when an unrecoverable invariant violation occurs. - Restrictions & Guarantees:
- Thread-safe; stores
handlerintog_fatal_error_handlerwithstd::memory_order_release. - Pass
nullptrto restore the defaultstd::cerrdiagnostic logging behavior.
- Thread-safe; stores
- Parameters:
handler: Customnoexceptcallback function pointer, ornullptr.
- Return Value:
- None.