1//////////////////////////////////////////////////////////////////////////////
2//
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)
7//
8// See http://www.boost.org/libs/move for documentation.
9//
10//////////////////////////////////////////////////////////////////////////////
11
12//! \file
13//! This header includes core utilities from <tt><boost/move/utility_core.hpp></tt> and defines
14//! some more advanced utilities such as:
15
16#ifndef BOOST_MOVE_MOVE_UTILITY_HPP
17#define BOOST_MOVE_MOVE_UTILITY_HPP
18
19#ifndef BOOST_CONFIG_HPP
20# include <boost/config.hpp>
21#endif
22#
23#if defined(BOOST_HAS_PRAGMA_ONCE)
24# pragma once
25#endif
26
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>
31
32#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED)
33
34 namespace boost {
35
36 //////////////////////////////////////////////////////////////////////////////
37 //
38 // move_if_noexcept()
39 //
40 //////////////////////////////////////////////////////////////////////////////
41
42 template <class T>
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 &
46 >::type
47 move_if_noexcept(T& x) BOOST_NOEXCEPT
48 {
49 return x;
50 }
51
52 template <class T>
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
57 {
58 return *static_cast<rv<T>* >(::boost::move_detail::addressof(x));
59 }
60
61 template <class T>
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
65 , rv<T>&
66 >::type
67 move_if_noexcept(rv<T>& x) BOOST_NOEXCEPT
68 {
69 return x;
70 }
71
72 template <class T>
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 &
77 >::type
78 move_if_noexcept(T& x) BOOST_NOEXCEPT
79 {
80 return x;
81 }
82
83 template <class T>
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 &
88 >::type
89 move_if_noexcept(rv<T>& x) BOOST_NOEXCEPT
90 {
91 return x;
92 }
93
94 } //namespace boost
95
96#else //#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED)
97
98 #if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
99 #include <utility>
100
101 namespace boost{
102
103 using ::std::move_if_noexcept;
104
105 } //namespace boost
106
107 #else //!BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE
108
109 namespace boost {
110
111 //////////////////////////////////////////////////////////////////////////////
112 //
113 // move_if_noexcept()
114 //
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
123 template <class T>
124 rvalue_reference_or_const_lvalue_reference move_if_noexcept(input_reference) noexcept;
125
126 #else //BOOST_MOVE_DOXYGEN_INVOKED
127
128 template <class T>
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); }
133
134 template <class T>
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
138 { return x; }
139
140 #endif //BOOST_MOVE_DOXYGEN_INVOKED
141
142 } //namespace boost {
143
144 #endif //#if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
145
146#endif //BOOST_NO_CXX11_RVALUE_REFERENCES
147
148#include <boost/move/detail/config_end.hpp>
149
150#endif //#ifndef BOOST_MOVE_MOVE_UTILITY_HPP
151

source code of include/boost/move/utility.hpp