/*============================================================================= Copyright (c) 2003 Joel de Guzman Copyright (c) 2004 Peder Holt 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) ==============================================================================*/ #if !defined(FUSION_ALGORITHM_FOLD_HPP) #define FUSION_ALGORITHM_FOLD_HPP #include namespace boost { namespace fusion { namespace meta { template struct fold { typedef typename detail::static_fold< typename meta::begin::type , typename meta::end::type , State , F >::type type; }; } namespace function { struct fold { template struct apply : meta::fold {}; template inline typename apply::type operator()(Sequence const& seq, State const& state, F const& f) const { return detail::fold( fusion::begin(seq) , fusion::end(seq) , state , f , is_same< BOOST_DEDUCED_TYPENAME meta::begin::type , BOOST_DEDUCED_TYPENAME meta::end::type>() ); } template inline typename apply::type operator()(Sequence& seq, State const& state, F const& f) const { return detail::fold( fusion::begin(seq) , fusion::end(seq) , state , f , is_same< BOOST_DEDUCED_TYPENAME meta::begin::type , BOOST_DEDUCED_TYPENAME meta::end::type>() ); } }; } function::fold const fold = function::fold(); }} #endif