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/detail/workaround.hpp> //forceinline
29 #include <boost/move/utility_core.hpp>
30 #include <boost/move/traits.hpp>
32 #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED)
36 //////////////////////////////////////////////////////////////////////////////
40 //////////////////////////////////////////////////////////////////////////////
43 BOOST_MOVE_FORCEINLINE typename ::boost::move_detail::enable_if_c
44 < enable_move_utility_emulation<T>::value && !has_move_emulation_enabled<T>::value
45 , typename ::boost::move_detail::add_const<T>::type &
47 move_if_noexcept(T& x) BOOST_NOEXCEPT
53 BOOST_MOVE_FORCEINLINE typename ::boost::move_detail::enable_if_c
54 < enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value
55 && ::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value, rv<T>&>::type
56 move_if_noexcept(T& x) BOOST_NOEXCEPT
58 return *static_cast<rv<T>* >(::boost::move_detail::addressof(x));
62 BOOST_MOVE_FORCEINLINE typename ::boost::move_detail::enable_if_c
63 < enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value
64 && ::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value
67 move_if_noexcept(rv<T>& x) BOOST_NOEXCEPT
73 BOOST_MOVE_FORCEINLINE typename ::boost::move_detail::enable_if_c
74 < enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value
75 && !::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value
76 , typename ::boost::move_detail::add_const<T>::type &
78 move_if_noexcept(T& x) BOOST_NOEXCEPT
84 BOOST_MOVE_FORCEINLINE typename ::boost::move_detail::enable_if_c
85 < enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value
86 && !::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value
87 , typename ::boost::move_detail::add_const<T>::type &
89 move_if_noexcept(rv<T>& x) BOOST_NOEXCEPT
96 #else //#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED)
98 #if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
103 using ::std::move_if_noexcept;
107 #else //!BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE
111 //////////////////////////////////////////////////////////////////////////////
113 // move_if_noexcept()
115 //////////////////////////////////////////////////////////////////////////////
116 #if defined(BOOST_MOVE_DOXYGEN_INVOKED)
117 //! This function provides a way to convert a reference into a rvalue reference
118 //! in compilers with rvalue references. For other compilers converts T & into
119 //! <i>::boost::rv<T> &</i> so that move emulation is activated. Reference
120 //! would be converted to rvalue reference only if input type is nothrow move
121 //! constructible or if it has no copy constructor. In all other cases const
122 //! reference would be returned
124 rvalue_reference_or_const_lvalue_reference move_if_noexcept(input_reference) noexcept;
126 #else //BOOST_MOVE_DOXYGEN_INVOKED
129 BOOST_MOVE_FORCEINLINE typename ::boost::move_detail::enable_if_c
130 < ::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value, T&&>::type
131 move_if_noexcept(T& x) BOOST_NOEXCEPT
132 { return ::boost::move(x); }
135 BOOST_MOVE_FORCEINLINE typename ::boost::move_detail::enable_if_c
136 < !::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value, const T&>::type
137 move_if_noexcept(T& x) BOOST_NOEXCEPT
140 #endif //BOOST_MOVE_DOXYGEN_INVOKED
142 } //namespace boost {
144 #endif //#if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
146 #endif //BOOST_NO_CXX11_RVALUE_REFERENCES
148 #include <boost/move/detail/config_end.hpp>
150 #endif //#ifndef BOOST_MOVE_MOVE_UTILITY_HPP