1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2012-2012.
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // See http://www.boost.org/libs/move for documentation.
10 //////////////////////////////////////////////////////////////////////////////
13 //! This header includes core utilities from <tt><boost/move/utility_core.hpp></tt> and defines
14 //! some more advanced utilities such as:
16 #ifndef BOOST_MOVE_MOVE_UTILITY_HPP
17 #define BOOST_MOVE_MOVE_UTILITY_HPP
19 #ifndef BOOST_CONFIG_HPP
20 # include <boost/config.hpp>
23 #if defined(BOOST_HAS_PRAGMA_ONCE)
27 #include <boost/move/detail/config_begin.hpp>
28 #include <boost/move/utility_core.hpp>
29 #include <boost/move/traits.hpp>
31 #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED)
35 //////////////////////////////////////////////////////////////////////////////
39 //////////////////////////////////////////////////////////////////////////////
42 inline typename ::boost::move_detail::enable_if_c
43 < enable_move_utility_emulation<T>::value && !has_move_emulation_enabled<T>::value
44 , typename ::boost::move_detail::add_const<T>::type &
46 move_if_noexcept(T& x) BOOST_NOEXCEPT
52 inline typename ::boost::move_detail::enable_if_c
53 < enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value
54 && ::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value, rv<T>&>::type
55 move_if_noexcept(T& x) BOOST_NOEXCEPT
57 return *static_cast<rv<T>* >(::boost::move_detail::addressof(x));
61 inline typename ::boost::move_detail::enable_if_c
62 < enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value
63 && ::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value
66 move_if_noexcept(rv<T>& x) BOOST_NOEXCEPT
72 inline typename ::boost::move_detail::enable_if_c
73 < enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value
74 && !::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value
75 , typename ::boost::move_detail::add_const<T>::type &
77 move_if_noexcept(T& x) BOOST_NOEXCEPT
83 inline typename ::boost::move_detail::enable_if_c
84 < enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value
85 && !::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value
86 , typename ::boost::move_detail::add_const<T>::type &
88 move_if_noexcept(rv<T>& x) BOOST_NOEXCEPT
95 #else //#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED)
97 #if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
102 using ::std::move_if_noexcept;
106 #else //!BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE
110 //////////////////////////////////////////////////////////////////////////////
112 // move_if_noexcept()
114 //////////////////////////////////////////////////////////////////////////////
115 #if defined(BOOST_MOVE_DOXYGEN_INVOKED)
116 //! This function provides a way to convert a reference into a rvalue reference
117 //! in compilers with rvalue references. For other compilers converts T & into
118 //! <i>::boost::rv<T> &</i> so that move emulation is activated. Reference
119 //! would be converted to rvalue reference only if input type is nothrow move
120 //! constructible or if it has no copy constructor. In all other cases const
121 //! reference would be returned
123 rvalue_reference_or_const_lvalue_reference move_if_noexcept(input_reference) noexcept;
125 #else //BOOST_MOVE_DOXYGEN_INVOKED
128 typename ::boost::move_detail::enable_if_c
129 < ::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value, T&&>::type
130 move_if_noexcept(T& x) BOOST_NOEXCEPT
131 { return ::boost::move(x); }
134 typename ::boost::move_detail::enable_if_c
135 < !::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value, const T&>::type
136 move_if_noexcept(T& x) BOOST_NOEXCEPT
139 #endif //BOOST_MOVE_DOXYGEN_INVOKED
141 } //namespace boost {
143 #endif //#if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
145 #endif //BOOST_NO_CXX11_RVALUE_REFERENCES
147 #include <boost/move/detail/config_end.hpp>
149 #endif //#ifndef BOOST_MOVE_MOVE_UTILITY_HPP