fusion::fold allows to take non-const lv-ref state properly.

This commit is contained in:
Kohei Takahashi
2015-09-08 15:14:27 +09:00
parent 1df7fc1dca
commit 76b7697ba5
11 changed files with 31 additions and 23 deletions

View File

@ -258,6 +258,22 @@ the first call) and [arg_desc] of `seq`.
typename result_of_name_macro<Sequence const, State const, F>::type name_macro( typename result_of_name_macro<Sequence const, State const, F>::type name_macro(
Sequence const& seq, State const& initial_state, F f); Sequence const& seq, State const& initial_state, F f);
template<
typename Sequence,
typename State,
typename F
>
typename result_of_name_macro<Sequence, State, F>::type name_macro(
Sequence& seq, State& initial_state, F f);
template<
typename Sequence,
typename State,
typename F
>
typename result_of_name_macro<Sequence const, State, F>::type name_macro(
Sequence const& seq, State& initial_state, F f);
[def seq_concept_macro [seq_concept]] [def seq_concept_macro [seq_concept]]
[def arg_type_id_macro [arg_type_id]] [def arg_type_id_macro [arg_type_id]]
[def arg_id_macro [arg_id]] [def arg_id_macro [arg_id]]

View File

@ -68,9 +68,7 @@ namespace boost { namespace fusion
, typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION<It>::type , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION<It>::type
, boost::result_of< , boost::result_of<
F( F(
typename add_reference<typename add_const< typename add_reference<typename State::type>::type,
typename State::type
>::type>::type,
BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It const) BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It const)
) )
> >
@ -108,9 +106,7 @@ namespace boost { namespace fusion
typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION<It>::type typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION<It>::type
, boost::result_of< , boost::result_of<
F( F(
typename add_reference<typename add_const< typename add_reference<typename State::type>::type,
typename State::type
>::type>::type,
BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It const) BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It const)
) )
> >
@ -136,7 +132,7 @@ namespace boost { namespace fusion
, BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM( , BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM(
typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION<Seq>::type typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION<Seq>::type
) )
, add_reference<typename add_const<State>::type> , add_reference<State>
, F , F
> >
{}; {};
@ -150,7 +146,7 @@ namespace boost { namespace fusion
BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM( BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM(
typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION<Seq>::type typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION<Seq>::type
) )
, add_reference<typename add_const<State>::type> , add_reference<State>
, F , F
>( >(
typename result_of::size<Seq>::type() typename result_of::size<Seq>::type()
@ -199,7 +195,7 @@ namespace boost { namespace fusion
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::BOOST_FUSION_FOLD_NAME< inline typename result_of::BOOST_FUSION_FOLD_NAME<
Seq Seq
, State const , State
, F , F
>::type >::type
BOOST_FUSION_FOLD_NAME(Seq& seq, State& state, F f) BOOST_FUSION_FOLD_NAME(Seq& seq, State& state, F f)
@ -211,7 +207,7 @@ namespace boost { namespace fusion
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::BOOST_FUSION_FOLD_NAME< inline typename result_of::BOOST_FUSION_FOLD_NAME<
Seq const Seq const
, State const , State
, F , F
>::type >::type
BOOST_FUSION_FOLD_NAME(Seq const& seq, State& state, F f) BOOST_FUSION_FOLD_NAME(Seq const& seq, State& state, F f)

View File

@ -22,7 +22,6 @@
#include <boost/fusion/iterator/next.hpp> #include <boost/fusion/iterator/next.hpp>
#include <boost/utility/result_of.hpp> #include <boost/utility/result_of.hpp>
#include <boost/core/enable_if.hpp> #include <boost/core/enable_if.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/add_reference.hpp> #include <boost/type_traits/add_reference.hpp>
#if !defined(BOOST_FUSION_DONT_USE_PREPROCESSED_FILES) #if !defined(BOOST_FUSION_DONT_USE_PREPROCESSED_FILES)

View File

@ -38,7 +38,7 @@ namespace boost { namespace fusion
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::fold< inline typename result_of::fold<
Seq Seq
, State const , State
, F , F
>::type >::type
fold(Seq& seq, State& state, F f); fold(Seq& seq, State& state, F f);
@ -47,7 +47,7 @@ namespace boost { namespace fusion
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
inline typename result_of::fold< inline typename result_of::fold<
Seq const Seq const
, State const , State
, F , F
>::type >::type
fold(Seq const& seq, State& state, F f); fold(Seq const& seq, State& state, F f);

View File

@ -22,7 +22,6 @@
#include <boost/fusion/iterator/next.hpp> #include <boost/fusion/iterator/next.hpp>
#include <boost/utility/result_of.hpp> #include <boost/utility/result_of.hpp>
#include <boost/core/enable_if.hpp> #include <boost/core/enable_if.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/add_reference.hpp> #include <boost/type_traits/add_reference.hpp>
#define BOOST_FUSION_ITER_FOLD #define BOOST_FUSION_ITER_FOLD

View File

@ -38,7 +38,7 @@ namespace boost { namespace fusion
BOOST_CONSTEXPR 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
, F , F
>::type >::type
iter_fold(Seq& seq, State& state, F f); iter_fold(Seq& seq, State& state, F f);
@ -47,7 +47,7 @@ namespace boost { namespace fusion
BOOST_CONSTEXPR 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
, F , F
>::type >::type
iter_fold(Seq const& seq, State& state, F f); iter_fold(Seq const& seq, State& state, F f);

View File

@ -22,7 +22,6 @@
#include <boost/fusion/iterator/prior.hpp> #include <boost/fusion/iterator/prior.hpp>
#include <boost/utility/result_of.hpp> #include <boost/utility/result_of.hpp>
#include <boost/core/enable_if.hpp> #include <boost/core/enable_if.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/add_reference.hpp> #include <boost/type_traits/add_reference.hpp>
#define BOOST_FUSION_REVERSE_FOLD #define BOOST_FUSION_REVERSE_FOLD

View File

@ -38,7 +38,7 @@ namespace boost { namespace fusion
BOOST_CONSTEXPR 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
, F , F
>::type >::type
reverse_fold(Seq& seq, State& state, F f); reverse_fold(Seq& seq, State& state, F f);
@ -47,7 +47,7 @@ namespace boost { namespace fusion
BOOST_CONSTEXPR 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
, F , F
>::type >::type
reverse_fold(Seq const& seq, State& state, F f); reverse_fold(Seq const& seq, State& state, F f);

View File

@ -21,7 +21,6 @@
#include <boost/fusion/iterator/prior.hpp> #include <boost/fusion/iterator/prior.hpp>
#include <boost/utility/result_of.hpp> #include <boost/utility/result_of.hpp>
#include <boost/core/enable_if.hpp> #include <boost/core/enable_if.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/add_reference.hpp> #include <boost/type_traits/add_reference.hpp>
#define BOOST_FUSION_REVERSE_FOLD #define BOOST_FUSION_REVERSE_FOLD

View File

@ -38,7 +38,7 @@ namespace boost { namespace fusion
BOOST_CONSTEXPR 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
, F , F
>::type >::type
reverse_iter_fold(Seq& seq, State& state, F f); reverse_iter_fold(Seq& seq, State& state, F f);
@ -47,7 +47,7 @@ namespace boost { namespace fusion
BOOST_CONSTEXPR 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
, F , F
>::type >::type
reverse_iter_fold(Seq const& seq, State& state, F f); reverse_iter_fold(Seq const& seq, State& state, F f);

View File

@ -189,7 +189,7 @@ struct fold_test_n
>::type >::type
, typename mpl::if_c< , typename mpl::if_c<
!n !n
, mpl::vector<mpl::int_<1>, mpl::int_<0> > const& , mpl::vector<mpl::int_<1>, mpl::int_<0> >&
, mpl::vector<mpl::int_<n+1>, mpl::int_<squares_sum> > , mpl::vector<mpl::int_<n+1>, mpl::int_<squares_sum> >
>::type >::type
> >