make find and find_if algorithms segment-aware, stylistic consistency tweaks

[SVN r73892]
This commit is contained in:
Eric Niebler
2011-08-18 17:12:05 +00:00
parent 528ad04fdb
commit 9dd14c435e
27 changed files with 623 additions and 539 deletions

View File

@ -12,24 +12,24 @@
namespace boost { namespace fusion { namespace detail
{
//auto segmented_begin( rng )
//auto segmented_begin( seq )
//{
// return make_segmented_iterator( segmented_begin_impl( rng, nil ) );
// return make_segmented_iterator( segmented_begin_impl( seq, nil ) );
//}
template<typename Range>
template <typename Sequence>
struct segmented_begin
{
typedef
segmented_iterator<
typename segmented_begin_impl<Range, fusion::nil>::type
typename segmented_begin_impl<Sequence, fusion::nil>::type
>
type;
static type call(Range & rng)
static type call(Sequence& seq)
{
return type(
segmented_begin_impl<Range, fusion::nil>::call(rng, fusion::nil()));
segmented_begin_impl<Sequence, fusion::nil>::call(seq, fusion::nil()));
}
};

View File

@ -27,80 +27,80 @@ namespace boost { namespace fusion { namespace detail
template <typename Sig>
struct result;
template <typename This, typename Range, typename State, typename Context>
struct result<This(Range&, State&, Context&)>
template <typename This, typename Sequence, typename State, typename Context>
struct result<This(Sequence&, State&, Context&)>
{
typedef
iterator_range<
typename fusion::result_of::begin<Range>::type,
typename fusion::result_of::end<Range>::type
typename fusion::result_of::begin<Sequence>::type
, typename fusion::result_of::end<Sequence>::type
>
range_type;
typedef
fusion::result<
cons<range_type, typename remove_const<Context>::type>,
fusion::break_
cons<range_type, typename remove_const<Context>::type>
, fusion::break_
>
type;
};
template <typename Range, typename State, typename Context>
typename result<segmented_begin_fun(Range&, State const&, Context const&)>::type
operator()(Range& rng, State const&, Context const& context) const
template <typename Sequence, typename State, typename Context>
typename result<segmented_begin_fun(Sequence&, State const&, Context const&)>::type
operator()(Sequence& seq, State const&, Context const& context) const
{
typedef
iterator_range<
typename fusion::result_of::begin<Range>::type,
typename fusion::result_of::end<Range>::type
typename fusion::result_of::begin<Sequence>::type
, typename fusion::result_of::end<Sequence>::type
>
range_type;
return cons<range_type, Context>(range_type(fusion::begin(rng), fusion::end(rng)), context);
return cons<range_type, Context>(range_type(fusion::begin(seq), fusion::end(seq)), context);
}
};
template <typename Range, typename Stack, bool IsSegmented = traits::is_segmented<Range>::type::value>
template <typename Sequence, typename Stack, bool IsSegmented = traits::is_segmented<Sequence>::type::value>
struct segmented_begin_impl_aux
{
typedef
segmented_end_impl<Range, Stack>
segmented_end_impl<Sequence, Stack>
end_impl;
typedef
segmented_fold_until_impl<
Range,
result<typename end_impl::type, continue_>,
Stack,
segmented_begin_fun
Sequence
, result<typename end_impl::type, continue_>
, Stack
, segmented_begin_fun
>
fold_impl;
typedef typename fold_impl::type::value_type type;
static type call(Range& rng, Stack const& stack)
static type call(Sequence& seq, Stack const& stack)
{
return fold_impl::call(rng, end_impl::call(rng, stack), stack, segmented_begin_fun()).value;
return fold_impl::call(seq, end_impl::call(seq, stack), stack, segmented_begin_fun()).value;
}
};
template <typename Range, typename Stack>
struct segmented_begin_impl_aux<Range, Stack, false>
template <typename Sequence, typename Stack>
struct segmented_begin_impl_aux<Sequence, Stack, false>
{
typedef typename result_of::begin<Range>::type begin_type;
typedef typename result_of::end<Range>::type end_type;
typedef typename result_of::begin<Sequence>::type begin_type;
typedef typename result_of::end<Sequence>::type end_type;
typedef iterator_range<begin_type, end_type> pair_type;
typedef cons<pair_type, Stack> type;
static type call(Range& rng, Stack stack)
static type call(Sequence& seq, Stack stack)
{
return type(pair_type(fusion::begin(rng), fusion::end(rng)), stack);
return type(pair_type(fusion::begin(seq), fusion::end(seq)), stack);
}
};
template <typename Range, typename Stack>
template <typename Sequence, typename Stack>
struct segmented_begin_impl
: segmented_begin_impl_aux<Range, Stack>
: segmented_begin_impl_aux<Sequence, Stack>
{};
}}}

View File

@ -13,24 +13,24 @@
namespace boost { namespace fusion { namespace detail
{
//auto segmented_end( rng )
//auto segmented_end( seq )
//{
// return make_segmented_iterator( segmented_end_impl( rng ) );
// return make_segmented_iterator( segmented_end_impl( seq ) );
//}
template<typename Range>
template <typename Sequence>
struct segmented_end
{
typedef
segmented_iterator<
typename segmented_end_impl<Range, fusion::nil>::type
typename segmented_end_impl<Sequence, fusion::nil>::type
>
type;
static type call(Range & rng)
static type call(Sequence & seq)
{
return type(
segmented_end_impl<Range, fusion::nil>::call(rng, fusion::nil()));
segmented_end_impl<Sequence, fusion::nil>::call(seq, fusion::nil()));
}
};

View File

@ -22,23 +22,23 @@ namespace boost { namespace fusion
namespace boost { namespace fusion { namespace detail
{
//auto segmented_end_impl( rng, stack )
//auto segmented_end_impl( seq, stack )
//{
// assert(is_segmented(rng));
// auto it = end(segments(rng));
// assert(is_segmented(seq));
// auto it = end(segments(seq));
// return cons(iterator_range(it, it), stack);
//}
template<typename Range, typename Stack>
template <typename Sequence, typename Stack>
struct segmented_end_impl
{
BOOST_MPL_ASSERT((traits::is_segmented<Range>));
BOOST_MPL_ASSERT((traits::is_segmented<Sequence>));
typedef
typename result_of::end<
typename remove_reference<
typename add_const<
typename result_of::segments<Range>::type
typename result_of::segments<Sequence>::type
>::type
>::type
>::type
@ -47,9 +47,9 @@ namespace boost { namespace fusion { namespace detail
typedef iterator_range<end_type, end_type> pair_type;
typedef cons<pair_type, Stack> type;
static type call(Range & rng, Stack stack)
static type call(Sequence & seq, Stack stack)
{
end_type end = fusion::end(fusion::segments(rng));
end_type end = fusion::end(fusion::segments(seq));
return type(pair_type(end, end), stack);
}
};

View File

@ -28,14 +28,14 @@ namespace boost { namespace fusion { namespace detail
///////////////////////////////////////////////////////////////////////////
template<typename Sequence, bool IsSegmented = traits::is_segmented<Sequence>::value>
struct segmented_size_impl
: mpl::fold<
: mpl::fold<
typename remove_reference<
typename add_const<
typename result_of::segments<Sequence>::type
>::type
>::type,
mpl::size_t<0>,
mpl::plus<mpl::_1, segmented_size<mpl::_2> >
>::type
, mpl::size_t<0>
, mpl::plus<mpl::_1, segmented_size<mpl::_2> >
>::type
{};