launder.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/container for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. #ifndef BOOST_MOVE_DETAIL_LAUNDER_HPP
  11. #define BOOST_MOVE_DETAIL_LAUNDER_HPP
  12. #ifndef BOOST_CONFIG_HPP
  13. # include <boost/config.hpp>
  14. #endif
  15. #if defined(BOOST_HAS_PRAGMA_ONCE)
  16. # pragma once
  17. #endif
  18. #include <boost/move/detail/workaround.hpp>
  19. namespace boost {
  20. namespace move_detail {
  21. #if defined(BOOST_MOVE_HAS_BUILTIN_LAUNDER)
  22. template<class T>
  23. BOOST_MOVE_FORCEINLINE T* launder(T* p)
  24. {
  25. return __builtin_launder( p );
  26. }
  27. #else
  28. template<class T>
  29. BOOST_MOVE_FORCEINLINE T* launder(T* p)
  30. {
  31. return p;
  32. }
  33. #endif
  34. template<class T>
  35. BOOST_MOVE_FORCEINLINE T launder_cast(const volatile void* p)
  36. {
  37. return (launder)((T)p);
  38. }
  39. } //namespace move_detail {
  40. } //namespace boost {
  41. #endif //#ifndef BOOST_MOVE_DETAIL_LAUNDER_HPP