1 /*=============================================================================
2     Copyright (c) 2003 Joel de Guzman
3     Copyright (c) 2004 Peder Holt
4 
5     Use, modification and distribution is subject to the Boost Software
6     License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7     http://www.boost.org/LICENSE_1_0.txt)
8 ==============================================================================*/
9 #if !defined(FUSION_ALGORITHM_FOR_EACH_HPP)
10 #define FUSION_ALGORITHM_FOR_EACH_HPP
11 
12 #include <boost/spirit/fusion/sequence/begin.hpp>
13 #include <boost/spirit/fusion/sequence/end.hpp>
14 #include <boost/spirit/fusion/iterator/equal_to.hpp>
15 #include <boost/spirit/fusion/algorithm/detail/for_each.ipp>
16 
17 namespace boost { namespace fusion
18 {
19     namespace meta
20     {
21         template <typename Sequence, typename F>
22         struct for_each
23         {
24             typedef void type;
25         };
26     }
27 
28     namespace function
29     {
30         struct for_each
31         {
32             template <typename Sequence, typename F>
33             struct apply
34             {
35                 typedef void type;
36             };
37 
38             template <typename Sequence, typename F>
39             inline void
operator ()boost::fusion::function::for_each40             operator()(Sequence const& seq, F const& f) const
41             {
42                 detail::for_each(
43                         fusion::begin(seq)
44                       , fusion::end(seq)
45                       , f
46                       , meta::equal_to<
47                             BOOST_DEDUCED_TYPENAME meta::begin<Sequence>::type
48                           , BOOST_DEDUCED_TYPENAME meta::end<Sequence>::type>());
49             }
50 
51             template <typename Sequence, typename F>
52             inline void
operator ()boost::fusion::function::for_each53             operator()(Sequence& seq, F const& f) const
54             {
55                 detail::for_each(
56                         fusion::begin(seq)
57                       , fusion::end(seq)
58                       , f
59                       , meta::equal_to<
60                             BOOST_DEDUCED_TYPENAME meta::begin<Sequence>::type
61                           , BOOST_DEDUCED_TYPENAME meta::end<Sequence>::type>());
62             }
63         };
64     }
65 
66     function::for_each const for_each = function::for_each();
67 }}
68 
69 #endif
70 
71