Home | History | Annotate | Download | only in util.smartptr.shared.atomic
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // UNSUPPORTED: libcpp-has-no-threads
     11 //
     12 // This test uses new symbols that were not defined in the libc++ shipped on
     13 // darwin11 and darwin12:
     14 // XFAIL: availability=macosx10.7
     15 // XFAIL: availability=macosx10.8
     16 
     17 // <memory>
     18 
     19 // shared_ptr
     20 
     21 // template <class T>
     22 // shared_ptr<T>
     23 // atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r)
     24 
     25 // UNSUPPORTED: c++98, c++03
     26 
     27 #include <memory>
     28 #include <cassert>
     29 
     30 #include "test_macros.h"
     31 
     32 int main()
     33 {
     34     {
     35         std::shared_ptr<int> p(new int(4));
     36         std::shared_ptr<int> r(new int(3));
     37         r = std::atomic_exchange_explicit(&p, r, std::memory_order_seq_cst);
     38         assert(*p == 3);
     39         assert(*r == 4);
     40     }
     41 }
     42