Merge pull request #143 from boostorg/bugfix/returing-tmp-variable

Fix returing temporary variable warning on MSVC.
This commit is contained in:
Kohei Takahashi
2016-11-01 02:44:58 +09:00
committed by GitHub
2 changed files with 10 additions and 8 deletions

View File

@ -59,7 +59,7 @@ namespace boost { namespace fusion { namespace detail
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
keyed_element(keyed_element&& rhs) keyed_element(keyed_element&& rhs)
: Rest(BOOST_FUSION_FWD_ELEM(Rest, rhs.forward_base())) : Rest(rhs.forward_base())
, value_(BOOST_FUSION_FWD_ELEM(Value, rhs.value_)) , value_(BOOST_FUSION_FWD_ELEM(Value, rhs.value_))
{} {}
#endif #endif
@ -90,7 +90,7 @@ namespace boost { namespace fusion { namespace detail
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
Rest&& forward_base() BOOST_NOEXCEPT Rest&& forward_base() BOOST_NOEXCEPT
{ {
return BOOST_FUSION_FWD_ELEM(Rest, *static_cast<Rest*>(this)); return std::move(*static_cast<Rest*>(this));
} }
#endif #endif
@ -116,7 +116,7 @@ namespace boost { namespace fusion { namespace detail
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
keyed_element(Value&& value, Rest&& rest) keyed_element(Value&& value, Rest&& rest)
: Rest(BOOST_FUSION_FWD_ELEM(Rest, rest)) : Rest(std::move(rest))
, value_(BOOST_FUSION_FWD_ELEM(Value, value)) , value_(BOOST_FUSION_FWD_ELEM(Value, value))
{} {}
#endif #endif
@ -147,8 +147,8 @@ namespace boost { namespace fusion { namespace detail
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
keyed_element& operator=(keyed_element&& rhs) keyed_element& operator=(keyed_element&& rhs)
{ {
base::operator=(std::forward<keyed_element>(rhs)); base::operator=(rhs.forward_base());
value_ = BOOST_FUSION_FWD_ELEM(Value, rhs.value_); value_ = std::move(rhs.value_);
return *this; return *this;
} }
#endif #endif

View File

@ -10,7 +10,8 @@
#include <boost/detail/lightweight_test.hpp> #include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/adapted/boost_tuple.hpp> #include <boost/fusion/adapted/boost_tuple.hpp>
#include <boost/fusion/adapted/std_pair.hpp> #include <boost/fusion/adapted/std_pair.hpp>
#if !defined(BOOST_NO_CXX11_HDR_TUPLE) #if !defined(BOOST_NO_CXX11_HDR_TUPLE) \
&& !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
# include <boost/fusion/adapted/std_tuple.hpp> # include <boost/fusion/adapted/std_tuple.hpp>
#endif #endif
#include <boost/fusion/container/deque.hpp> #include <boost/fusion/container/deque.hpp>
@ -257,8 +258,9 @@ void test()
, boost::tuple<convertible, int>(500, 400) , boost::tuple<convertible, int>(500, 400)
) )
)); ));
#if !defined(BOOST_NO_CXX11_HDR_TUPLE) #if !defined(BOOST_NO_CXX11_HDR_TUPLE) \
&& !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
BOOST_TEST((run< Scenario< FUSION_SEQUENCE<> > >(std::tuple<>()))); BOOST_TEST((run< Scenario< FUSION_SEQUENCE<> > >(std::tuple<>())));
BOOST_TEST(( BOOST_TEST((
run<Scenario<FUSION_SEQUENCE<> > >(std::tuple<int>(100), std::tuple<>()) run<Scenario<FUSION_SEQUENCE<> > >(std::tuple<int>(100), std::tuple<>())