boost_no_cxx11_atomic_sp.ipp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // (C) Copyright John Maddock 2012
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/config for more information.
  6. // MACRO: BOOST_NO_CXX11_ATOMIC_SMART_PTR
  7. // TITLE: C++11 <memory> does not support atomic smart pointer operations
  8. // DESCRIPTION: The compiler does not support the C++11 atomic smart pointer features added to <memory>
  9. #include <memory>
  10. namespace boost_no_cxx11_atomic_smart_ptr {
  11. int test()
  12. {
  13. std::shared_ptr<int> spi(new int), spi2(new int);
  14. spi = std::static_pointer_cast<int>(spi);
  15. atomic_is_lock_free(&spi);
  16. atomic_load(&spi);
  17. atomic_load_explicit(&spi, std::memory_order_relaxed);
  18. atomic_store(&spi, spi2);
  19. atomic_store_explicit(&spi, spi2, std::memory_order_relaxed);
  20. atomic_exchange(&spi, spi2);
  21. atomic_compare_exchange_weak(&spi, &spi2, spi);
  22. atomic_compare_exchange_strong(&spi, &spi2, spi);
  23. atomic_compare_exchange_weak_explicit(&spi, &spi2, spi, std::memory_order_relaxed, std::memory_order_relaxed);
  24. atomic_compare_exchange_strong_explicit(&spi, &spi2, spi, std::memory_order_relaxed, std::memory_order_relaxed);
  25. return 0;
  26. }
  27. }