Chris@16
|
1 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 //
|
Chris@16
|
3 // (C) Copyright Ion Gaztanaga 2012-2012.
|
Chris@16
|
4 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
5 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
6 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 //
|
Chris@16
|
8 // See http://www.boost.org/libs/move for documentation.
|
Chris@16
|
9 //
|
Chris@16
|
10 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
11
|
Chris@16
|
12 //! \file
|
Chris@101
|
13 //! This header includes core utilities from <tt><boost/move/utility_core.hpp></tt> and defines
|
Chris@101
|
14 //! some more advanced utilities such as:
|
Chris@16
|
15
|
Chris@16
|
16 #ifndef BOOST_MOVE_MOVE_UTILITY_HPP
|
Chris@16
|
17 #define BOOST_MOVE_MOVE_UTILITY_HPP
|
Chris@16
|
18
|
Chris@101
|
19 #ifndef BOOST_CONFIG_HPP
|
Chris@101
|
20 # include <boost/config.hpp>
|
Chris@101
|
21 #endif
|
Chris@101
|
22 #
|
Chris@101
|
23 #if defined(BOOST_HAS_PRAGMA_ONCE)
|
Chris@101
|
24 # pragma once
|
Chris@101
|
25 #endif
|
Chris@101
|
26
|
Chris@16
|
27 #include <boost/move/detail/config_begin.hpp>
|
Chris@101
|
28 #include <boost/move/utility_core.hpp>
|
Chris@101
|
29 #include <boost/move/traits.hpp>
|
Chris@16
|
30
|
Chris@16
|
31 #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
Chris@16
|
32
|
Chris@16
|
33 namespace boost {
|
Chris@16
|
34
|
Chris@16
|
35 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
36 //
|
Chris@101
|
37 // move_if_noexcept()
|
Chris@16
|
38 //
|
Chris@16
|
39 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
40
|
Chris@16
|
41 template <class T>
|
Chris@16
|
42 inline typename ::boost::move_detail::enable_if_c
|
Chris@101
|
43 < enable_move_utility_emulation<T>::value && !has_move_emulation_enabled<T>::value
|
Chris@101
|
44 , typename ::boost::move_detail::add_const<T>::type &
|
Chris@101
|
45 >::type
|
Chris@101
|
46 move_if_noexcept(T& x) BOOST_NOEXCEPT
|
Chris@16
|
47 {
|
Chris@16
|
48 return x;
|
Chris@16
|
49 }
|
Chris@16
|
50
|
Chris@16
|
51 template <class T>
|
Chris@16
|
52 inline typename ::boost::move_detail::enable_if_c
|
Chris@101
|
53 < enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value
|
Chris@101
|
54 && ::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value, rv<T>&>::type
|
Chris@101
|
55 move_if_noexcept(T& x) BOOST_NOEXCEPT
|
Chris@16
|
56 {
|
Chris@16
|
57 return *static_cast<rv<T>* >(::boost::move_detail::addressof(x));
|
Chris@16
|
58 }
|
Chris@16
|
59
|
Chris@16
|
60 template <class T>
|
Chris@16
|
61 inline typename ::boost::move_detail::enable_if_c
|
Chris@101
|
62 < enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value
|
Chris@101
|
63 && ::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value
|
Chris@101
|
64 , rv<T>&
|
Chris@101
|
65 >::type
|
Chris@101
|
66 move_if_noexcept(rv<T>& x) BOOST_NOEXCEPT
|
Chris@16
|
67 {
|
Chris@16
|
68 return x;
|
Chris@16
|
69 }
|
Chris@16
|
70
|
Chris@16
|
71 template <class T>
|
Chris@16
|
72 inline typename ::boost::move_detail::enable_if_c
|
Chris@101
|
73 < enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value
|
Chris@101
|
74 && !::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value
|
Chris@101
|
75 , typename ::boost::move_detail::add_const<T>::type &
|
Chris@101
|
76 >::type
|
Chris@101
|
77 move_if_noexcept(T& x) BOOST_NOEXCEPT
|
Chris@16
|
78 {
|
Chris@101
|
79 return x;
|
Chris@16
|
80 }
|
Chris@16
|
81
|
Chris@16
|
82 template <class T>
|
Chris@16
|
83 inline typename ::boost::move_detail::enable_if_c
|
Chris@101
|
84 < enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value
|
Chris@101
|
85 && !::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value
|
Chris@101
|
86 , typename ::boost::move_detail::add_const<T>::type &
|
Chris@101
|
87 >::type
|
Chris@101
|
88 move_if_noexcept(rv<T>& x) BOOST_NOEXCEPT
|
Chris@16
|
89 {
|
Chris@16
|
90 return x;
|
Chris@16
|
91 }
|
Chris@16
|
92
|
Chris@16
|
93 } //namespace boost
|
Chris@16
|
94
|
Chris@16
|
95 #else //#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
Chris@16
|
96
|
Chris@16
|
97 #if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
|
Chris@16
|
98 #include <utility>
|
Chris@16
|
99
|
Chris@16
|
100 namespace boost{
|
Chris@16
|
101
|
Chris@101
|
102 using ::std::move_if_noexcept;
|
Chris@16
|
103
|
Chris@16
|
104 } //namespace boost
|
Chris@16
|
105
|
Chris@16
|
106 #else //!BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE
|
Chris@16
|
107
|
Chris@16
|
108 namespace boost {
|
Chris@16
|
109
|
Chris@16
|
110 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
111 //
|
Chris@101
|
112 // move_if_noexcept()
|
Chris@16
|
113 //
|
Chris@16
|
114 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
115 #if defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
Chris@16
|
116 //! This function provides a way to convert a reference into a rvalue reference
|
Chris@16
|
117 //! in compilers with rvalue references. For other compilers converts T & into
|
Chris@101
|
118 //! <i>::boost::rv<T> &</i> so that move emulation is activated. Reference
|
Chris@101
|
119 //! would be converted to rvalue reference only if input type is nothrow move
|
Chris@101
|
120 //! constructible or if it has no copy constructor. In all other cases const
|
Chris@101
|
121 //! reference would be returned
|
Chris@16
|
122 template <class T>
|
Chris@101
|
123 rvalue_reference_or_const_lvalue_reference move_if_noexcept(input_reference) noexcept;
|
Chris@16
|
124
|
Chris@101
|
125 #else //BOOST_MOVE_DOXYGEN_INVOKED
|
Chris@16
|
126
|
Chris@16
|
127 template <class T>
|
Chris@101
|
128 typename ::boost::move_detail::enable_if_c
|
Chris@101
|
129 < ::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value, T&&>::type
|
Chris@101
|
130 move_if_noexcept(T& x) BOOST_NOEXCEPT
|
Chris@101
|
131 { return ::boost::move(x); }
|
Chris@16
|
132
|
Chris@16
|
133 template <class T>
|
Chris@101
|
134 typename ::boost::move_detail::enable_if_c
|
Chris@101
|
135 < !::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value, const T&>::type
|
Chris@101
|
136 move_if_noexcept(T& x) BOOST_NOEXCEPT
|
Chris@101
|
137 { return x; }
|
Chris@16
|
138
|
Chris@101
|
139 #endif //BOOST_MOVE_DOXYGEN_INVOKED
|
Chris@16
|
140
|
Chris@16
|
141 } //namespace boost {
|
Chris@16
|
142
|
Chris@16
|
143 #endif //#if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
|
Chris@16
|
144
|
Chris@16
|
145 #endif //BOOST_NO_CXX11_RVALUE_REFERENCES
|
Chris@16
|
146
|
Chris@16
|
147 #include <boost/move/detail/config_end.hpp>
|
Chris@16
|
148
|
Chris@16
|
149 #endif //#ifndef BOOST_MOVE_MOVE_UTILITY_HPP
|