Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions stl/inc/atomic
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,11 @@ inline bool __stdcall _Atomic_wait_compare_16_bytes(const void* _Storage, void*
#endif // _HAS_CXX20
#endif // TRANSITION, ABI

#if _HAS_CXX20
_EXPORT_STD template <class>
struct atomic_ref;
#endif // _HAS_CXX20

template <class _Ty, size_t /* = ... */>
struct _Atomic_storage {
// Provides operations common to all specializations of std::atomic, load, store, exchange, and CAS.
Expand Down Expand Up @@ -666,6 +671,11 @@ public:
_Ty _Storage;
mutable _Smtx_t _Mutex{};
#endif // ^^^ break ABI ^^^

#if _HAS_CXX20
template <class>
friend struct atomic_ref;
#endif // _HAS_CXX20
};

template <class _Ty>
Expand Down Expand Up @@ -2319,8 +2329,22 @@ public:
}
}

explicit atomic_ref(_Ty&&) = delete; // per LWG-4472

atomic_ref(const atomic_ref&) noexcept = default;

template <class _Uty>
requires is_convertible_v<_Uty (*)[], _Ty (*)[]>
atomic_ref(const atomic_ref<_Uty>& _Ref) noexcept : _Base(_Ref._Storage) {
if constexpr (!is_always_lock_free) {
#if 1 // TRANSITION, ABI
this->_Spinlock = _Ref._Spinlock;
#else // ^^^ don't break ABI / break ABI vvv
this->_Mutex = _Ref._Mutex;
#endif // ^^^ break ABI ^^^
}
}

atomic_ref& operator=(const atomic_ref&) = delete;

static constexpr bool is_always_lock_free =
Expand Down
1 change: 1 addition & 0 deletions stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@
// P3323R1 Forbid atomic<cv T>, Specify atomic_ref<cv T>
// (for atomic_ref<cv T>)
// P3349R1 Converting Contiguous Iterators To Pointers
// P3860R1 Make atomic_ref<T> Convertible To atomic_ref<const T>

// _HAS_CXX20 indirectly controls:
// P0619R4 Removing C++17-Deprecated Features
Expand Down
Loading