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 // UNSUPPORTED: libcpp-has-no-threads
10 //
11 // This test uses new symbols that were not defined in the libc++ shipped on
12 // darwin11 and darwin12:
13 // XFAIL: availability=macosx10.7
14 // XFAIL: availability=macosx10.8
15 
16 // <memory>
17 
18 // shared_ptr
19 
20 // template <class T>
21 // shared_ptr<T>
22 // atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r)
23 
24 // UNSUPPORTED: c++98, c++03
25 
26 #include <memory>
27 #include <cassert>
28 
29 #include "test_macros.h"
30 
31 int main(int, char**)
32 {
33     {
34         std::shared_ptr<int> p(new int(4));
35         std::shared_ptr<int> r(new int(3));
36         r = std::atomic_exchange(&p, r);
37         assert(*p == 3);
38         assert(*r == 4);
39     }
40 
41   return 0;
42 }
43