Skip to content

Commit f8060ad

Browse files
committed
[libc++] P2869R3: Remove Deprecated shared_ptr Atomic Access APIs from C++26
Implements https://wg21.link/P2869R3
1 parent 4abb722 commit f8060ad

15 files changed

+58
-33
lines changed

libcxx/docs/ReleaseNotes/19.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Implemented Papers
4343
- P2819R2 - Add ``tuple`` protocol to ``complex``
4444
- P2495R3 - Interfacing ``stringstream``\s with ``string_view``
4545
- P2867R2 - Remove Deprecated ``strstream``\s From C++26
46+
- P2869R3 - Remove Deprecated ``shared_ptr`` Atomic Access APIs from C++26
4647
- P2872R3 - Remove ``wstring_convert`` From C++26
4748
- P2302R4 - ``std::ranges::contains``
4849
- P1659R3 - ``std::ranges::starts_with`` and ``std::ranges::ends_with``
@@ -58,6 +59,9 @@ Improvements and New Features
5859

5960
- The ``_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM`` macro has been added to make the declarations in ``<strstream>`` available.
6061

62+
- The ``_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS`` macro has been added to make the declarations in ``<memory>``
63+
available.
64+
6165
- The ``_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT`` macro has been added to make the declarations in ``<locale>``
6266
available.
6367

libcxx/include/__memory/shared_ptr.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,6 +1580,8 @@ class _LIBCPP_EXPORTED_FROM_ABI __sp_mut {
15801580

15811581
_LIBCPP_EXPORTED_FROM_ABI __sp_mut& __get_sp_mut(const void*);
15821582

1583+
# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS)
1584+
15831585
template <class _Tp>
15841586
inline _LIBCPP_HIDE_FROM_ABI bool atomic_is_lock_free(const shared_ptr<_Tp>*) {
15851587
return false;
@@ -1663,6 +1665,8 @@ inline _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_weak_explicit(
16631665
return std::atomic_compare_exchange_weak(__p, __v, __w);
16641666
}
16651667

1668+
# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS)
1669+
16661670
#endif // !defined(_LIBCPP_HAS_NO_THREADS)
16671671

16681672
_LIBCPP_END_NAMESPACE_STD

libcxx/include/memory

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -830,34 +830,34 @@ public:
830830
};
831831
832832
template<class T>
833-
bool atomic_is_lock_free(const shared_ptr<T>* p);
833+
bool atomic_is_lock_free(const shared_ptr<T>* p); // Removed in C++26
834834
template<class T>
835-
shared_ptr<T> atomic_load(const shared_ptr<T>* p);
835+
shared_ptr<T> atomic_load(const shared_ptr<T>* p); // Removed in C++26
836836
template<class T>
837-
shared_ptr<T> atomic_load_explicit(const shared_ptr<T>* p, memory_order mo);
837+
shared_ptr<T> atomic_load_explicit(const shared_ptr<T>* p, memory_order mo); // Removed in C++26
838838
template<class T>
839-
void atomic_store(shared_ptr<T>* p, shared_ptr<T> r);
839+
void atomic_store(shared_ptr<T>* p, shared_ptr<T> r); // Removed in C++26
840840
template<class T>
841-
void atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo);
841+
void atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo); // Removed in C++26
842842
template<class T>
843-
shared_ptr<T> atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r);
843+
shared_ptr<T> atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r); // Removed in C++26
844844
template<class T>
845845
shared_ptr<T>
846-
atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo);
846+
atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo); // Removed in C++26
847847
template<class T>
848848
bool
849-
atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
849+
atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w); // Removed in C++26
850850
template<class T>
851851
bool
852-
atomic_compare_exchange_strong( shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
852+
atomic_compare_exchange_strong( shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w); // Removed in C++26
853853
template<class T>
854854
bool
855-
atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
855+
atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v, // Removed in C++26
856856
shared_ptr<T> w, memory_order success,
857857
memory_order failure);
858858
template<class T>
859859
bool
860-
atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
860+
atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v, // Removed in C++26
861861
shared_ptr<T> w, memory_order success,
862862
memory_order failure);
863863
// Hash support

libcxx/modules/std/memory.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ export namespace std {
190190
// using std::inout_ptr;
191191

192192
#ifndef _LIBCPP_HAS_NO_THREADS
193+
194+
# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS)
195+
193196
// [depr.util.smartptr.shared.atomic]
194197
using std::atomic_is_lock_free;
195198

@@ -206,5 +209,8 @@ export namespace std {
206209
using std::atomic_compare_exchange_strong_explicit;
207210
using std::atomic_compare_exchange_weak;
208211
using std::atomic_compare_exchange_weak_explicit;
212+
213+
# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS)
214+
209215
#endif // _LIBCPP_HAS_NO_THREADS
210216
} // namespace std

libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
//
8+
9+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS
910
// UNSUPPORTED: no-threads
1011

1112
// <memory>
@@ -15,7 +16,7 @@
1516
// template <class T>
1617
// bool
1718
// atomic_compare_exchange_strong(shared_ptr<T>* p, shared_ptr<T>* v,
18-
// shared_ptr<T> w);
19+
// shared_ptr<T> w); // Removed in C++26
1920

2021
// UNSUPPORTED: c++03
2122

libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
//
8+
9+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS
910
// UNSUPPORTED: no-threads
1011

1112
// <memory>
@@ -16,7 +17,7 @@
1617
// bool
1718
// atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
1819
// shared_ptr<T> w, memory_order success,
19-
// memory_order failure);
20+
// memory_order failure); // Removed in C++26
2021

2122
// UNSUPPORTED: c++03
2223

libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
//
8+
9+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS
910
// UNSUPPORTED: no-threads
1011

1112
// <memory>
@@ -15,7 +16,7 @@
1516
// template <class T>
1617
// bool
1718
// atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v,
18-
// shared_ptr<T> w);
19+
// shared_ptr<T> w); // Removed in C++26
1920

2021
// UNSUPPORTED: c++03
2122

libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
//
8+
9+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS
910
// UNSUPPORTED: no-threads
1011

1112
// <memory>
@@ -16,7 +17,7 @@
1617
// bool
1718
// atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
1819
// shared_ptr<T> w, memory_order success,
19-
// memory_order failure);
20+
// memory_order failure); // Removed in C++26
2021

2122
// UNSUPPORTED: c++03
2223

libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
//
8+
9+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS
910
// UNSUPPORTED: no-threads
1011

1112
// <memory>
@@ -14,7 +15,7 @@
1415

1516
// template <class T>
1617
// shared_ptr<T>
17-
// atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r)
18+
// atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r) // Removed in C++26
1819

1920
// UNSUPPORTED: c++03
2021

libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
//
8+
9+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS
910
// UNSUPPORTED: no-threads
1011

1112
// <memory>
@@ -14,7 +15,7 @@
1415

1516
// template <class T>
1617
// shared_ptr<T>
17-
// atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r)
18+
// atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r) // Removed in C++26
1819

1920
// UNSUPPORTED: c++03
2021

libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_is_lock_free.pass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
//
8+
9+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS
910
// UNSUPPORTED: no-threads
1011

1112
// <memory>
@@ -14,7 +15,7 @@
1415

1516
// template<class T>
1617
// bool
17-
// atomic_is_lock_free(const shared_ptr<T>* p);
18+
// atomic_is_lock_free(const shared_ptr<T>* p); // Removed in C++26
1819

1920
// UNSUPPORTED: c++03
2021

libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
//
8+
9+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS
910
// UNSUPPORTED: no-threads
1011

1112
// <memory>
@@ -14,7 +15,7 @@
1415

1516
// template <class T>
1617
// shared_ptr<T>
17-
// atomic_load(const shared_ptr<T>* p)
18+
// atomic_load(const shared_ptr<T>* p) // Removed in C++26
1819

1920
// UNSUPPORTED: c++03
2021

libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
//
8+
9+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS
910
// UNSUPPORTED: no-threads
1011

1112
// <memory>
@@ -14,7 +15,7 @@
1415

1516
// template <class T>
1617
// shared_ptr<T>
17-
// atomic_load_explicit(const shared_ptr<T>* p, memory_order mo)
18+
// atomic_load_explicit(const shared_ptr<T>* p, memory_order mo) // Removed in C++26
1819

1920
// UNSUPPORTED: c++03
2021

libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
//
8+
9+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS
910
// UNSUPPORTED: no-threads
1011

1112
// <memory>
@@ -14,7 +15,7 @@
1415

1516
// template <class T>
1617
// void
17-
// atomic_store(shared_ptr<T>* p, shared_ptr<T> r)
18+
// atomic_store(shared_ptr<T>* p, shared_ptr<T> r) // Removed in C++26
1819

1920
// UNSUPPORTED: c++03
2021

libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
//
8+
9+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS
910
// UNSUPPORTED: no-threads
1011

1112
// <memory>
@@ -14,7 +15,7 @@
1415

1516
// template <class T>
1617
// void
17-
// atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo)
18+
// atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo) // Removed in C++26
1819

1920
// UNSUPPORTED: c++03
2021

0 commit comments

Comments
 (0)