// Copyright 2005 Daniel Wallin. // Copyright 2005 Joel de Guzman. // Copyright 2005 Dan Marsden. // // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Modeled after range_ex, Copyright 2004 Eric Niebler #ifndef BOOST_PHOENIX_ALGORITHM_ITERATION_HPP #define BOOST_PHOENIX_ALGORITHM_ITERATION_HPP #include #include #include #include #include namespace boost { namespace phoenix { namespace impl { struct for_each { template struct result; template struct result : result {}; template struct result { typedef F type; }; template F const operator()(R& r, F const& fn) const { return std::for_each(detail::begin_(r), detail::end_(r), fn); } }; struct accumulate { template struct result; template struct result : result {}; template struct result { typedef I type; }; template struct result : result {}; template struct result { typedef I type; }; template I operator()(R& r, I i) const { return std::accumulate(detail::begin_(r), detail::end_(r), i); } template I operator()(R& r, I i, C c) const { return std::accumulate(detail::begin_(r), detail::end_(r), i, c); } }; } BOOST_PHOENIX_ADAPT_CALLABLE(for_each, impl::for_each, 2) BOOST_PHOENIX_ADAPT_CALLABLE(accumulate, impl::accumulate, 2) BOOST_PHOENIX_ADAPT_CALLABLE(accumulate, impl::accumulate, 3) }} #endif