forked from boostorg/move
Reduced unused classes from meta_utiles and simplified the implementation of several traits classes to avoid inheritance from integral_constant
Moved declval to utility_core.hpp
This commit is contained in:
@@ -47,103 +47,24 @@ struct has_trivial_destructor_after_move
|
||||
//! and assignment can specialize this trait to obtain some performance improvements.
|
||||
template <class T>
|
||||
struct has_nothrow_move
|
||||
: public ::boost::move_detail::integral_constant
|
||||
< bool
|
||||
, boost::is_nothrow_move_constructible<T>::value &&
|
||||
boost::is_nothrow_move_assignable<T>::value
|
||||
>
|
||||
{};
|
||||
{
|
||||
static const bool value = boost::is_nothrow_move_constructible<T>::value &&
|
||||
boost::is_nothrow_move_assignable<T>::value;
|
||||
};
|
||||
|
||||
namespace move_detail {
|
||||
|
||||
template <class T>
|
||||
struct is_nothrow_move_constructible_or_uncopyable
|
||||
: public ::boost::move_detail::integral_constant
|
||||
< bool
|
||||
//The standard requires is_nothrow_move_constructible for move_if_noexcept
|
||||
//but a user (usually in C++03) might specialize has_nothrow_move which includes it
|
||||
, boost::is_nothrow_move_constructible<T>::value ||
|
||||
has_nothrow_move<T>::value ||
|
||||
!boost::is_copy_constructible<T>::value
|
||||
>
|
||||
{};
|
||||
|
||||
// Code from Jeffrey Lee Hellrung, many thanks
|
||||
|
||||
template< class T > struct is_rvalue_reference : ::boost::move_detail::integral_constant<bool, false> { };
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template< class T > struct is_rvalue_reference< T&& > : ::boost::move_detail::integral_constant<bool, true> { };
|
||||
#else // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template< class T > struct is_rvalue_reference< boost::rv<T>& >
|
||||
: ::boost::move_detail::integral_constant<bool, true>
|
||||
{};
|
||||
|
||||
template< class T > struct is_rvalue_reference< const boost::rv<T>& >
|
||||
: ::boost::move_detail::integral_constant<bool, true>
|
||||
{};
|
||||
#endif // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template< class T > struct add_rvalue_reference { typedef T&& type; };
|
||||
#else // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
namespace detail_add_rvalue_reference
|
||||
{
|
||||
template< class T
|
||||
, bool emulation = ::boost::has_move_emulation_enabled<T>::value
|
||||
, bool rv = ::boost::move_detail::is_rv<T>::value >
|
||||
struct add_rvalue_reference_impl { typedef T type; };
|
||||
|
||||
template< class T, bool emulation>
|
||||
struct add_rvalue_reference_impl< T, emulation, true > { typedef T & type; };
|
||||
|
||||
template< class T, bool rv >
|
||||
struct add_rvalue_reference_impl< T, true, rv > { typedef ::boost::rv<T>& type; };
|
||||
} // namespace detail_add_rvalue_reference
|
||||
|
||||
template< class T >
|
||||
struct add_rvalue_reference
|
||||
: detail_add_rvalue_reference::add_rvalue_reference_impl<T>
|
||||
{ };
|
||||
|
||||
template< class T >
|
||||
struct add_rvalue_reference<T &>
|
||||
{ typedef T & type; };
|
||||
|
||||
#endif // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
template< class T > struct remove_rvalue_reference { typedef T type; };
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template< class T > struct remove_rvalue_reference< T&& > { typedef T type; };
|
||||
#else // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template< class T > struct remove_rvalue_reference< rv<T> > { typedef T type; };
|
||||
template< class T > struct remove_rvalue_reference< const rv<T> > { typedef T type; };
|
||||
template< class T > struct remove_rvalue_reference< volatile rv<T> > { typedef T type; };
|
||||
template< class T > struct remove_rvalue_reference< const volatile rv<T> > { typedef T type; };
|
||||
template< class T > struct remove_rvalue_reference< rv<T>& > { typedef T type; };
|
||||
template< class T > struct remove_rvalue_reference< const rv<T>& > { typedef T type; };
|
||||
template< class T > struct remove_rvalue_reference< volatile rv<T>& > { typedef T type; };
|
||||
template< class T > struct remove_rvalue_reference< const volatile rv<T>& >{ typedef T type; };
|
||||
#endif // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
template <typename T>
|
||||
typename boost::move_detail::add_rvalue_reference<T>::type declval();
|
||||
{
|
||||
//The standard requires is_nothrow_move_constructible for move_if_noexcept
|
||||
//but a user (usually in C++03) might specialize has_nothrow_move which includes it
|
||||
static const bool value = boost::is_nothrow_move_constructible<T>::value ||
|
||||
has_nothrow_move<T>::value ||
|
||||
!boost::is_copy_constructible<T>::value;
|
||||
};
|
||||
|
||||
} //move_detail {
|
||||
|
||||
// Ideas from Boost.Move review, Jeffrey Lee Hellrung:
|
||||
//
|
||||
//- TypeTraits metafunctions is_lvalue_reference, add_lvalue_reference, and remove_lvalue_reference ?
|
||||
// Perhaps add_reference and remove_reference can be modified so that they behave wrt emulated rvalue
|
||||
// references the same as wrt real rvalue references, i.e., add_reference< rv<T>& > -> T& rather than
|
||||
// rv<T>& (since T&& & -> T&).
|
||||
//
|
||||
//- Add'l TypeTraits has_[trivial_]move_{constructor,assign}...?
|
||||
//
|
||||
//- An as_lvalue(T& x) function, which amounts to an identity operation in C++0x, but strips emulated
|
||||
// rvalue references in C++03. This may be necessary to prevent "accidental moves".
|
||||
|
||||
|
||||
} //namespace boost {
|
||||
|
||||
#include <boost/move/detail/config_end.hpp>
|
||||
|
||||
Reference in New Issue
Block a user