Chris@16: //////////////////////////////////////////////////////////////////////////////
Chris@16: //
Chris@16: // (C) Copyright Ion Gaztanaga 2012-2012.
Chris@16: // Distributed under the Boost Software License, Version 1.0.
Chris@16: // (See accompanying file LICENSE_1_0.txt or copy at
Chris@16: // http://www.boost.org/LICENSE_1_0.txt)
Chris@16: //
Chris@16: // See http://www.boost.org/libs/move for documentation.
Chris@16: //
Chris@16: //////////////////////////////////////////////////////////////////////////////
Chris@16:
Chris@16: //! \file
Chris@101: //! This header includes core utilities from and defines
Chris@101: //! some more advanced utilities such as:
Chris@16:
Chris@16: #ifndef BOOST_MOVE_MOVE_UTILITY_HPP
Chris@16: #define BOOST_MOVE_MOVE_UTILITY_HPP
Chris@16:
Chris@101: #ifndef BOOST_CONFIG_HPP
Chris@101: # include
Chris@101: #endif
Chris@101: #
Chris@101: #if defined(BOOST_HAS_PRAGMA_ONCE)
Chris@101: # pragma once
Chris@101: #endif
Chris@101:
Chris@16: #include
Chris@101: #include
Chris@101: #include
Chris@16:
Chris@16: #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED)
Chris@16:
Chris@16: namespace boost {
Chris@16:
Chris@16: //////////////////////////////////////////////////////////////////////////////
Chris@16: //
Chris@101: // move_if_noexcept()
Chris@16: //
Chris@16: //////////////////////////////////////////////////////////////////////////////
Chris@16:
Chris@16: template
Chris@16: inline typename ::boost::move_detail::enable_if_c
Chris@101: < enable_move_utility_emulation::value && !has_move_emulation_enabled::value
Chris@101: , typename ::boost::move_detail::add_const::type &
Chris@101: >::type
Chris@101: move_if_noexcept(T& x) BOOST_NOEXCEPT
Chris@16: {
Chris@16: return x;
Chris@16: }
Chris@16:
Chris@16: template
Chris@16: inline typename ::boost::move_detail::enable_if_c
Chris@101: < enable_move_utility_emulation::value && has_move_emulation_enabled::value
Chris@101: && ::boost::move_detail::is_nothrow_move_constructible_or_uncopyable::value, rv&>::type
Chris@101: move_if_noexcept(T& x) BOOST_NOEXCEPT
Chris@16: {
Chris@16: return *static_cast* >(::boost::move_detail::addressof(x));
Chris@16: }
Chris@16:
Chris@16: template
Chris@16: inline typename ::boost::move_detail::enable_if_c
Chris@101: < enable_move_utility_emulation::value && has_move_emulation_enabled::value
Chris@101: && ::boost::move_detail::is_nothrow_move_constructible_or_uncopyable::value
Chris@101: , rv&
Chris@101: >::type
Chris@101: move_if_noexcept(rv& x) BOOST_NOEXCEPT
Chris@16: {
Chris@16: return x;
Chris@16: }
Chris@16:
Chris@16: template
Chris@16: inline typename ::boost::move_detail::enable_if_c
Chris@101: < enable_move_utility_emulation::value && has_move_emulation_enabled::value
Chris@101: && !::boost::move_detail::is_nothrow_move_constructible_or_uncopyable::value
Chris@101: , typename ::boost::move_detail::add_const::type &
Chris@101: >::type
Chris@101: move_if_noexcept(T& x) BOOST_NOEXCEPT
Chris@16: {
Chris@101: return x;
Chris@16: }
Chris@16:
Chris@16: template
Chris@16: inline typename ::boost::move_detail::enable_if_c
Chris@101: < enable_move_utility_emulation::value && has_move_emulation_enabled::value
Chris@101: && !::boost::move_detail::is_nothrow_move_constructible_or_uncopyable::value
Chris@101: , typename ::boost::move_detail::add_const::type &
Chris@101: >::type
Chris@101: move_if_noexcept(rv& x) BOOST_NOEXCEPT
Chris@16: {
Chris@16: return x;
Chris@16: }
Chris@16:
Chris@16: } //namespace boost
Chris@16:
Chris@16: #else //#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED)
Chris@16:
Chris@16: #if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
Chris@16: #include
Chris@16:
Chris@16: namespace boost{
Chris@16:
Chris@101: using ::std::move_if_noexcept;
Chris@16:
Chris@16: } //namespace boost
Chris@16:
Chris@16: #else //!BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE
Chris@16:
Chris@16: namespace boost {
Chris@16:
Chris@16: //////////////////////////////////////////////////////////////////////////////
Chris@16: //
Chris@101: // move_if_noexcept()
Chris@16: //
Chris@16: //////////////////////////////////////////////////////////////////////////////
Chris@16: #if defined(BOOST_MOVE_DOXYGEN_INVOKED)
Chris@16: //! This function provides a way to convert a reference into a rvalue reference
Chris@16: //! in compilers with rvalue references. For other compilers converts T & into
Chris@101: //! ::boost::rv & so that move emulation is activated. Reference
Chris@101: //! would be converted to rvalue reference only if input type is nothrow move
Chris@101: //! constructible or if it has no copy constructor. In all other cases const
Chris@101: //! reference would be returned
Chris@16: template
Chris@101: rvalue_reference_or_const_lvalue_reference move_if_noexcept(input_reference) noexcept;
Chris@16:
Chris@101: #else //BOOST_MOVE_DOXYGEN_INVOKED
Chris@16:
Chris@16: template
Chris@101: typename ::boost::move_detail::enable_if_c
Chris@101: < ::boost::move_detail::is_nothrow_move_constructible_or_uncopyable::value, T&&>::type
Chris@101: move_if_noexcept(T& x) BOOST_NOEXCEPT
Chris@101: { return ::boost::move(x); }
Chris@16:
Chris@16: template
Chris@101: typename ::boost::move_detail::enable_if_c
Chris@101: < !::boost::move_detail::is_nothrow_move_constructible_or_uncopyable::value, const T&>::type
Chris@101: move_if_noexcept(T& x) BOOST_NOEXCEPT
Chris@101: { return x; }
Chris@16:
Chris@101: #endif //BOOST_MOVE_DOXYGEN_INVOKED
Chris@16:
Chris@16: } //namespace boost {
Chris@16:
Chris@16: #endif //#if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
Chris@16:
Chris@16: #endif //BOOST_NO_CXX11_RVALUE_REFERENCES
Chris@16:
Chris@16: #include
Chris@16:
Chris@16: #endif //#ifndef BOOST_MOVE_MOVE_UTILITY_HPP