15 #ifndef PAAL_FUSION_ALGORITHMS_HPP
16 #define PAAL_FUSION_ALGORITHMS_HPP
20 #include <boost/fusion/include/begin.hpp>
25 namespace data_structures {
33 template <
typename Functor,
typename IterEnd,
34 typename AccumulatorFunctor,
typename AccumulatorData>
35 typename std::result_of<AccumulatorFunctor(AccumulatorData)>::type
36 operator()(Functor, AccumulatorFunctor accumulatorFunctor,
37 AccumulatorData accumulatorData, IterEnd, IterEnd)
const {
38 return accumulatorFunctor(accumulatorData);
41 template <
typename Functor,
typename IterBegin,
typename IterEnd,
42 typename AccumulatorFunctor,
typename AccumulatorData,
47 typename Dummy =
typename std::enable_if<
48 !std::is_same<IterEnd, IterBegin>::value>::type>
49 auto operator()(Functor f, AccumulatorFunctor accumulatorFunctor,
50 AccumulatorData accumulatorData, IterBegin begin,
52 ->
typename std::result_of<Functor(
53 typename boost::fusion::result_of::deref<IterBegin>::type,
54 AccumulatorFunctor, AccumulatorData,
57 decltype(std::move(std::bind(
58 *
this, f, std::placeholders::_1, std::placeholders::_2,
59 boost::fusion::next(begin), end))))>::type {
60 auto continuation = std::bind(*
this, f, std::placeholders::_1,
61 std::placeholders::_2,
62 boost::fusion::next(begin), end);
64 return f(*begin, accumulatorFunctor, accumulatorData, continuation);
83 template <
typename Functor,
typename AccumulatorFunctor,
typename AccumulatorData,
typename Sequence>
84 auto operator()(Functor f, AccumulatorFunctor accumulatorFunctor,
85 AccumulatorData accumulatorData, Sequence &seq)
const{
87 (f, accumulatorFunctor, accumulatorData, boost::fusion::begin(seq),
88 boost::fusion::end(seq));
103 template <
typename Predicate,
typename IterEnd>
104 bool satisfy(Predicate, IterEnd, IterEnd)
const {
120 template <
typename Predicate,
typename IterBegin,
typename IterEnd>
121 bool satisfy(Predicate pred, IterBegin begin, IterEnd end)
const {
125 return satisfy(pred, boost::fusion::next(begin), end);
139 template <
typename Predicate,
typename Seq>
141 return satisfy(pred, boost::fusion::begin(seq),
142 boost::fusion::end(seq));
149 #endif // PAAL_FUSION_ALGORITHMS_HPP
bool operator()(Predicate pred, Seq &seq) const
operator()
class for polymorphic join on boost fusion sequence
auto operator()(Functor f, AccumulatorFunctor accumulatorFunctor, AccumulatorData accumulatorData, Sequence &seq) const
operator()