correct fix for ticket 10676. this is a temporary fix until we overhaul the fold implementation.

This commit is contained in:
Joel de Guzman
2014-10-27 19:45:38 +08:00
parent 06a46de636
commit c704efb49c
4 changed files with 47 additions and 4 deletions

View File

@ -47,7 +47,7 @@ namespace boost { namespace fusion
{ {
template<typename State, typename It, typename F> template<typename State, typename It, typename F>
struct BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state) struct BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)
: boost::tr1_result_of< : fusion::detail::result_of_with_decltype<
F( F(
typename add_reference<typename add_const<State>::type>::type, typename add_reference<typename add_const<State>::type>::type,
BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It)) BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It))
@ -327,7 +327,7 @@ namespace boost { namespace fusion
{ {
typedef typename typedef typename
BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)<
typename boost::tr1_result_of< typename fusion::detail::result_of_with_decltype<
F( F(
StateRef, StateRef,
BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM( BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(

View File

@ -14,7 +14,7 @@ namespace boost { namespace fusion
{ {
template<typename State, typename It, typename F> template<typename State, typename It, typename F>
struct fold_lvalue_state struct fold_lvalue_state
: boost::result_of< : fusion::detail::result_of_with_decltype<
F( F(
typename add_reference<typename add_const<State>::type>::type, typename add_reference<typename add_const<State>::type>::type,
typename fusion::result_of::deref<It>::type) typename fusion::result_of::deref<It>::type)
@ -273,7 +273,7 @@ namespace boost { namespace fusion
{ {
typedef typename typedef typename
result_of_unrolled_fold< result_of_unrolled_fold<
typename boost::tr1_result_of< typename fusion::detail::result_of_with_decltype<
F( F(
StateRef, StateRef,
typename fusion::result_of::deref< It0 const>::type typename fusion::result_of::deref< It0 const>::type

View File

@ -10,6 +10,7 @@
#define BOOST_FUSION_ALGORITHM_ITERATION_FOLD_HPP #define BOOST_FUSION_ALGORITHM_ITERATION_FOLD_HPP
#include <boost/fusion/support/config.hpp> #include <boost/fusion/support/config.hpp>
#include <boost/fusion/support/detail/result_of.hpp>
#include <boost/fusion/algorithm/iteration/fold_fwd.hpp> #include <boost/fusion/algorithm/iteration/fold_fwd.hpp>
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp> #include <boost/fusion/sequence/intrinsic/begin.hpp>

View File

@ -0,0 +1,42 @@
/*=============================================================================
Copyright (c) 2001-2014 Joel de Guzman
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)
==============================================================================*/
#if !defined(FUSION_RESULT_OF_10272014_0654)
#define FUSION_RESULT_OF_10272014_0654
#include <boost/utility/result_of.hpp>
namespace boost { namespace fusion { namespace detail
{
// This is a temporary workaround for result_of before we make fusion fully
// sfinae result_of friendy, which will require some heavy lifting for some
// low level code. So far this is used only in the fold algorithm. This will
// be removed once we overhaul fold.
#if defined(BOOST_NO_CXX11_DECLTYPE)
template <typename Sig>
struct result_of_with_decltype : boost::tr1_result_of<Sig> {};
#else
BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
BOOST_MPL_HAS_XXX_TEMPLATE_DEF(result)
template <typename Sig>
struct result_of_with_decltype;
template <typename F, typename... Args>
struct result_of_with_decltype<F(Args...)>
: mpl::if_<mpl::or_<has_result_type<F>, detail::has_result<F>>,
boost::tr1_result_of<F(Args...)>,
boost::detail::cpp0x_result_of<F(Args...)>>::type {};
#endif
}}}
#endif