forked from boostorg/fusion
Replace some usage of std::forward to static_cast.
For more details, See inline comment of include/boost/fusion/support/config.hpp .
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#define FUSION_SUPPORT_CONFIG_01092014_1718
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#ifndef BOOST_FUSION_GPU_ENABLED
|
||||
#define BOOST_FUSION_GPU_ENABLED BOOST_GPU_ENABLED
|
||||
@@ -39,4 +40,32 @@ namespace boost { namespace fusion { namespace detail
|
||||
#define BOOST_FUSION_BARRIER_BEGIN namespace barrier {
|
||||
#define BOOST_FUSION_BARRIER_END }
|
||||
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1900))
|
||||
// All of rvalue-reference ready MSVC don't perform implicit conversion from
|
||||
// fundamental type to rvalue-reference of another fundamental type [1].
|
||||
//
|
||||
// Following example doesn't compile
|
||||
//
|
||||
// int i;
|
||||
// long &&l = i; // sigh..., std::forward<long&&>(i) also fail.
|
||||
//
|
||||
// however, following one will work.
|
||||
//
|
||||
// int i;
|
||||
// long &&l = static_cast<long &&>(i);
|
||||
//
|
||||
// OK, now can we replace all usage of std::forward to static_cast? -- I say NO!
|
||||
// All of rvalue-reference ready Clang doesn't compile above static_cast usage [2], sigh...
|
||||
//
|
||||
// References:
|
||||
// 1. https://connect.microsoft.com/VisualStudio/feedback/details/1037806/implicit-conversion-doesnt-perform-for-fund
|
||||
// 2. http://llvm.org/bugs/show_bug.cgi?id=19917
|
||||
//
|
||||
// Tentatively, we use static_cast to forward if run under MSVC.
|
||||
# define BOOST_FUSION_FWD_ELEM(type, value) static_cast<type&&>(value)
|
||||
#else
|
||||
# define BOOST_FUSION_FWD_ELEM(type, value) std::forward<type>(value)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -41,7 +41,7 @@ namespace boost { namespace fusion
|
||||
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
pair(pair&& rhs)
|
||||
: second(std::forward<Second>(rhs.second)) {}
|
||||
: second(BOOST_FUSION_FWD_ELEM(Second, rhs.second)) {}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace boost { namespace fusion
|
||||
pair(Second2&& val
|
||||
, typename boost::disable_if<is_lvalue_reference<Second2> >::type* /* dummy */ = 0
|
||||
, typename boost::enable_if<is_convertible<Second2, Second> >::type* /*dummy*/ = 0
|
||||
) : second(std::forward<Second>(val)) {}
|
||||
) : second(BOOST_FUSION_FWD_ELEM(Second, val)) {}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace boost { namespace fusion
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
pair& operator=(pair&& rhs)
|
||||
{
|
||||
second = std::forward<Second>(rhs.second);
|
||||
second = BOOST_FUSION_FWD_ELEM(Second, rhs.second);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user