Skip to content

Commit 9b832b7

Browse files
authored
[libc++] Deprecated shared_ptr Atomic Access APIs as per P0718R2 & Implemented P2869R3: Remove Deprecated shared_ptr Atomic Access APIs from C++26 (#87111)
Implements https://wg21.link/P2869R4 Implements deprecations as per https://wg21.link/P0718R2
1 parent 6c2cc82 commit 9b832b7

30 files changed

+423
-46
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+
- P2869R4 - Remove Deprecated ``shared_ptr`` Atomic Access APIs from C++26
4647
- P2872R3 - Remove ``wstring_convert`` From C++26
4748
- P3142R0 - Printing Blank Lines with ``println`` (as DR against C++23)
4849
- P2302R4 - ``std::ranges::contains``
@@ -63,6 +64,9 @@ Improvements and New Features
6364

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

67+
- The ``_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS`` macro has been added to make the declarations in ``<memory>``
68+
available.
69+
6670
- The ``_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT`` macro has been added to make the declarations in ``<locale>``
6771
available.
6872

libcxx/docs/Status/Cxx20.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ Paper Status
5959
* ``GPS clock`` not done
6060
* ``UTC clock`` not done
6161
62+
.. [#note-P0718] P0718: Implemented deprecation of ``shared_ptr`` atomic access APIs only.
63+
6264
.. _issues-status-cxx20:
6365

6466
Library Working Group Issues Status

libcxx/docs/Status/Cxx20Papers.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"`P0600R1 <https://wg21.link/P0600R1>`__","LWG","nodiscard in the Library","Albuquerque","|Complete|","16.0"
1313
"`P0616R0 <https://wg21.link/P0616R0>`__","LWG","de-pessimize legacy <numeric> algorithms with std::move","Albuquerque","|Complete|","12.0"
1414
"`P0653R2 <https://wg21.link/P0653R2>`__","LWG","Utility to convert a pointer to a raw pointer","Albuquerque","|Complete|","6.0"
15-
"`P0718R2 <https://wg21.link/P0718R2>`__","LWG","Atomic shared_ptr","Albuquerque","",""
15+
"`P0718R2 <https://wg21.link/P0718R2>`__","LWG","Atomic shared_ptr","Albuquerque","|Partial| [#note-P0718]_",""
1616
"`P0767R1 <https://wg21.link/P0767R1>`__","CWG","Deprecate POD","Albuquerque","|Complete|","7.0"
1717
"`P0768R1 <https://wg21.link/P0768R1>`__","CWG","Library Support for the Spaceship (Comparison) Operator","Albuquerque","|Complete|",""
1818
"`P0777R1 <https://wg21.link/P0777R1>`__","LWG","Treating Unnecessary ``decay``\ ","Albuquerque","|Complete|","7.0"

libcxx/docs/Status/Cxx2cPapers.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"","","","","","",""
4949
"`P2875R4 <https://wg21.link/P2875R4>`__","LWG","Undeprecate ``polymorphic_allocator::destroy`` for C++26","Tokyo March 2024","|Complete|","15.0",""
5050
"`P2867R2 <https://wg21.link/P2867R2>`__","LWG","Remove Deprecated ``strstreams`` From C++26","Tokyo March 2024","|Complete|","19.0",""
51-
"`P2869R4 <https://wg21.link/P2869R4>`__","LWG","Remove Deprecated ``shared_ptr`` Atomic Access APIs from C++26","Tokyo March 2024","","",""
51+
"`P2869R4 <https://wg21.link/P2869R4>`__","LWG","Remove Deprecated ``shared_ptr`` Atomic Access APIs from C++26","Tokyo March 2024","|Complete|","19.0",""
5252
"`P2872R3 <https://wg21.link/P2872R3>`__","LWG","Remove ``wstring_convert`` From C++26","Tokyo March 2024","|Complete|","19.0",""
5353
"`P3107R5 <https://wg21.link/P3107R5>`__","LWG","Permit an efficient implementation of ``std::print``","Tokyo March 2024","","","|format| |DR|"
5454
"`P3142R0 <https://wg21.link/P3142R0>`__","LWG","Printing Blank Lines with ``println``","Tokyo March 2024","|Complete|","19.0","|format|"

libcxx/docs/UsingLibcxx.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,14 @@ C++26 Specific Configuration Macros
277277
**_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM**:
278278
This macro is used to re-enable all named declarations in ``<strstream>``.
279279

280+
**_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS**:
281+
This macro is used to re-enable all ``shared_ptr`` atomic access APIs in ``<memory>``.
282+
280283
**_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT**:
281284
This macro is used to re-enable the ``wstring_convert`` and ``wbuffer_convert``
282285
in ``<locale>``.
283286

287+
284288
Libc++ Extensions
285289
=================
286290

libcxx/include/__memory/shared_ptr.h

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,13 +1580,15 @@ 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>
1584-
inline _LIBCPP_HIDE_FROM_ABI bool atomic_is_lock_free(const shared_ptr<_Tp>*) {
1586+
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool atomic_is_lock_free(const shared_ptr<_Tp>*) {
15851587
return false;
15861588
}
15871589

15881590
template <class _Tp>
1589-
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> atomic_load(const shared_ptr<_Tp>* __p) {
1591+
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> atomic_load(const shared_ptr<_Tp>* __p) {
15901592
__sp_mut& __m = std::__get_sp_mut(__p);
15911593
__m.lock();
15921594
shared_ptr<_Tp> __q = *__p;
@@ -1595,25 +1597,28 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> atomic_load(const shared_ptr<_Tp>* __p) {
15951597
}
15961598

15971599
template <class _Tp>
1598-
inline _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> atomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order) {
1600+
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
1601+
atomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order) {
15991602
return std::atomic_load(__p);
16001603
}
16011604

16021605
template <class _Tp>
1603-
_LIBCPP_HIDE_FROM_ABI void atomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) {
1606+
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void atomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) {
16041607
__sp_mut& __m = std::__get_sp_mut(__p);
16051608
__m.lock();
16061609
__p->swap(__r);
16071610
__m.unlock();
16081611
}
16091612

16101613
template <class _Tp>
1611-
inline _LIBCPP_HIDE_FROM_ABI void atomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order) {
1614+
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void
1615+
atomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order) {
16121616
std::atomic_store(__p, __r);
16131617
}
16141618

16151619
template <class _Tp>
1616-
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> atomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) {
1620+
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
1621+
atomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) {
16171622
__sp_mut& __m = std::__get_sp_mut(__p);
16181623
__m.lock();
16191624
__p->swap(__r);
@@ -1622,13 +1627,13 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> atomic_exchange(shared_ptr<_Tp>* __p, shar
16221627
}
16231628

16241629
template <class _Tp>
1625-
inline _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
1630+
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
16261631
atomic_exchange_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order) {
16271632
return std::atomic_exchange(__p, __r);
16281633
}
16291634

16301635
template <class _Tp>
1631-
_LIBCPP_HIDE_FROM_ABI bool
1636+
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool
16321637
atomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w) {
16331638
shared_ptr<_Tp> __temp;
16341639
__sp_mut& __m = std::__get_sp_mut(__p);
@@ -1646,23 +1651,25 @@ atomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, share
16461651
}
16471652

16481653
template <class _Tp>
1649-
inline _LIBCPP_HIDE_FROM_ABI bool
1654+
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool
16501655
atomic_compare_exchange_weak(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w) {
16511656
return std::atomic_compare_exchange_strong(__p, __v, __w);
16521657
}
16531658

16541659
template <class _Tp>
1655-
inline _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_strong_explicit(
1660+
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_strong_explicit(
16561661
shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w, memory_order, memory_order) {
16571662
return std::atomic_compare_exchange_strong(__p, __v, __w);
16581663
}
16591664

16601665
template <class _Tp>
1661-
inline _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_weak_explicit(
1666+
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_weak_explicit(
16621667
shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w, memory_order, memory_order) {
16631668
return std::atomic_compare_exchange_weak(__p, __v, __w);
16641669
}
16651670

1671+
# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS)
1672+
16661673
#endif // !defined(_LIBCPP_HAS_NO_THREADS)
16671674

16681675
_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); // Deprecated in C++20, 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); // Deprecated in C++20, 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); // Deprecated in C++20, 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); // Deprecated in C++20, 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); // Deprecated in C++20, 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); // Deprecated in C++20, 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); // Deprecated in C++20, 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); // Deprecated in C++20, 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); // Deprecated in C++20, 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, // Deprecated in C++20, 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, // Deprecated in C++20, 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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS
10+
// UNSUPPORTED: no-threads
11+
// UNSUPPORTED: c++03, c++11, c++14, c++17
12+
13+
// <memory>
14+
15+
// shared_ptr
16+
17+
// template <class T>
18+
// bool
19+
// atomic_compare_exchange_strong(shared_ptr<T>* p, shared_ptr<T>* v,
20+
// shared_ptr<T> w); // Deprecated in C++20, removed in C++26
21+
22+
#include <atomic>
23+
#include <memory>
24+
#include <tuple>
25+
26+
void test() {
27+
std::shared_ptr<int> p(new int(4));
28+
std::shared_ptr<int> v(new int(3));
29+
std::shared_ptr<int> w(new int(2));
30+
// expected-warning@+1 {{'atomic_compare_exchange_strong<int>' is deprecated}}
31+
std::ignore = std::atomic_compare_exchange_strong(&p, &v, w);
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS
10+
// UNSUPPORTED: no-threads
11+
// UNSUPPORTED: c++03, c++11, c++14, c++17
12+
13+
// <memory>
14+
15+
// shared_ptr
16+
17+
// template <class T>
18+
// bool
19+
// atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
20+
// shared_ptr<T> w, memory_order success,
21+
// memory_order failure); // Deprecated in C++20, removed in C++26
22+
23+
#include <atomic>
24+
#include <memory>
25+
#include <tuple>
26+
27+
void test() {
28+
std::shared_ptr<int> p(new int(4));
29+
std::shared_ptr<int> v(new int(3));
30+
std::shared_ptr<int> w(new int(2));
31+
// expected-warning@+2 {{'atomic_compare_exchange_strong_explicit<int>' is deprecated}}
32+
std::ignore =
33+
std::atomic_compare_exchange_strong_explicit(&p, &v, w, std::memory_order_seq_cst, std::memory_order_seq_cst);
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS
10+
// UNSUPPORTED: no-threads
11+
// UNSUPPORTED: c++03, c++11, c++14, c++17
12+
13+
// <memory>
14+
15+
// shared_ptr
16+
17+
// template <class T>
18+
// bool
19+
// atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v,
20+
// shared_ptr<T> w); // Deprecated in C++20, removed in C++26
21+
22+
#include <memory>
23+
#include <tuple>
24+
25+
int main(int, char**) {
26+
std::shared_ptr<int> p(new int(4));
27+
std::shared_ptr<int> v(new int(3));
28+
std::shared_ptr<int> w(new int(2));
29+
// expected-warning@+1 {{'atomic_compare_exchange_weak<int>' is deprecated}}
30+
std::ignore = std::atomic_compare_exchange_weak(&p, &v, w);
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS
10+
// UNSUPPORTED: no-threads
11+
// UNSUPPORTED: c++03, c++11, c++14, c++17
12+
13+
// <memory>
14+
15+
// shared_ptr
16+
17+
// template <class T>
18+
// bool
19+
// atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
20+
// shared_ptr<T> w, memory_order success,
21+
// memory_order failure); // Deprecated in C++20, removed in C++26
22+
23+
#include <atomic>
24+
#include <memory>
25+
#include <tuple>
26+
27+
void test() {
28+
std::shared_ptr<int> p(new int(4));
29+
std::shared_ptr<int> v(new int(3));
30+
std::shared_ptr<int> w(new int(2));
31+
// expected-warning@+2 {{'atomic_compare_exchange_weak_explicit<int>' is deprecated}}
32+
std::ignore =
33+
std::atomic_compare_exchange_weak_explicit(&p, &v, w, std::memory_order_seq_cst, std::memory_order_seq_cst);
34+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS
10+
// UNSUPPORTED: no-threads
11+
// UNSUPPORTED: c++03, c++11, c++14, c++17
12+
13+
// <memory>
14+
15+
// shared_ptr
16+
17+
// template <class T>
18+
// shared_ptr<T>
19+
// atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r) // Deprecated in C++20, removed in C++26
20+
21+
#include <memory>
22+
#include <tuple>
23+
24+
void test() {
25+
std::shared_ptr<int> p(new int(4));
26+
std::shared_ptr<int> r(new int(3));
27+
// expected-warning@+1 {{'atomic_exchange<int>' is deprecated}}
28+
std::ignore = std::atomic_exchange(&p, r);
29+
}

0 commit comments

Comments
 (0)