Files
boost_fusion/include/boost/fusion/support/segmented_fold_until.hpp

61 lines
2.2 KiB
C++
Raw Normal View History

/*=============================================================================
Copyright (c) 2011 Eric Niebler
Distributed under 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(BOOST_FUSION_SEGMENTED_FOLD_UNTIL_HPP_INCLUDED)
#define BOOST_FUSION_SEGMENTED_FOLD_UNTIL_HPP_INCLUDED
2011-08-17 18:53:56 +00:00
#include <boost/fusion/support/detail/segmented_fold_until_impl.hpp>
#include <boost/fusion/view/iterator_range.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
2011-08-17 18:53:56 +00:00
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/container/list/cons.hpp>
namespace boost { namespace fusion
{
//auto segmented_fold_until(rng, state, fun)
//{
// return first(segmented_fold_until_impl(rng, state, nil, fun));
//}
namespace result_of
{
2011-08-17 18:53:56 +00:00
template <typename Range, typename State, typename Fun>
struct segmented_fold_until
{
typedef
detail::segmented_fold_until_impl<
Range,
result<State, continue_>,
fusion::nil,
Fun
>
impl;
typedef
typename impl::type::value_type
type;
};
}
2011-08-17 18:53:56 +00:00
template <typename Range, typename State, typename Fun>
typename result_of::segmented_fold_until<Range, State, Fun>::type
segmented_fold_until(Range& rng, State const& state, Fun const& fun)
{
typedef typename result_of::segmented_fold_until<Range, State, Fun>::impl impl;
return impl::call(rng, state, fusion::nil(), fun).value;
}
2011-08-17 18:53:56 +00:00
template <typename Range, typename State, typename Fun>
typename result_of::segmented_fold_until<Range const, State, Fun>::type
segmented_fold_until(Range const& rng, State const& state, Fun const& fun)
{
typedef typename result_of::segmented_fold_until<Range const, State, Fun>::impl impl;
return impl::call(rng, state, fusion::nil(), fun).value;
}
}}
#endif