Files

151 lines
5.5 KiB
C++

//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2012-2012.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/move for documentation.
//
//////////////////////////////////////////////////////////////////////////////
//! \file
//! This header includes core utilities from <tt><ActivBoost/move/utility_core.hpp></tt> and defines
//! some more advanced utilities such as:
#ifndef ACTIV_BOOST_MOVE_MOVE_UTILITY_HPP
#define ACTIV_BOOST_MOVE_MOVE_UTILITY_HPP
#ifndef ACTIV_BOOST_CONFIG_HPP
# include <ActivBoost/config.hpp>
#endif
#
#if defined(ACTIV_BOOST_HAS_PRAGMA_ONCE)
# pragma once
#endif
#include <ActivBoost/move/detail/config_begin.hpp>
#include <ActivBoost/move/detail/workaround.hpp> //forceinline
#include <ActivBoost/move/utility_core.hpp>
#include <ActivBoost/move/traits.hpp>
#if defined(ACTIV_BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(ACTIV_BOOST_MOVE_DOXYGEN_INVOKED)
namespace Boost {
//////////////////////////////////////////////////////////////////////////////
//
// move_if_noexcept()
//
//////////////////////////////////////////////////////////////////////////////
template <class T>
ACTIV_BOOST_MOVE_FORCEINLINE typename ::Boost::move_detail::enable_if_c
< enable_move_utility_emulation<T>::value && !has_move_emulation_enabled<T>::value
, typename ::Boost::move_detail::add_const<T>::type &
>::type
move_if_noexcept(T& x) ACTIV_BOOST_NOEXCEPT
{
return x;
}
template <class T>
ACTIV_BOOST_MOVE_FORCEINLINE typename ::Boost::move_detail::enable_if_c
< enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value
&& ::Boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value, rv<T>&>::type
move_if_noexcept(T& x) ACTIV_BOOST_NOEXCEPT
{
return *static_cast<rv<T>* >(::Boost::move_detail::addressof(x));
}
template <class T>
ACTIV_BOOST_MOVE_FORCEINLINE typename ::Boost::move_detail::enable_if_c
< enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value
&& ::Boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value
, rv<T>&
>::type
move_if_noexcept(rv<T>& x) ACTIV_BOOST_NOEXCEPT
{
return x;
}
template <class T>
ACTIV_BOOST_MOVE_FORCEINLINE typename ::Boost::move_detail::enable_if_c
< enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value
&& !::Boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value
, typename ::Boost::move_detail::add_const<T>::type &
>::type
move_if_noexcept(T& x) ACTIV_BOOST_NOEXCEPT
{
return x;
}
template <class T>
ACTIV_BOOST_MOVE_FORCEINLINE typename ::Boost::move_detail::enable_if_c
< enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value
&& !::Boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value
, typename ::Boost::move_detail::add_const<T>::type &
>::type
move_if_noexcept(rv<T>& x) ACTIV_BOOST_NOEXCEPT
{
return x;
}
} //namespace Boost
#else //#if defined(ACTIV_BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(ACTIV_BOOST_MOVE_DOXYGEN_INVOKED)
#if defined(ACTIV_BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
#include <utility>
namespace Boost{
using ::std::move_if_noexcept;
} //namespace Boost
#else //!ACTIV_BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE
namespace Boost {
//////////////////////////////////////////////////////////////////////////////
//
// move_if_noexcept()
//
//////////////////////////////////////////////////////////////////////////////
#if defined(ACTIV_BOOST_MOVE_DOXYGEN_INVOKED)
//! This function provides a way to convert a reference into a rvalue reference
//! in compilers with rvalue references. For other compilers converts T & into
//! <i>::Boost::rv<T> &</i> so that move emulation is activated. Reference
//! would be converted to rvalue reference only if input type is nothrow move
//! constructible or if it has no copy constructor. In all other cases const
//! reference would be returned
template <class T>
rvalue_reference_or_const_lvalue_reference move_if_noexcept(input_reference) noexcept;
#else //ACTIV_BOOST_MOVE_DOXYGEN_INVOKED
template <class T>
ACTIV_BOOST_MOVE_FORCEINLINE typename ::Boost::move_detail::enable_if_c
< ::Boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value, T&&>::type
move_if_noexcept(T& x) ACTIV_BOOST_NOEXCEPT
{ return ::Boost::move(x); }
template <class T>
ACTIV_BOOST_MOVE_FORCEINLINE typename ::Boost::move_detail::enable_if_c
< !::Boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value, const T&>::type
move_if_noexcept(T& x) ACTIV_BOOST_NOEXCEPT
{ return x; }
#endif //ACTIV_BOOST_MOVE_DOXYGEN_INVOKED
} //namespace Boost {
#endif //#if defined(ACTIV_BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
#endif //ACTIV_BOOST_NO_CXX11_RVALUE_REFERENCES
#include <ActivBoost/move/detail/config_end.hpp>
#endif //#ifndef ACTIV_BOOST_MOVE_MOVE_UTILITY_HPP