sp_forward.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef BOOST_SMART_PTR_DETAIL_SP_FORWARD_HPP_INCLUDED
  2. #define BOOST_SMART_PTR_DETAIL_SP_FORWARD_HPP_INCLUDED
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  5. # pragma once
  6. #endif
  7. // detail/sp_forward.hpp
  8. //
  9. // Copyright 2008,2012 Peter Dimov
  10. //
  11. // Distributed under the Boost Software License, Version 1.0.
  12. // See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt
  14. #include <boost/config.hpp>
  15. namespace boost
  16. {
  17. namespace detail
  18. {
  19. #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
  20. #if defined( BOOST_GCC ) && __GNUC__ * 100 + __GNUC_MINOR__ <= 404
  21. // GCC 4.4 supports an outdated version of rvalue references and creates a copy of the forwarded object.
  22. // This results in warnings 'returning reference to temporary'. Therefore we use a special version similar to std::forward.
  23. template< class T > T&& sp_forward( T && t ) BOOST_NOEXCEPT
  24. {
  25. return t;
  26. }
  27. #else
  28. template< class T > T&& sp_forward( T & t ) BOOST_NOEXCEPT
  29. {
  30. return static_cast< T&& >( t );
  31. }
  32. #endif
  33. #endif
  34. } // namespace detail
  35. } // namespace boost
  36. #endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_FORWARD_HPP_INCLUDED