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 // <memory> 11 12 // shared_ptr 13 14 // template <class T> 15 // shared_ptr<T> 16 // atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r) 17 18 #include <memory> 19 #include <cassert> 20 21 int main() 22 { 23 #if __has_feature(cxx_atomic) 24 { 25 std::shared_ptr<int> p(new int(4)); 26 std::shared_ptr<int> r(new int(3)); 27 r = std::atomic_exchange_explicit(&p, r, std::memory_order_seq_cst); 28 assert(*p == 3); 29 assert(*r == 4); 30 } 31 #endif 32 } 33