atomic_exchange_explicit.pass.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. // <memory>
  16. // shared_ptr
  17. // template <class T>
  18. // shared_ptr<T>
  19. // atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r)
  20. // UNSUPPORTED: c++98, c++03
  21. #include <memory>
  22. #include <cassert>
  23. #include "test_macros.h"
  24. int main(int, char**)
  25. {
  26. {
  27. std::shared_ptr<int> p(new int(4));
  28. std::shared_ptr<int> r(new int(3));
  29. r = std::atomic_exchange_explicit(&p, r, std::memory_order_seq_cst);
  30. assert(*p == 3);
  31. assert(*r == 4);
  32. }
  33. return 0;
  34. }