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/utility_core.hpp>
29#include <boost/move/traits.hpp>
30
31#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED)
32
33 namespace boost {
34
35 //////////////////////////////////////////////////////////////////////////////
36 //
37 // move_if_noexcept()
38 //
39 //////////////////////////////////////////////////////////////////////////////
40
41 template <class T>
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 &
45 >::type
46 move_if_noexcept(T& x) BOOST_NOEXCEPT
47 {
48 return x;
49 }
50
51 template <class T>
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
56 {
57 return *static_cast<rv<T>* >(::boost::move_detail::addressof(x));
58 }
59
60 template <class T>
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
64 , rv<T>&
65 >::type
66 move_if_noexcept(rv<T>& x) BOOST_NOEXCEPT
67 {
68 return x;
69 }
70
71 template <class T>
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 &
76 >::type
77 move_if_noexcept(T& x) BOOST_NOEXCEPT
78 {
79 return x;
80 }
81
82 template <class T>
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 &
87 >::type
88 move_if_noexcept(rv<T>& x) BOOST_NOEXCEPT
89 {
90 return x;
91 }
92
93 } //namespace boost
94
95#else //#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED)
96
97 #if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
98 #include <utility>
99
100 namespace boost{
101
102 using ::std::move_if_noexcept;
103
104 } //namespace boost
105
106 #else //!BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE
107
108 namespace boost {
109
110 //////////////////////////////////////////////////////////////////////////////
111 //
112 // move_if_noexcept()
113 //
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
122 template <class T>
123 rvalue_reference_or_const_lvalue_reference move_if_noexcept(input_reference) noexcept;
124
125 #else //BOOST_MOVE_DOXYGEN_INVOKED
126
127 template <class T>
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); }
132
133 template <class T>
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
137 { return x; }
138
139 #endif //BOOST_MOVE_DOXYGEN_INVOKED
140
141 } //namespace boost {
142
143 #endif //#if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
144
145#endif //BOOST_NO_CXX11_RVALUE_REFERENCES
146
147#include <boost/move/detail/config_end.hpp>
148
149#endif //#ifndef BOOST_MOVE_MOVE_UTILITY_HPP
150

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