YouCompleteMe/cpp/BoostParts/boost/thread/detail/move.hpp

262 lines
7.0 KiB
C++
Raw Normal View History

2012-05-10 00:45:30 -04:00
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// (C) Copyright 2007-8 Anthony Williams
2012-07-21 14:37:40 -04:00
// (C) Copyright 2011-2012 Vicente J. Botet Escriba
2012-05-10 00:45:30 -04:00
#ifndef BOOST_THREAD_MOVE_HPP
#define BOOST_THREAD_MOVE_HPP
#include <boost/thread/detail/config.hpp>
#ifndef BOOST_NO_SFINAE
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/remove_reference.hpp>
2012-07-21 14:37:40 -04:00
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/decay.hpp>
2012-05-10 00:45:30 -04:00
#endif
2012-07-21 14:37:40 -04:00
#include <boost/thread/detail/delete.hpp>
2013-02-13 23:03:52 -05:00
#include <boost/move/utility.hpp>
2012-05-10 00:45:30 -04:00
#include <boost/config/abi_prefix.hpp>
namespace boost
{
namespace detail
{
2012-07-21 14:37:40 -04:00
template <typename T>
2013-02-13 23:03:52 -05:00
struct enable_move_utility_emulation_dummy_specialization;
2012-05-10 00:45:30 -04:00
template<typename T>
struct thread_move_t
{
T& t;
explicit thread_move_t(T& t_):
t(t_)
{}
T& operator*() const
{
return t;
}
T* operator->() const
{
return &t;
}
private:
void operator=(thread_move_t&);
};
}
2013-02-13 23:03:52 -05:00
#if !defined BOOST_THREAD_USES_MOVE
2012-07-21 14:37:40 -04:00
2012-05-10 00:45:30 -04:00
#ifndef BOOST_NO_SFINAE
template<typename T>
typename enable_if<boost::is_convertible<T&,boost::detail::thread_move_t<T> >, boost::detail::thread_move_t<T> >::type move(T& t)
{
return boost::detail::thread_move_t<T>(t);
}
#endif
template<typename T>
boost::detail::thread_move_t<T> move(boost::detail::thread_move_t<T> t)
{
return t;
}
2013-02-13 23:03:52 -05:00
#endif //#if !defined BOOST_THREAD_USES_MOVE
2012-07-21 14:37:40 -04:00
}
2013-01-13 17:38:19 -05:00
#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
2012-07-21 14:37:40 -04:00
#define BOOST_THREAD_RV_REF(TYPE) BOOST_RV_REF(TYPE)
2013-02-13 23:03:52 -05:00
#define BOOST_THREAD_RV_REF_2_TEMPL_ARGS(TYPE) BOOST_RV_REF_2_TEMPL_ARGS(TYPE)
2012-07-21 14:37:40 -04:00
#define BOOST_THREAD_RV_REF_BEG BOOST_RV_REF_BEG
#define BOOST_THREAD_RV_REF_END BOOST_RV_REF_END
#define BOOST_THREAD_RV(V) V
#define BOOST_THREAD_MAKE_RV_REF(RVALUE) RVALUE
#define BOOST_THREAD_FWD_REF(TYPE) BOOST_FWD_REF(TYPE)
#define BOOST_THREAD_DCL_MOVABLE(TYPE)
#define BOOST_THREAD_DCL_MOVABLE_BEG(T) \
namespace detail { \
template <typename T> \
2013-02-13 23:03:52 -05:00
struct enable_move_utility_emulation_dummy_specialization<
2012-07-21 14:37:40 -04:00
#define BOOST_THREAD_DCL_MOVABLE_END > \
2013-02-13 23:03:52 -05:00
: integral_constant<bool, false> \
2012-07-21 14:37:40 -04:00
{}; \
}
2013-01-13 17:38:19 -05:00
#elif ! defined BOOST_NO_CXX11_RVALUE_REFERENCES && defined BOOST_MSVC
2012-07-21 14:37:40 -04:00
#define BOOST_THREAD_RV_REF(TYPE) BOOST_RV_REF(TYPE)
2013-02-13 23:03:52 -05:00
#define BOOST_THREAD_RV_REF_2_TEMPL_ARGS(TYPE) BOOST_RV_REF_2_TEMPL_ARGS(TYPE)
2012-07-21 14:37:40 -04:00
#define BOOST_THREAD_RV_REF_BEG BOOST_RV_REF_BEG
#define BOOST_THREAD_RV_REF_END BOOST_RV_REF_END
#define BOOST_THREAD_RV(V) V
#define BOOST_THREAD_MAKE_RV_REF(RVALUE) RVALUE
#define BOOST_THREAD_FWD_REF(TYPE) BOOST_FWD_REF(TYPE)
#define BOOST_THREAD_DCL_MOVABLE(TYPE)
#define BOOST_THREAD_DCL_MOVABLE_BEG(T) \
namespace detail { \
template <typename T> \
2013-02-13 23:03:52 -05:00
struct enable_move_utility_emulation_dummy_specialization<
2012-07-21 14:37:40 -04:00
#define BOOST_THREAD_DCL_MOVABLE_END > \
2013-02-13 23:03:52 -05:00
: integral_constant<bool, false> \
2012-07-21 14:37:40 -04:00
{}; \
}
#else
#if defined BOOST_THREAD_USES_MOVE
#define BOOST_THREAD_RV_REF(TYPE) BOOST_RV_REF(TYPE)
2013-02-13 23:03:52 -05:00
#define BOOST_THREAD_RV_REF_2_TEMPL_ARGS(TYPE) BOOST_RV_REF_2_TEMPL_ARGS(TYPE)
2012-07-21 14:37:40 -04:00
#define BOOST_THREAD_RV_REF_BEG BOOST_RV_REF_BEG
#define BOOST_THREAD_RV_REF_END BOOST_RV_REF_END
#define BOOST_THREAD_RV(V) V
#define BOOST_THREAD_FWD_REF(TYPE) BOOST_FWD_REF(TYPE)
#define BOOST_THREAD_DCL_MOVABLE(TYPE)
#define BOOST_THREAD_DCL_MOVABLE_BEG(T) \
namespace detail { \
template <typename T> \
2013-02-13 23:03:52 -05:00
struct enable_move_utility_emulation_dummy_specialization<
2012-07-21 14:37:40 -04:00
#define BOOST_THREAD_DCL_MOVABLE_END > \
2013-02-13 23:03:52 -05:00
: integral_constant<bool, false> \
2012-07-21 14:37:40 -04:00
{}; \
}
#else
#define BOOST_THREAD_RV_REF(TYPE) boost::detail::thread_move_t< TYPE >
#define BOOST_THREAD_RV_REF_BEG boost::detail::thread_move_t<
#define BOOST_THREAD_RV_REF_END >
#define BOOST_THREAD_RV(V) (*V)
#define BOOST_THREAD_FWD_REF(TYPE) BOOST_FWD_REF(TYPE)
#define BOOST_THREAD_DCL_MOVABLE(TYPE) \
template <> \
2013-02-13 23:03:52 -05:00
struct enable_move_utility_emulation< TYPE > \
{ \
static const bool value = false; \
};
2012-07-21 14:37:40 -04:00
#define BOOST_THREAD_DCL_MOVABLE_BEG(T) \
template <typename T> \
2013-02-13 23:03:52 -05:00
struct enable_move_utility_emulation<
2012-07-21 14:37:40 -04:00
#define BOOST_THREAD_DCL_MOVABLE_END > \
2013-02-13 23:03:52 -05:00
{ \
static const bool value = false; \
};
2012-07-21 14:37:40 -04:00
#endif
namespace boost
{
namespace detail
{
template <typename T>
BOOST_THREAD_RV_REF(typename ::boost::remove_cv<typename ::boost::remove_reference<T>::type>::type)
make_rv_ref(T v) BOOST_NOEXCEPT
{
return (BOOST_THREAD_RV_REF(typename ::boost::remove_cv<typename ::boost::remove_reference<T>::type>::type))(v);
}
// template <typename T>
// BOOST_THREAD_RV_REF(typename ::boost::remove_cv<typename ::boost::remove_reference<T>::type>::type)
// make_rv_ref(T &v) BOOST_NOEXCEPT
// {
// return (BOOST_THREAD_RV_REF(typename ::boost::remove_cv<typename ::boost::remove_reference<T>::type>::type))(v);
// }
// template <typename T>
// const BOOST_THREAD_RV_REF(typename ::boost::remove_cv<typename ::boost::remove_reference<T>::type>::type)
// make_rv_ref(T const&v) BOOST_NOEXCEPT
// {
// return (const BOOST_THREAD_RV_REF(typename ::boost::remove_cv<typename ::boost::remove_reference<T>::type>::type))(v);
// }
}
}
#define BOOST_THREAD_MAKE_RV_REF(RVALUE) RVALUE.move()
//#define BOOST_THREAD_MAKE_RV_REF(RVALUE) boost::detail::make_rv_ref(RVALUE)
#endif
2013-01-13 17:38:19 -05:00
#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
2012-07-21 14:37:40 -04:00
#define BOOST_THREAD_MOVABLE(TYPE)
#else
#if defined BOOST_THREAD_USES_MOVE
2012-05-10 00:45:30 -04:00
2012-07-21 14:37:40 -04:00
#define BOOST_THREAD_MOVABLE(TYPE) \
::boost::rv<TYPE>& move() BOOST_NOEXCEPT \
{ \
return *static_cast< ::boost::rv<TYPE>* >(this); \
} \
const ::boost::rv<TYPE>& move() const BOOST_NOEXCEPT \
{ \
return *static_cast<const ::boost::rv<TYPE>* >(this); \
} \
operator ::boost::rv<TYPE>&() \
{ \
return *static_cast< ::boost::rv<TYPE>* >(this); \
} \
operator const ::boost::rv<TYPE>&() const \
{ \
return *static_cast<const ::boost::rv<TYPE>* >(this); \
}\
2012-05-10 00:45:30 -04:00
2012-07-21 14:37:40 -04:00
#else
#define BOOST_THREAD_MOVABLE(TYPE) \
operator ::boost::detail::thread_move_t<TYPE>() BOOST_NOEXCEPT \
{ \
return move(); \
} \
::boost::detail::thread_move_t<TYPE> move() BOOST_NOEXCEPT \
{ \
::boost::detail::thread_move_t<TYPE> x(*this); \
return x; \
} \
#endif
#endif
#define BOOST_THREAD_MOVABLE_ONLY(TYPE) \
BOOST_THREAD_NO_COPYABLE(TYPE) \
BOOST_THREAD_MOVABLE(TYPE) \
#define BOOST_THREAD_COPYABLE_AND_MOVABLE(TYPE) \
BOOST_THREAD_MOVABLE(TYPE) \
namespace boost
{ namespace thread_detail
{
2013-02-13 23:03:52 -05:00
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
2012-07-21 14:37:40 -04:00
template <class T>
typename decay<T>::type
decay_copy(T&& t)
{
return boost::forward<T>(t);
}
2013-02-13 23:03:52 -05:00
#else
template <class T>
typename decay<T>::type
decay_copy(BOOST_THREAD_FWD_REF(T) t)
{
return boost::forward<T>(t);
2012-07-21 14:37:40 -04:00
}
#endif
2013-02-13 23:03:52 -05:00
}
}
2012-05-10 00:45:30 -04:00
#include <boost/config/abi_suffix.hpp>
#endif