summaryrefslogtreecommitdiff
path: root/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp')
-rw-r--r--boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp138
1 files changed, 77 insertions, 61 deletions
diff --git a/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp b/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp
index cc78231a50..947897821a 100644
--- a/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp
+++ b/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp
@@ -13,7 +13,7 @@ namespace boost { namespace fusion
{
template<typename State, typename It, typename F>
struct reverse_fold_lvalue_state
- : boost::result_of<
+ : fusion::detail::result_of_with_decltype<
F(
typename add_reference<typename add_const<State>::type>::type,
typename fusion::result_of::deref<It>::type)
@@ -22,35 +22,11 @@ namespace boost { namespace fusion
template<typename Result,int N>
struct unrolled_reverse_fold
{
- template<typename State, typename It0, typename F>
- BOOST_FUSION_GPU_ENABLED
+ template<typename State3, typename It3, typename F>
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result
- call(State const& state,It0 const& it0,F f)
+ call_3(State3 const& state3,It3 const& it3,F& f)
{
- typedef typename
- result_of::prior<
- It0 const
- >::type
- It1;
- It1 it1 = fusion::prior(it0);
- typedef typename
- result_of::prior<
- It1
- >::type
- It2;
- It2 it2 = fusion::prior(it1);
- typedef typename
- result_of::prior<
- It2
- >::type
- It3;
- It3 it3 = fusion::prior(it2);
- typedef typename reverse_fold_lvalue_state<State,It0,F>::type State1;
- State1 const state1=f(state,fusion::deref(it0));
- typedef typename reverse_fold_lvalue_state<State1,It1,F>::type State2;
- State2 const state2=f(state1,fusion::deref(it1));
- typedef typename reverse_fold_lvalue_state<State2,It2,F>::type State3;
- State3 const state3=f(state2,fusion::deref(it2));
return unrolled_reverse_fold<
Result
, N-4
@@ -59,54 +35,94 @@ namespace boost { namespace fusion
fusion::prior(it3),
f);
}
+ template<typename State2, typename It2, typename F>
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
+ static Result
+ call_2(State2 const& state2,It2 const& it2,F& f)
+ {
+ return call_3(
+ f(state2,fusion::deref(it2)),
+ fusion::prior(it2),
+ f);
+ }
+ template<typename State1, typename It1, typename F>
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
+ static Result
+ call_1(State1 const& state1,It1 const& it1,F& f)
+ {
+ return call_2(
+ f(state1,fusion::deref(it1)),
+ fusion::prior(it1),
+ f);
+ }
+ template<typename State, typename It0, typename F>
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
+ static Result
+ call(State const& state,It0 const& it0,F f)
+ {
+ return call_1(
+ f(state,fusion::deref(it0)),
+ fusion::prior(it0),
+ f);
+ }
};
template<typename Result>
struct unrolled_reverse_fold<Result,3>
{
+ template<typename State2, typename It2, typename F>
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
+ static Result
+ call_2(State2 const& state2,It2 const& it2,F& f)
+ {
+ return f(state2,fusion::deref(it2));
+ }
+ template<typename State1, typename It1, typename F>
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
+ static Result
+ call_1(State1 const& state1,It1 const& it1,F& f)
+ {
+ return call_2(
+ f(state1,fusion::deref(it1)),
+ fusion::prior(it1),
+ f);
+ }
template<typename State, typename It0, typename F>
- BOOST_FUSION_GPU_ENABLED
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result
call(State const& state,It0 const& it0,F f)
{
- typedef typename
- result_of::prior<
- It0 const
- >::type
- It1;
- It1 it1 = fusion::prior(it0);
- typedef typename
- result_of::prior<
- It1
- >::type
- It2;
- It2 it2 = fusion::prior(it1);
- typedef typename reverse_fold_lvalue_state<State,It0,F>::type State1;
- State1 const state1=f(state,fusion::deref(it0));
- typedef typename reverse_fold_lvalue_state<State1,It1,F>::type State2;
- State2 const state2=f(state1,fusion::deref(it1));
- return f(state2,fusion::deref(it2));
+ return call_1(
+ f(state,fusion::deref(it0)),
+ fusion::prior(it0),
+ f);
}
};
template<typename Result>
struct unrolled_reverse_fold<Result,2>
{
+ template<typename State1, typename It1, typename F>
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
+ static Result
+ call_1(State1 const& state1,It1 const& it1,F& f)
+ {
+ return f(state1,fusion::deref(it1));
+ }
template<typename State, typename It0, typename F>
- BOOST_FUSION_GPU_ENABLED
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result
call(State const& state,It0 const& it0,F f)
{
- typedef typename reverse_fold_lvalue_state<State,It0,F>::type State1;
- State1 const state1=f(state,fusion::deref(it0));
- return f(
- state1,
- fusion::deref( fusion::prior(it0)));
+ return call_1(
+ f(state,fusion::deref(it0)),
+ fusion::prior(it0),
+ f);
}
};
template<typename Result>
struct unrolled_reverse_fold<Result,1>
{
template<typename State, typename It0, typename F>
- BOOST_FUSION_GPU_ENABLED
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result
call(State const& state,It0 const& it0,F f)
{
@@ -118,7 +134,7 @@ namespace boost { namespace fusion
struct unrolled_reverse_fold<Result,0>
{
template<typename State, typename It0, typename F>
- BOOST_FUSION_GPU_ENABLED
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result
call(State const& state,It0 const&, F)
{
@@ -256,7 +272,7 @@ namespace boost { namespace fusion
{
typedef typename
result_of_unrolled_reverse_fold<
- typename boost::result_of<
+ typename fusion::detail::result_of_with_decltype<
F(
StateRef,
typename fusion::result_of::deref< It0 const>::type
@@ -281,7 +297,7 @@ namespace boost { namespace fusion
, SeqSize
>::type
type;
- BOOST_FUSION_GPU_ENABLED
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type
call(StateRef state, Seq& seq, F f)
{
@@ -301,7 +317,7 @@ namespace boost { namespace fusion
struct reverse_fold_impl<0,StateRef,Seq,F>
{
typedef StateRef type;
- BOOST_FUSION_GPU_ENABLED
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static StateRef
call(StateRef state, Seq&, F)
{
@@ -333,7 +349,7 @@ namespace boost { namespace fusion
{};
}
template<typename Seq, typename State, typename F>
- BOOST_FUSION_GPU_ENABLED
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::reverse_fold<
Seq
, State const
@@ -347,7 +363,7 @@ namespace boost { namespace fusion
f);
}
template<typename Seq, typename State, typename F>
- BOOST_FUSION_GPU_ENABLED
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::reverse_fold<
Seq const
, State const
@@ -361,7 +377,7 @@ namespace boost { namespace fusion
f);
}
template<typename Seq, typename State, typename F>
- BOOST_FUSION_GPU_ENABLED
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::reverse_fold<
Seq
, State const
@@ -375,7 +391,7 @@ namespace boost { namespace fusion
f);
}
template<typename Seq, typename State, typename F>
- BOOST_FUSION_GPU_ENABLED
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::reverse_fold<
Seq const
, State const