1 // Copyright 2005 Daniel Wallin.
2 // Copyright 2005 Joel de Guzman.
3 // Copyright 2005 Dan Marsden.
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)
9 // Modeled after range_ex, Copyright 2004 Eric Niebler
11 #ifndef PHOENIX_ALGORITHM_ITERATION_HPP
12 #define PHOENIX_ALGORITHM_ITERATION_HPP
17 #include <boost/spirit/home/phoenix/stl/algorithm/detail/begin.hpp>
18 #include <boost/spirit/home/phoenix/stl/algorithm/detail/end.hpp>
20 #include <boost/spirit/home/phoenix/function/function.hpp>
22 namespace boost { namespace phoenix {
27 template<class R, class F>
33 template<class R, class F>
34 F operator()(R& r, F fn) const
36 return std::for_each(detail::begin_(r), detail::end_(r), fn);
42 template<class R, class I, class C = void>
48 template<class R, class I>
49 typename result<R,I>::type
50 operator()(R& r, I i) const
52 return std::accumulate(detail::begin_(r), detail::end_(r), i);
55 template<class R, class I, class C>
56 typename result<R,I,C>::type
57 operator()(R& r, I i, C c) const
59 return std::accumulate(detail::begin_(r), detail::end_(r), i, c);
64 function<impl::for_each> const for_each = impl::for_each();
65 function<impl::accumulate> const accumulate = impl::accumulate();