• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2008 Dan Marsden
3 
4     Use modification and distribution are subject to the Boost Software
5     License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6     http://www.boost.org/LICENSE_1_0.txt).
7 ==============================================================================*/
8 
9 #include <boost/fusion/include/transform.hpp>
10 #include <boost/fusion/include/for_each.hpp>
11 #include <boost/fusion/include/vector.hpp>
12 
13 namespace fusion = boost::fusion;
14 
15 namespace
16 {
17   template<int n, int batch>
18   struct distinct
19   {
20     static const int value = n;
21   };
22 
23   struct f
24   {
25     typedef int result_type;
26 
27     template<typename T>
operator ()__anon30eafb3b0111::f28     result_type operator()(T const& t) const
29     {
30       return T::value;
31     }
32   };
33 
34   struct touch
35   {
36     template<typename T>
operator ()__anon30eafb3b0111::touch37     void operator()(T const&) const
38     {}
39   };
40 
41   template<int batch>
test()42   void test()
43   {
44     fusion::vector<
45       distinct<0, batch>, distinct<1, batch>, distinct<2, batch>, distinct<3, batch>, distinct<4, batch>,
46       distinct<5, batch>, distinct<6, batch>, distinct<7, batch>, distinct<8, batch>, distinct<9, batch> > v;
47 
48     // We're testing transform really
49     // for_each call is to force iteration through the lazy
50     // transform, otherwise very little will happen.
51     fusion::for_each(fusion::transform(v, f()), touch());
52   }
53 }
54 
55 #include "./driver.hpp"
56