All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Pages
fusion_algorithms_example.cpp
Go to the documentation of this file.
1 //=======================================================================
2 // Copyright (c)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //=======================================================================
17 #include "paal/utils/infinity.hpp"
18 
19 #include <boost/fusion/include/vector.hpp>
20 
21 #include <iostream>
22 
23 struct F {
24  template <class Num, class AccumulatorFunctor, class AccumulatorData,
25  class Continuation>
26  void operator()(Num num, AccumulatorFunctor accFunctor,
27  AccumulatorData accData, Continuation continuation) const
28  // TODO if we use auto -> decltype(accFunctor(accData)) here instead
29  // of void, the code does not compile on g++-4.8
30  {
31  if (accData < num) {
32  auto print = [](Num n) { std::cout << n << std::endl; };
33  return continuation(print, num);
34  } else {
35  return continuation(accFunctor, accData);
36  }
37  }
38 };
39 
40 int main() {
41  boost::fusion::vector<int, float, long long> v(12, 5.5f, 2ll);
42 
44  fold(F{}, [](paal::minus_infinity) {
45  std::cout << "Empty Collection" << std::endl;
46  },
48 }
class for polymorphic join on boost fusion sequence
detail::infinity< false > minus_infinity
detail
Definition: infinity.hpp:111
if the sign = true, class represents plus_infinity: object bigger than everything if the sign = false...
Definition: infinity.hpp:27