Merge pull request #23 from Flast/bugfix/cxx14-constexpr

Improve constexpr supports
This commit is contained in:
Joel de Guzman
2014-10-21 22:55:54 +08:00
10 changed files with 381 additions and 302 deletions

View File

@ -57,39 +57,11 @@ namespace boost { namespace fusion
template<typename Result,int N> template<typename Result,int N>
struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME)
{ {
template<typename State, typename It0, typename F> template<typename State3, typename It3, typename F>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result 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::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION<
It0 const
>::type
It1;
It1 it1 = fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0);
typedef typename
result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION<
It1
>::type
It2;
It2 it2 = fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it1);
typedef typename
result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION<
It2
>::type
It3;
It3 it3 = fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it2);
typedef typename BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)<State,It0,F>::type State1;
State1 const state1=f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0));
typedef typename BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)<State1,It1,F>::type State2;
State2 const state2=f(state1,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it1));
typedef typename BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)<State2,It2,F>::type State3;
State3 const state3=f(state2,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it2));
return BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME)< return BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME)<
Result Result
, N-4 , N-4
@ -98,54 +70,95 @@ namespace boost { namespace fusion
fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it3), fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it3),
f); f);
} }
};
template<typename Result> template<typename State2, typename It2, typename F>
struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME)<Result,3> BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
{ static Result
call_2(State2 const& state2,It2 const& it2,F& f)
{
return call_3(
f(state2,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it2)),
fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(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,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it1)),
fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it1),
f);
}
template<typename State, typename It0, typename F> template<typename State, typename It0, typename F>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result static Result
call(State const& state,It0 const& it0,F f) call(State const& state,It0 const& it0,F f)
{ {
typedef typename return call_1(
result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)),
It0 const fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0),
>::type f);
It1; }
It1 it1 = fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0); };
typedef typename
result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION<
It1
>::type
It2;
It2 it2 = fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it1);
typedef typename BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)<State,It0,F>::type State1;
State1 const state1=f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0));
typedef typename BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)<State1,It1,F>::type State2;
State2 const state2=f(state1,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it1));
template<typename Result>
struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME)<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,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it2)); return f(state2,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(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,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it1)),
fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(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,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)),
fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0),
f);
}
}; };
template<typename Result> template<typename Result>
struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME)<Result,2> struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME)<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,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it1));
}
template<typename State, typename It0, typename F> template<typename State, typename It0, typename F>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result static Result
call(State const& state,It0 const& it0,F f) call(State const& state,It0 const& it0,F f)
{ {
typedef typename BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)<State,It0,F>::type State1; return call_1(
State1 const state1=f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)); f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)),
fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0),
return f( f);
state1,
BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(
fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0)));
} }
}; };

View File

@ -23,35 +23,11 @@ namespace boost { namespace fusion
template<typename Result,int N> template<typename Result,int N>
struct unrolled_fold struct unrolled_fold
{ {
template<typename State, typename It0, typename F> template<typename State3, typename It3, typename F>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result 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::next<
It0 const
>::type
It1;
It1 it1 = fusion::next(it0);
typedef typename
result_of::next<
It1
>::type
It2;
It2 it2 = fusion::next(it1);
typedef typename
result_of::next<
It2
>::type
It3;
It3 it3 = fusion::next(it2);
typedef typename fold_lvalue_state<State,It0,F>::type State1;
State1 const state1=f(state,fusion::deref(it0));
typedef typename fold_lvalue_state<State1,It1,F>::type State2;
State2 const state2=f(state1,fusion::deref(it1));
typedef typename fold_lvalue_state<State2,It2,F>::type State3;
State3 const state3=f(state2,fusion::deref(it2));
return unrolled_fold< return unrolled_fold<
Result Result
, N-4 , N-4
@ -60,47 +36,87 @@ namespace boost { namespace fusion
fusion::next(it3), fusion::next(it3),
f); f);
} }
}; template<typename State2, typename It2, typename F>
template<typename Result> BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
struct unrolled_fold<Result,3> static Result
{ call_2(State2 const& state2,It2 const& it2,F& f)
{
return call_3(
f(state2,fusion::deref(it2)),
fusion::next(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::next(it1),
f);
}
template<typename State, typename It0, typename F> template<typename State, typename It0, typename F>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result static Result
call(State const& state,It0 const& it0,F f) call(State const& state,It0 const& it0,F f)
{ {
typedef typename return call_1(
result_of::next< f(state,fusion::deref(it0)),
It0 const fusion::next(it0),
>::type f);
It1; }
It1 it1 = fusion::next(it0); };
typedef typename template<typename Result>
result_of::next< struct unrolled_fold<Result,3>
It1 {
>::type template<typename State2, typename It2, typename F>
It2; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
It2 it2 = fusion::next(it1); static Result
typedef typename fold_lvalue_state<State,It0,F>::type State1; call_2(State2 const& state2,It2 const& it2,F& f)
State1 const state1=f(state,fusion::deref(it0)); {
typedef typename fold_lvalue_state<State1,It1,F>::type State2;
State2 const state2=f(state1,fusion::deref(it1));
return f(state2,fusion::deref(it2)); 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::next(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::next(it0),
f);
}
}; };
template<typename Result> template<typename Result>
struct unrolled_fold<Result,2> struct unrolled_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> template<typename State, typename It0, typename F>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result static Result
call(State const& state,It0 const& it0,F f) call(State const& state,It0 const& it0,F f)
{ {
typedef typename fold_lvalue_state<State,It0,F>::type State1; return call_1(
State1 const state1=f(state,fusion::deref(it0)); f(state,fusion::deref(it0)),
return f( fusion::next(it0),
state1, f);
fusion::deref( fusion::next(it0)));
} }
}; };
template<typename Result> template<typename Result>

View File

@ -22,35 +22,11 @@ namespace boost { namespace fusion
template<typename Result,int N> template<typename Result,int N>
struct unrolled_iter_fold struct unrolled_iter_fold
{ {
template<typename State, typename It0, typename F> template<typename State3, typename It3, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result 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::next<
It0 const
>::type
It1;
It1 it1 = fusion::next(it0);
typedef typename
result_of::next<
It1
>::type
It2;
It2 it2 = fusion::next(it1);
typedef typename
result_of::next<
It2
>::type
It3;
It3 it3 = fusion::next(it2);
typedef typename iter_fold_lvalue_state<State,It0,F>::type State1;
State1 const state1=f(state,it0);
typedef typename iter_fold_lvalue_state<State1,It1,F>::type State2;
State2 const state2=f(state1,it1);
typedef typename iter_fold_lvalue_state<State2,It2,F>::type State3;
State3 const state3=f(state2,it2);
return unrolled_iter_fold< return unrolled_iter_fold<
Result Result
, N-4 , N-4
@ -59,54 +35,94 @@ namespace boost { namespace fusion
fusion::next(it3), fusion::next(it3),
f); 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,it2),
fusion::next(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,it1),
fusion::next(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,it0),
fusion::next(it0),
f);
}
}; };
template<typename Result> template<typename Result>
struct unrolled_iter_fold<Result,3> struct unrolled_iter_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,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,it1),
fusion::next(it1),
f);
}
template<typename State, typename It0, typename F> template<typename State, typename It0, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result static Result
call(State const& state,It0 const& it0,F f) call(State const& state,It0 const& it0,F f)
{ {
typedef typename return call_1(
result_of::next< f(state,it0),
It0 const fusion::next(it0),
>::type f);
It1;
It1 it1 = fusion::next(it0);
typedef typename
result_of::next<
It1
>::type
It2;
It2 it2 = fusion::next(it1);
typedef typename iter_fold_lvalue_state<State,It0,F>::type State1;
State1 const state1=f(state,it0);
typedef typename iter_fold_lvalue_state<State1,It1,F>::type State2;
State2 const state2=f(state1,it1);
return f(state2,it2);
} }
}; };
template<typename Result> template<typename Result>
struct unrolled_iter_fold<Result,2> struct unrolled_iter_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,it1);
}
template<typename State, typename It0, typename F> template<typename State, typename It0, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result static Result
call(State const& state,It0 const& it0,F f) call(State const& state,It0 const& it0,F f)
{ {
typedef typename iter_fold_lvalue_state<State,It0,F>::type State1; return call_1(
State1 const state1=f(state,it0); f(state,it0),
return f( fusion::next(it0),
state1, f);
fusion::next(it0));
} }
}; };
template<typename Result> template<typename Result>
struct unrolled_iter_fold<Result,1> struct unrolled_iter_fold<Result,1>
{ {
template<typename State, typename It0, typename F> template<typename State, typename It0, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result static Result
call(State const& state,It0 const& it0,F f) call(State const& state,It0 const& it0,F f)
{ {
@ -118,7 +134,7 @@ namespace boost { namespace fusion
struct unrolled_iter_fold<Result,0> struct unrolled_iter_fold<Result,0>
{ {
template<typename State, typename It0, typename F> template<typename State, typename It0, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result static Result
call(State const& state,It0 const&, F) call(State const& state,It0 const&, F)
{ {
@ -281,7 +297,7 @@ namespace boost { namespace fusion
, SeqSize , SeqSize
>::type >::type
type; type;
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type static type
call(StateRef state, Seq& seq, F f) call(StateRef state, Seq& seq, F f)
{ {
@ -301,7 +317,7 @@ namespace boost { namespace fusion
struct iter_fold_impl<0,StateRef,Seq,F> struct iter_fold_impl<0,StateRef,Seq,F>
{ {
typedef StateRef type; typedef StateRef type;
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static StateRef static StateRef
call(StateRef state, Seq&, F) call(StateRef state, Seq&, F)
{ {
@ -333,7 +349,7 @@ namespace boost { namespace fusion
{}; {};
} }
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::iter_fold< inline typename result_of::iter_fold<
Seq Seq
, State const , State const
@ -347,7 +363,7 @@ namespace boost { namespace fusion
f); f);
} }
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::iter_fold< inline typename result_of::iter_fold<
Seq const Seq const
, State const , State const
@ -361,7 +377,7 @@ namespace boost { namespace fusion
f); f);
} }
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::iter_fold< inline typename result_of::iter_fold<
Seq Seq
, State const , State const
@ -375,7 +391,7 @@ namespace boost { namespace fusion
f); f);
} }
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::iter_fold< inline typename result_of::iter_fold<
Seq const Seq const
, State const , State const

View File

@ -22,35 +22,11 @@ namespace boost { namespace fusion
template<typename Result,int N> template<typename Result,int N>
struct unrolled_reverse_fold struct unrolled_reverse_fold
{ {
template<typename State, typename It0, typename F> template<typename State3, typename It3, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result 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< return unrolled_reverse_fold<
Result Result
, N-4 , N-4
@ -59,54 +35,94 @@ namespace boost { namespace fusion
fusion::prior(it3), fusion::prior(it3),
f); 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> template<typename Result>
struct unrolled_reverse_fold<Result,3> 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> template<typename State, typename It0, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result static Result
call(State const& state,It0 const& it0,F f) call(State const& state,It0 const& it0,F f)
{ {
typedef typename return call_1(
result_of::prior< f(state,fusion::deref(it0)),
It0 const fusion::prior(it0),
>::type f);
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));
} }
}; };
template<typename Result> template<typename Result>
struct unrolled_reverse_fold<Result,2> 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> template<typename State, typename It0, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result static Result
call(State const& state,It0 const& it0,F f) call(State const& state,It0 const& it0,F f)
{ {
typedef typename reverse_fold_lvalue_state<State,It0,F>::type State1; return call_1(
State1 const state1=f(state,fusion::deref(it0)); f(state,fusion::deref(it0)),
return f( fusion::prior(it0),
state1, f);
fusion::deref( fusion::prior(it0)));
} }
}; };
template<typename Result> template<typename Result>
struct unrolled_reverse_fold<Result,1> struct unrolled_reverse_fold<Result,1>
{ {
template<typename State, typename It0, typename F> template<typename State, typename It0, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result static Result
call(State const& state,It0 const& it0,F f) call(State const& state,It0 const& it0,F f)
{ {
@ -118,7 +134,7 @@ namespace boost { namespace fusion
struct unrolled_reverse_fold<Result,0> struct unrolled_reverse_fold<Result,0>
{ {
template<typename State, typename It0, typename F> template<typename State, typename It0, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result static Result
call(State const& state,It0 const&, F) call(State const& state,It0 const&, F)
{ {
@ -281,7 +297,7 @@ namespace boost { namespace fusion
, SeqSize , SeqSize
>::type >::type
type; type;
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type static type
call(StateRef state, Seq& seq, F f) call(StateRef state, Seq& seq, F f)
{ {
@ -301,7 +317,7 @@ namespace boost { namespace fusion
struct reverse_fold_impl<0,StateRef,Seq,F> struct reverse_fold_impl<0,StateRef,Seq,F>
{ {
typedef StateRef type; typedef StateRef type;
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static StateRef static StateRef
call(StateRef state, Seq&, F) call(StateRef state, Seq&, F)
{ {
@ -333,7 +349,7 @@ namespace boost { namespace fusion
{}; {};
} }
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::reverse_fold< inline typename result_of::reverse_fold<
Seq Seq
, State const , State const
@ -347,7 +363,7 @@ namespace boost { namespace fusion
f); f);
} }
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::reverse_fold< inline typename result_of::reverse_fold<
Seq const Seq const
, State const , State const
@ -361,7 +377,7 @@ namespace boost { namespace fusion
f); f);
} }
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::reverse_fold< inline typename result_of::reverse_fold<
Seq Seq
, State const , State const
@ -375,7 +391,7 @@ namespace boost { namespace fusion
f); f);
} }
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::reverse_fold< inline typename result_of::reverse_fold<
Seq const Seq const
, State const , State const

View File

@ -22,35 +22,11 @@ namespace boost { namespace fusion
template<typename Result,int N> template<typename Result,int N>
struct unrolled_reverse_iter_fold struct unrolled_reverse_iter_fold
{ {
template<typename State, typename It0, typename F> template<typename State3, typename It3, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result 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_iter_fold_lvalue_state<State,It0,F>::type State1;
State1 const state1=f(state,it0);
typedef typename reverse_iter_fold_lvalue_state<State1,It1,F>::type State2;
State2 const state2=f(state1,it1);
typedef typename reverse_iter_fold_lvalue_state<State2,It2,F>::type State3;
State3 const state3=f(state2,it2);
return unrolled_reverse_iter_fold< return unrolled_reverse_iter_fold<
Result Result
, N-4 , N-4
@ -59,54 +35,94 @@ namespace boost { namespace fusion
fusion::prior(it3), fusion::prior(it3),
f); 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,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,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,it0),
fusion::prior(it0),
f);
}
}; };
template<typename Result> template<typename Result>
struct unrolled_reverse_iter_fold<Result,3> struct unrolled_reverse_iter_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,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,it1),
fusion::prior(it1),
f);
}
template<typename State, typename It0, typename F> template<typename State, typename It0, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result static Result
call(State const& state,It0 const& it0,F f) call(State const& state,It0 const& it0,F f)
{ {
typedef typename return call_1(
result_of::prior< f(state,it0),
It0 const fusion::prior(it0),
>::type f);
It1;
It1 it1 = fusion::prior(it0);
typedef typename
result_of::prior<
It1
>::type
It2;
It2 it2 = fusion::prior(it1);
typedef typename reverse_iter_fold_lvalue_state<State,It0,F>::type State1;
State1 const state1=f(state,it0);
typedef typename reverse_iter_fold_lvalue_state<State1,It1,F>::type State2;
State2 const state2=f(state1,it1);
return f(state2,it2);
} }
}; };
template<typename Result> template<typename Result>
struct unrolled_reverse_iter_fold<Result,2> struct unrolled_reverse_iter_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,it1);
}
template<typename State, typename It0, typename F> template<typename State, typename It0, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result static Result
call(State const& state,It0 const& it0,F f) call(State const& state,It0 const& it0,F f)
{ {
typedef typename reverse_iter_fold_lvalue_state<State,It0,F>::type State1; return call_1(
State1 const state1=f(state,it0); f(state,it0),
return f( fusion::prior(it0),
state1, f);
fusion::prior(it0));
} }
}; };
template<typename Result> template<typename Result>
struct unrolled_reverse_iter_fold<Result,1> struct unrolled_reverse_iter_fold<Result,1>
{ {
template<typename State, typename It0, typename F> template<typename State, typename It0, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result static Result
call(State const& state,It0 const& it0,F f) call(State const& state,It0 const& it0,F f)
{ {
@ -118,7 +134,7 @@ namespace boost { namespace fusion
struct unrolled_reverse_iter_fold<Result,0> struct unrolled_reverse_iter_fold<Result,0>
{ {
template<typename State, typename It0, typename F> template<typename State, typename It0, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static Result static Result
call(State const& state,It0 const&, F) call(State const& state,It0 const&, F)
{ {
@ -281,7 +297,7 @@ namespace boost { namespace fusion
, SeqSize , SeqSize
>::type >::type
type; type;
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static type static type
call(StateRef state, Seq& seq, F f) call(StateRef state, Seq& seq, F f)
{ {
@ -301,7 +317,7 @@ namespace boost { namespace fusion
struct reverse_iter_fold_impl<0,StateRef,Seq,F> struct reverse_iter_fold_impl<0,StateRef,Seq,F>
{ {
typedef StateRef type; typedef StateRef type;
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static StateRef static StateRef
call(StateRef state, Seq&, F) call(StateRef state, Seq&, F)
{ {
@ -333,7 +349,7 @@ namespace boost { namespace fusion
{}; {};
} }
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::reverse_iter_fold< inline typename result_of::reverse_iter_fold<
Seq Seq
, State const , State const
@ -347,7 +363,7 @@ namespace boost { namespace fusion
f); f);
} }
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::reverse_iter_fold< inline typename result_of::reverse_iter_fold<
Seq const Seq const
, State const , State const
@ -361,7 +377,7 @@ namespace boost { namespace fusion
f); f);
} }
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::reverse_iter_fold< inline typename result_of::reverse_iter_fold<
Seq Seq
, State const , State const
@ -375,7 +391,7 @@ namespace boost { namespace fusion
f); f);
} }
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::reverse_iter_fold< inline typename result_of::reverse_iter_fold<
Seq const Seq const
, State const , State const

View File

@ -17,7 +17,7 @@ namespace boost { namespace fusion
} }
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
typename result_of::iter_fold< typename result_of::iter_fold<
Seq Seq
, State const , State const
@ -26,7 +26,7 @@ namespace boost { namespace fusion
iter_fold(Seq& seq, State const& state, F f); iter_fold(Seq& seq, State const& state, F f);
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
typename result_of::iter_fold< typename result_of::iter_fold<
Seq const Seq const
, State const , State const
@ -35,7 +35,7 @@ namespace boost { namespace fusion
iter_fold(Seq const& seq, State const& state, F f); iter_fold(Seq const& seq, State const& state, F f);
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
typename result_of::iter_fold< typename result_of::iter_fold<
Seq Seq
, State const , State const
@ -44,7 +44,7 @@ namespace boost { namespace fusion
iter_fold(Seq& seq, State& state, F f); iter_fold(Seq& seq, State& state, F f);
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
typename result_of::iter_fold< typename result_of::iter_fold<
Seq const Seq const
, State const , State const

View File

@ -17,7 +17,7 @@ namespace boost { namespace fusion
} }
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
typename result_of::reverse_fold< typename result_of::reverse_fold<
Seq Seq
, State const , State const
@ -26,7 +26,7 @@ namespace boost { namespace fusion
reverse_fold(Seq& seq, State const& state, F f); reverse_fold(Seq& seq, State const& state, F f);
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
typename result_of::reverse_fold< typename result_of::reverse_fold<
Seq const Seq const
, State const , State const
@ -35,7 +35,7 @@ namespace boost { namespace fusion
reverse_fold(Seq const& seq, State const& state, F f); reverse_fold(Seq const& seq, State const& state, F f);
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
typename result_of::reverse_fold< typename result_of::reverse_fold<
Seq Seq
, State const , State const
@ -44,7 +44,7 @@ namespace boost { namespace fusion
reverse_fold(Seq& seq, State& state, F f); reverse_fold(Seq& seq, State& state, F f);
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
typename result_of::reverse_fold< typename result_of::reverse_fold<
Seq const Seq const
, State const , State const

View File

@ -17,7 +17,7 @@ namespace boost { namespace fusion
} }
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
typename result_of::reverse_iter_fold< typename result_of::reverse_iter_fold<
Seq Seq
, State const , State const
@ -26,7 +26,7 @@ namespace boost { namespace fusion
reverse_iter_fold(Seq& seq, State const& state, F f); reverse_iter_fold(Seq& seq, State const& state, F f);
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
typename result_of::reverse_iter_fold< typename result_of::reverse_iter_fold<
Seq const Seq const
, State const , State const
@ -35,7 +35,7 @@ namespace boost { namespace fusion
reverse_iter_fold(Seq const& seq, State const& state, F f); reverse_iter_fold(Seq const& seq, State const& state, F f);
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
typename result_of::reverse_iter_fold< typename result_of::reverse_iter_fold<
Seq Seq
, State const , State const
@ -44,7 +44,7 @@ namespace boost { namespace fusion
reverse_iter_fold(Seq& seq, State& state, F f); reverse_iter_fold(Seq& seq, State& state, F f);
template<typename Seq, typename State, typename F> template<typename Seq, typename State, typename F>
BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
typename result_of::reverse_iter_fold< typename result_of::reverse_iter_fold<
Seq const Seq const
, State const , State const

View File

@ -40,7 +40,7 @@ namespace boost { namespace fusion {
}; };
template<typename Elem> template<typename Elem>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
void operator()(Elem const& e) const void operator()(Elem const& e) const
{ {
using std::swap; using std::swap;
@ -50,8 +50,8 @@ namespace boost { namespace fusion {
} }
template<typename Seq1, typename Seq2> template<typename Seq1, typename Seq2>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
typename enable_if<mpl::and_<traits::is_sequence<Seq1>, traits::is_sequence<Seq2> >, void>::type typename enable_if<mpl::and_<traits::is_sequence<Seq1>, traits::is_sequence<Seq2> >, void>::type
swap(Seq1& lhs, Seq2& rhs) swap(Seq1& lhs, Seq2& rhs)
{ {
typedef vector<Seq1&, Seq2&> references; typedef vector<Seq1&, Seq2&> references;

View File

@ -10,6 +10,8 @@
-D_M_IX86 -D_M_IX86
-NBOOST_STATIC_ASSERT -NBOOST_STATIC_ASSERT
-NBOOST_FORCEINLINE -NBOOST_FORCEINLINE
-NBOOST_CONSTEXPR
-NBOOST_CXX14_CONSTEXPR
-NBOOST_MPL_ASSERT -NBOOST_MPL_ASSERT
-NBOOST_MPL_ASSERT_MSG -NBOOST_MPL_ASSERT_MSG
-NBOOST_MPL_ASSERT_RELATION -NBOOST_MPL_ASSERT_RELATION