зеркало из https://github.com/microsoft/STL.git
Finish Fixing Atomic Initialization (P0883R2) (#390)
Co-authored-by: AdamBucior https://github.com/AdamBucior Co-authored-by: Casey Carter <cartec69@gmail.com> Co-authored-by: Billy O'Neal <billy.oneal@gmail.com>
This commit is contained in:
Родитель
f96c61c346
Коммит
a46d897ac0
|
@ -1443,11 +1443,7 @@ public:
|
|||
|
||||
using _Base::_Base;
|
||||
|
||||
#ifdef __clang__ // TRANSITION, VSO-406237
|
||||
constexpr atomic() noexcept(is_nothrow_default_constructible_v<_Ty>) : _Base() {}
|
||||
#else // ^^^ no workaround / workaround vvv
|
||||
atomic() = default;
|
||||
#endif // TRANSITION, VSO-406237
|
||||
|
||||
atomic(const atomic&) = delete;
|
||||
atomic& operator=(const atomic&) = delete;
|
||||
|
@ -1609,7 +1605,8 @@ _NODISCARD bool atomic_is_lock_free(const atomic<_Ty>* _Mem) noexcept {
|
|||
}
|
||||
|
||||
template <class _Ty>
|
||||
void atomic_init(atomic<_Ty>* const _Mem, const typename atomic<_Ty>::value_type _Value) noexcept {
|
||||
_CXX20_DEPRECATE_ATOMIC_INIT void atomic_init(
|
||||
atomic<_Ty>* const _Mem, const typename atomic<_Ty>::value_type _Value) noexcept {
|
||||
#if 1 // TRANSITION, ABI
|
||||
_CSTD memcpy(_STD addressof(_Mem->_Storage), _STD addressof(_Value), sizeof(_Ty));
|
||||
#else // ^^^ don't break ABI / break ABI vvv
|
||||
|
@ -1619,7 +1616,8 @@ void atomic_init(atomic<_Ty>* const _Mem, const typename atomic<_Ty>::value_type
|
|||
}
|
||||
|
||||
template <class _Ty>
|
||||
void atomic_init(volatile atomic<_Ty>* const _Mem, const typename atomic<_Ty>::value_type _Value) noexcept {
|
||||
_CXX20_DEPRECATE_ATOMIC_INIT void atomic_init(
|
||||
volatile atomic<_Ty>* const _Mem, const typename atomic<_Ty>::value_type _Value) noexcept {
|
||||
// NB: respecting volatility here appears unimplementable
|
||||
_STD atomic_init(const_cast<atomic<_Ty>*>(_Mem), _Value);
|
||||
}
|
||||
|
@ -1947,11 +1945,7 @@ struct atomic_flag { // flag with test-and-set semantics
|
|||
_Storage.store(false, _Order);
|
||||
}
|
||||
|
||||
#ifdef __clang__ // TRANSITION, VSO-406237
|
||||
constexpr atomic_flag() noexcept = default;
|
||||
#else // ^^^ no workaround / workaround vvv
|
||||
atomic_flag() noexcept = default;
|
||||
#endif // TRANSITION, VSO-406237
|
||||
|
||||
#if 1 // TRANSITION, ABI
|
||||
atomic<long> _Storage;
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
// P0771R1 noexcept For std::function's Move Constructor
|
||||
// P0777R1 Avoiding Unnecessary decay
|
||||
// P0809R0 Comparing Unordered Containers
|
||||
// P0883R2 Fixing Atomic Initialization
|
||||
// P0941R2 Feature-Test Macros
|
||||
// P0972R0 noexcept For <chrono> zero(), min(), max()
|
||||
// P1164R1 Making create_directory() Intuitive
|
||||
|
@ -886,7 +887,19 @@
|
|||
#define _CXX20_DEPRECATE_REL_OPS
|
||||
#endif // ^^^ warning disabled ^^^
|
||||
|
||||
// next warning number: STL4028
|
||||
#if _HAS_CXX20 && !defined(_SILENCE_CXX20_ATOMIC_INIT_DEPRECATION_WARNING) \
|
||||
&& !defined(_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS)
|
||||
#define _CXX20_DEPRECATE_ATOMIC_INIT \
|
||||
[[deprecated("warning STL4028: " \
|
||||
"std::atomic_init() overloads are deprecated in C++20. " \
|
||||
"The constructors of std::atomic provide equivalent functionality. " \
|
||||
"You can define _SILENCE_CXX20_ATOMIC_INIT_DEPRECATION_WARNING " \
|
||||
"or _SILENCE_ALL_CXX20_DEPRECATION_WARNINGS to acknowledge that you have received this warning.")]]
|
||||
#else // ^^^ warning enabled / warning disabled vvv
|
||||
#define _CXX20_DEPRECATE_ATOMIC_INIT
|
||||
#endif // ^^^ warning disabled ^^^
|
||||
|
||||
// next warning number: STL4029
|
||||
|
||||
|
||||
// LIBRARY FEATURE-TEST MACROS
|
||||
|
@ -977,6 +990,8 @@
|
|||
#endif // _HAS_CXX17
|
||||
|
||||
// C++20
|
||||
#define __cpp_lib_atomic_value_initialization 201911L
|
||||
|
||||
#if _HAS_CXX20
|
||||
#define __cpp_lib_atomic_float 201711L
|
||||
#define __cpp_lib_bind_front 201907L
|
||||
|
|
Загрузка…
Ссылка в новой задаче