fold.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*=============================================================================
  2. Copyright (c) 2008 Dan Marsden
  3. Use modification and distribution are subject to the Boost Software
  4. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt).
  6. ==============================================================================*/
  7. #include <boost/fusion/include/fold.hpp>
  8. #include <boost/fusion/include/vector.hpp>
  9. namespace fusion = boost::fusion;
  10. namespace
  11. {
  12. template<int n, int batch>
  13. struct distinct
  14. {};
  15. struct f
  16. {
  17. typedef int result_type;
  18. template<int n, int batch>
  19. int operator()(int state, distinct<n, batch> const& d) const
  20. {
  21. return state + n;
  22. }
  23. };
  24. template<int batch>
  25. void test()
  26. {
  27. fusion::vector<
  28. distinct<0, batch>, distinct<1, batch>, distinct<2, batch>, distinct<3, batch>, distinct<4, batch>,
  29. distinct<5, batch>, distinct<6, batch>, distinct<7, batch>, distinct<8, batch>, distinct<9, batch> > v;
  30. fusion::fold(v, 0, f());
  31. }
  32. }
  33. #include "./driver.hpp"