Mercurial > hg > vamp-build-and-test
diff DEPENDENCIES/generic/include/boost/move/utility.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
line wrap: on
line diff
--- a/DEPENDENCIES/generic/include/boost/move/utility.hpp Fri Sep 04 12:01:02 2015 +0100 +++ b/DEPENDENCIES/generic/include/boost/move/utility.hpp Mon Sep 07 11:12:49 2015 +0100 @@ -10,72 +10,82 @@ ////////////////////////////////////////////////////////////////////////////// //! \file +//! This header includes core utilities from <tt><boost/move/utility_core.hpp></tt> and defines +//! some more advanced utilities such as: #ifndef BOOST_MOVE_MOVE_UTILITY_HPP #define BOOST_MOVE_MOVE_UTILITY_HPP +#ifndef BOOST_CONFIG_HPP +# include <boost/config.hpp> +#endif +# +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + #include <boost/move/detail/config_begin.hpp> -#include <boost/move/core.hpp> -#include <boost/move/detail/meta_utils.hpp> +#include <boost/move/utility_core.hpp> +#include <boost/move/traits.hpp> #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED) namespace boost { - template<class T> - struct enable_move_utility_emulation - { - static const bool value = true; - }; - ////////////////////////////////////////////////////////////////////////////// // - // move() + // move_if_noexcept() // ////////////////////////////////////////////////////////////////////////////// template <class T> inline typename ::boost::move_detail::enable_if_c - < enable_move_utility_emulation<T>::value && !has_move_emulation_enabled<T>::value, T&>::type - move(T& x) BOOST_NOEXCEPT + < enable_move_utility_emulation<T>::value && !has_move_emulation_enabled<T>::value + , typename ::boost::move_detail::add_const<T>::type & + >::type + move_if_noexcept(T& x) BOOST_NOEXCEPT { return x; } template <class T> inline typename ::boost::move_detail::enable_if_c - < enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value, rv<T>&>::type - move(T& x) BOOST_NOEXCEPT + < enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value + && ::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value, rv<T>&>::type + move_if_noexcept(T& x) BOOST_NOEXCEPT { return *static_cast<rv<T>* >(::boost::move_detail::addressof(x)); } template <class T> inline typename ::boost::move_detail::enable_if_c - < enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value, rv<T>&>::type - move(rv<T>& x) BOOST_NOEXCEPT + < enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value + && ::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value + , rv<T>& + >::type + move_if_noexcept(rv<T>& x) BOOST_NOEXCEPT { return x; } - ////////////////////////////////////////////////////////////////////////////// - // - // forward() - // - ////////////////////////////////////////////////////////////////////////////// - template <class T> inline typename ::boost::move_detail::enable_if_c - < enable_move_utility_emulation<T>::value && ::boost::move_detail::is_rv<T>::value, T &>::type - forward(const typename ::boost::move_detail::identity<T>::type &x) BOOST_NOEXCEPT + < enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value + && !::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value + , typename ::boost::move_detail::add_const<T>::type & + >::type + move_if_noexcept(T& x) BOOST_NOEXCEPT { - return const_cast<T&>(x); + return x; } template <class T> inline typename ::boost::move_detail::enable_if_c - < enable_move_utility_emulation<T>::value && !::boost::move_detail::is_rv<T>::value, const T &>::type - forward(const typename ::boost::move_detail::identity<T>::type &x) BOOST_NOEXCEPT + < enable_move_utility_emulation<T>::value && has_move_emulation_enabled<T>::value + && !::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value + , typename ::boost::move_detail::add_const<T>::type & + >::type + move_if_noexcept(rv<T>& x) BOOST_NOEXCEPT { return x; } @@ -89,99 +99,44 @@ namespace boost{ - using ::std::move; - using ::std::forward; + using ::std::move_if_noexcept; } //namespace boost #else //!BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE - #include <boost/type_traits/remove_reference.hpp> - namespace boost { - //! This trait's internal boolean `value` is false in compilers with rvalue references - //! and true in compilers without rvalue references. - //! - //! A user can specialize this trait for a type T to false to SFINAE out `move` and `forward` - //! so that the user can define a different move emulation for that type in namespace boost - //! (e.g. another Boost library for its types) and avoid any overload ambiguity. - template<class T> - struct enable_move_utility_emulation - { - static const bool value = false; - }; - ////////////////////////////////////////////////////////////////////////////// // - // move + // move_if_noexcept() // ////////////////////////////////////////////////////////////////////////////// - #if defined(BOOST_MOVE_DOXYGEN_INVOKED) //! This function provides a way to convert a reference into a rvalue reference //! in compilers with rvalue references. For other compilers converts T & into - //! <i>::boost::rv<T> &</i> so that move emulation is activated. + //! <i>::boost::rv<T> &</i> so that move emulation is activated. Reference + //! would be converted to rvalue reference only if input type is nothrow move + //! constructible or if it has no copy constructor. In all other cases const + //! reference would be returned template <class T> - rvalue_reference move(input_reference) noexcept; + rvalue_reference_or_const_lvalue_reference move_if_noexcept(input_reference) noexcept; - #elif defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES) - - //Old move approach, lvalues could bind to rvalue references - template <class T> - inline typename remove_reference<T>::type && move(T&& t) BOOST_NOEXCEPT - { return t; } - - #else //BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES + #else //BOOST_MOVE_DOXYGEN_INVOKED template <class T> - inline typename remove_reference<T>::type && move(T&& t) BOOST_NOEXCEPT - { return static_cast<typename remove_reference<T>::type &&>(t); } - - #endif //BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES - - ////////////////////////////////////////////////////////////////////////////// - // - // forward - // - ////////////////////////////////////////////////////////////////////////////// - - - #if defined(BOOST_MOVE_DOXYGEN_INVOKED) - //! This function provides limited form of forwarding that is usually enough for - //! in-place construction and avoids the exponential overloading for - //! achieve the limited forwarding in C++03. - //! - //! For compilers with rvalue references this function provides perfect forwarding. - //! - //! Otherwise: - //! * If input_reference binds to const ::boost::rv<T> & then it output_reference is - //! ::boost::rv<T> & - //! - //! * Else, output_reference is equal to input_reference. - template <class T> output_reference forward(input_reference) noexcept; - #elif defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES) - - //Old move approach, lvalues could bind to rvalue references + typename ::boost::move_detail::enable_if_c + < ::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value, T&&>::type + move_if_noexcept(T& x) BOOST_NOEXCEPT + { return ::boost::move(x); } template <class T> - inline T&& forward(typename ::boost::move_detail::identity<T>::type&& t) BOOST_NOEXCEPT - { return t; } + typename ::boost::move_detail::enable_if_c + < !::boost::move_detail::is_nothrow_move_constructible_or_uncopyable<T>::value, const T&>::type + move_if_noexcept(T& x) BOOST_NOEXCEPT + { return x; } - #else //Old move - - //Implementation #5 from N2951, thanks to Howard Hinnant - - template <class T, class U> - inline T&& forward(U&& t - , typename ::boost::move_detail::enable_if_c< - move_detail::is_lvalue_reference<T>::value ? move_detail::is_lvalue_reference<U>::value : true>::type * = 0/* - , typename ::boost::move_detail::enable_if_c< - move_detail::is_convertible - <typename remove_reference<U>::type*, typename remove_reference<T>::type*>::value>::type * = 0*/) BOOST_NOEXCEPT - { return static_cast<T&&>(t); } - - #endif //BOOST_MOVE_DOXYGEN_INVOKED + #endif //BOOST_MOVE_DOXYGEN_INVOKED } //namespace boost {