diff --git a/include/boost/fusion/algorithm/iteration/ext_/fold_s.hpp b/include/boost/fusion/algorithm/iteration/ext_/fold_s.hpp index f991d03c..9e9c3456 100644 --- a/include/boost/fusion/algorithm/iteration/ext_/fold_s.hpp +++ b/include/boost/fusion/algorithm/iteration/ext_/fold_s.hpp @@ -12,18 +12,18 @@ namespace boost { namespace fusion { namespace detail { - template + template struct segmented_fold_fun { - template + template struct result; - template - struct result + template + struct result { typedef fusion::result< - typename result_of::fold::type, + typename result_of::fold::type, continue_ > type; @@ -33,11 +33,11 @@ namespace boost { namespace fusion { namespace detail : fun(f) {} - template - typename result::type - operator()(Range& rng, State const& state, Context const&) const + template + typename result::type + operator()(Sequence& seq, State const& state, Context const&) const { - return fusion::fold(rng, state, fun); + return fusion::fold(seq, state, fun); } Fun const& fun; diff --git a/include/boost/fusion/algorithm/iteration/ext_/for_each_s.hpp b/include/boost/fusion/algorithm/iteration/ext_/for_each_s.hpp index 8d9173aa..8158a986 100644 --- a/include/boost/fusion/algorithm/iteration/ext_/for_each_s.hpp +++ b/include/boost/fusion/algorithm/iteration/ext_/for_each_s.hpp @@ -13,7 +13,7 @@ namespace boost { namespace fusion { namespace detail { - template + template struct segmented_for_each_fun { typedef result result_type; @@ -22,10 +22,10 @@ namespace boost { namespace fusion { namespace detail : fun(f) {} - template - result_type operator()(Range& rng, State const&, Context const&) const + template + result_type operator()(Sequence& seq, State const&, Context const&) const { - fusion::for_each(rng, fun); + fusion::for_each(seq, fun); return void_(); } diff --git a/include/boost/fusion/algorithm/query/detail/find_if.hpp b/include/boost/fusion/algorithm/query/detail/find_if.hpp index 5d2a7419..db2c182a 100644 --- a/include/boost/fusion/algorithm/query/detail/find_if.hpp +++ b/include/boost/fusion/algorithm/query/detail/find_if.hpp @@ -9,19 +9,18 @@ #if !defined(FUSION_FIND_IF_05052005_1107) #define FUSION_FIND_IF_05052005_1107 -#include -#include -#include #include +#include #include +#include +#include +#include +#include #include #include #include -#include -#include +#include #include -#include -#include namespace boost { namespace fusion { struct random_access_traversal_tag; @@ -222,10 +221,31 @@ namespace detail template static type - call(Iterator const& iter) + iter_call(Iterator const& iter) { return choose_call(iter, typename traits::category_of::type()); } + + template + static type + call(Sequence& seq) + { + return iter_call(fusion::begin(seq)); + } + }; + + template + struct result_of_find_if + { + typedef + static_find_if< + typename result_of::begin::type + , typename result_of::end::type + , Pred + > + filter; + + typedef typename filter::type type; }; }}} diff --git a/include/boost/fusion/algorithm/query/detail/segmented_find.hpp b/include/boost/fusion/algorithm/query/detail/segmented_find.hpp new file mode 100644 index 00000000..8429022e --- /dev/null +++ b/include/boost/fusion/algorithm/query/detail/segmented_find.hpp @@ -0,0 +1,106 @@ +/*============================================================================= + 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_FIND_HPP_INCLUDED) +#define BOOST_FUSION_SEGMENTED_FIND_HPP_INCLUDED + +#include +#include +#include +#include +#include + +namespace boost { namespace fusion { namespace detail +{ + template + struct segmented_find_fun + { + template + struct result; + + template + struct result + { + typedef + typename result_of::find::type + iterator_type; + + typedef + typename result_of::make_segmented_iterator< + iterator_type + , typename remove_const::type + >::type + segmented_iterator_type; + + typedef + typename mpl::if_< + result_of::equal_to< + iterator_type + , typename result_of::end::type + > + , fusion::result::type, continue_>, // NOT FOUND + fusion::result // FOUND + >::type + type; + }; + + template + typename result::type + operator()(Sequence& seq, State const&state, Context const& context) const + { + typedef + typename result_of::equal_to< + typename result_of::find::type + , typename result_of::end::type + >::type + not_found; + + return call(seq, state, context, not_found()); + } + + private: + template + typename result::type + call(Sequence&, State const&state, Context const&, mpl::true_) const + { + return state; + } + + template + typename result::type + call(Sequence& seq, State const&, Context const& context, mpl::false_) const + { + return fusion::make_segmented_iterator(fusion::find(seq), context); + } + }; + + template + struct result_of_segmented_find + { + struct filter + { + typedef + typename result_of::segmented_fold_until< + Sequence + , typename result_of::end::type + , segmented_find_fun + >::type + type; + + static type call(Sequence& seq) + { + return fusion::segmented_fold_until( + seq + , fusion::end(seq) + , detail::segmented_find_fun()); + } + }; + + typedef typename filter::type type; + }; +}}} + +#endif diff --git a/include/boost/fusion/algorithm/query/detail/segmented_find_if.hpp b/include/boost/fusion/algorithm/query/detail/segmented_find_if.hpp new file mode 100644 index 00000000..bdbbcfbc --- /dev/null +++ b/include/boost/fusion/algorithm/query/detail/segmented_find_if.hpp @@ -0,0 +1,108 @@ +/*============================================================================= + 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_FIND_IF_HPP_INCLUDED) +#define BOOST_FUSION_SEGMENTED_FIND_IF_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion { namespace detail +{ + template + struct segmented_find_if_fun + { + template + struct result; + + template + struct result + { + typedef + typename result_of::find_if::type + iterator_type; + + typedef + typename result_of::make_segmented_iterator< + iterator_type + , typename remove_const::type + >::type + segmented_iterator_type; + + typedef + typename mpl::if_< + result_of::equal_to< + iterator_type + , typename result_of::end::type + > + , fusion::result::type, continue_>, // NOT FOUND + fusion::result // FOUND + >::type + type; + }; + + template + typename result::type + operator()(Sequence& seq, State const& state, Context const& context) const + { + typedef + typename result_of::equal_to< + typename result_of::find_if::type + , typename result_of::end::type + >::type + not_found; + + return call(seq, state, context, not_found()); + } + + private: + template + typename result::type + call(Sequence&, State const& state, Context const&, mpl::true_) const + { + return state; + } + + template + typename result::type + call(Sequence& seq, State const&, Context const& context, mpl::false_) const + { + return fusion::make_segmented_iterator(fusion::find_if(seq), context); + } + }; + + template + struct result_of_segmented_find_if + { + struct filter + { + typedef + typename result_of::segmented_fold_until< + Sequence + , typename result_of::end::type + , segmented_find_if_fun + >::type + type; + + static type call(Sequence& seq) + { + return fusion::segmented_fold_until( + seq + , fusion::end(seq) + , segmented_find_if_fun()); + } + }; + + typedef typename filter::type type; + }; +}}} + +#endif diff --git a/include/boost/fusion/algorithm/query/ext_/find_if_s.hpp b/include/boost/fusion/algorithm/query/ext_/find_if_s.hpp deleted file mode 100644 index 863d806a..00000000 --- a/include/boost/fusion/algorithm/query/ext_/find_if_s.hpp +++ /dev/null @@ -1,114 +0,0 @@ -/*============================================================================= - 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_FIND_IF_S_HPP_INCLUDED) -#define BOOST_FUSION_FIND_IF_S_HPP_INCLUDED - -#include -#include -#include -#include - -namespace boost { namespace fusion { namespace detail -{ - template - struct segmented_find_if_fun - { - template - struct result; - - template - struct result - { - typedef - typename result_of::find_if::type - iterator_type; - - typedef - typename result_of::make_segmented_iterator< - iterator_type, - typename remove_const::type - >::type - segmented_iterator_type; - - typedef - typename mpl::if_< - result_of::equal_to< - iterator_type, - typename result_of::end::type - >, - fusion::result::type, continue_>, // NOT FOUND - fusion::result // FOUND - >::type - type; - }; - - template - typename result::type - operator()(Range& rng, State const& state, Context const& context) const - { - typedef - typename result_of::equal_to< - typename result_of::find_if::type, - typename result_of::end::type - >::type - not_found; - - return call(rng, state, context, not_found()); - } - - private: - template - typename result::type - call(Range&, State const& state, Context const&, mpl::true_) const - { - return state; - } - - template - typename result::type - call(Range& rng, State const&, Context const& context, mpl::false_) const - { - return fusion::make_segmented_iterator(fusion::find_if(rng), context); - } - }; - -}}} - -namespace boost { namespace fusion -{ - namespace result_of - { - template - struct find_if_s - : result_of::segmented_fold_until< - Sequence, - typename result_of::end::type, - detail::segmented_find_if_fun > - {}; - } - - template - typename result_of::find_if_s::type - find_if_s(Sequence& seq) - { - return fusion::segmented_fold_until( - seq, - fusion::end(seq), - detail::segmented_find_if_fun()); - } - - template - typename result_of::find_if_s::type - find_if_s(Sequence const& seq) - { - return fusion::segmented_fold_until( - seq, fusion::end(seq), - detail::segmented_find_if_fun()); - } -}} - -#endif diff --git a/include/boost/fusion/algorithm/query/ext_/find_s.hpp b/include/boost/fusion/algorithm/query/ext_/find_s.hpp deleted file mode 100644 index a1a1f904..00000000 --- a/include/boost/fusion/algorithm/query/ext_/find_s.hpp +++ /dev/null @@ -1,115 +0,0 @@ -/*============================================================================= - 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_FIND_S_HPP_INCLUDED) -#define BOOST_FUSION_FIND_S_HPP_INCLUDED - -#include -#include -#include -#include - -namespace boost { namespace fusion { namespace detail -{ - template - struct segmented_find_fun - { - template - struct result; - - template - struct result - { - typedef - typename result_of::find::type - iterator_type; - - typedef - typename result_of::make_segmented_iterator< - iterator_type, - typename remove_const::type - >::type - segmented_iterator_type; - - typedef - typename mpl::if_< - result_of::equal_to< - iterator_type, - typename result_of::end::type - >, - fusion::result::type, continue_>, // NOT FOUND - fusion::result // FOUND - >::type - type; - }; - - template - typename result::type - operator()(Range& rng, State const&state, Context const& context) const - { - typedef - typename result_of::equal_to< - typename result_of::find::type, - typename result_of::end::type - >::type - not_found; - - return call(rng, state, context, not_found()); - } - - private: - template - typename result::type - call(Range&, State const&state, Context const&, mpl::true_) const - { - return state; - } - - template - typename result::type - call(Range& rng, State const&, Context const& context, mpl::false_) const - { - return fusion::make_segmented_iterator(fusion::find(rng), context); - } - }; - -}}} - -namespace boost { namespace fusion -{ - namespace result_of - { - template - struct find_s - : result_of::segmented_fold_until< - Sequence, - typename result_of::end::type, - detail::segmented_find_fun > - {}; - } - - template - typename result_of::find_s::type - find_s(Sequence& seq) - { - return fusion::segmented_fold_until( - seq, - fusion::end(seq), - detail::segmented_find_fun()); - } - - template - typename result_of::find_s::type - find_s(Sequence const& seq) - { - return fusion::segmented_fold_until( - seq, - fusion::end(seq), - detail::segmented_find_fun()); - } -}} - -#endif diff --git a/include/boost/fusion/algorithm/query/find.hpp b/include/boost/fusion/algorithm/query/find.hpp index 6beb9005..7b089c96 100644 --- a/include/boost/fusion/algorithm/query/find.hpp +++ b/include/boost/fusion/algorithm/query/find.hpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman + 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) @@ -7,13 +8,15 @@ #if !defined(FUSION_FIND_05052005_1107) #define FUSION_FIND_05052005_1107 +#include #include -#include -#include +#include #include #include #include +#include #include +#include #include #include #include @@ -22,17 +25,14 @@ namespace boost { namespace fusion { namespace result_of { - template < - typename Sequence - , typename T - > + template struct find - { - typedef - detail::static_find_if< - typename result_of::begin::type - , typename result_of::end::type - , is_same< + : mpl::if_< + traits::is_segmented + , detail::result_of_segmented_find + , detail::result_of_find_if< + Sequence, + is_same< typename mpl::if_< traits::is_associative , key_of @@ -41,10 +41,8 @@ namespace boost { namespace fusion , T > > - filter; - - typedef typename filter::type type; - }; + >::type + {}; } template @@ -56,7 +54,7 @@ namespace boost { namespace fusion find(Sequence& seq) { typedef typename result_of::find::filter filter; - return filter::call(fusion::begin(seq)); + return filter::call(seq); } template @@ -64,9 +62,8 @@ namespace boost { namespace fusion find(Sequence const& seq) { typedef typename result_of::find::filter filter; - return filter::call(fusion::begin(seq)); + return filter::call(seq); } }} #endif - diff --git a/include/boost/fusion/algorithm/query/find_fwd.hpp b/include/boost/fusion/algorithm/query/find_fwd.hpp new file mode 100644 index 00000000..96d989a4 --- /dev/null +++ b/include/boost/fusion/algorithm/query/find_fwd.hpp @@ -0,0 +1,34 @@ +/*============================================================================= + 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_FIND_FWD_HPP_INCLUDED) +#define BOOST_FUSION_FIND_FWD_HPP_INCLUDED + +#include +#include + +namespace boost { namespace fusion +{ + namespace result_of + { + template + struct find; + } + + template + inline typename + lazy_disable_if< + is_const + , result_of::find + >::type const + find(Sequence& seq); + + template + inline typename result_of::find::type const + find(Sequence const& seq); +}} + +#endif diff --git a/include/boost/fusion/algorithm/query/find_if.hpp b/include/boost/fusion/algorithm/query/find_if.hpp index 3950958c..5f0e64d8 100644 --- a/include/boost/fusion/algorithm/query/find_if.hpp +++ b/include/boost/fusion/algorithm/query/find_if.hpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman + 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) @@ -7,15 +8,17 @@ #if !defined(FUSION_FIND_IF_05052005_1108) #define FUSION_FIND_IF_05052005_1108 +#include #include -#include -#include +#include #include -#include -#include -#include +#include #include #include +#include +#include +#include +#include namespace boost { namespace fusion { @@ -23,20 +26,18 @@ namespace boost { namespace fusion { template struct find_if - { - typedef - detail::static_find_if< - typename result_of::begin::type - , typename result_of::end::type - , mpl::bind1< + : mpl::if_< + traits::is_segmented + , detail::result_of_segmented_find_if + , detail::result_of_find_if< + Sequence, + mpl::bind1< typename mpl::lambda::type - , mpl::bind1,mpl::_1> + , mpl::bind1, mpl::_1> > > - filter; - - typedef typename filter::type type; - }; + >::type + {}; } template @@ -48,7 +49,7 @@ namespace boost { namespace fusion find_if(Sequence& seq) { typedef typename result_of::find_if::filter filter; - return filter::call(fusion::begin(seq)); + return filter::call(seq); } template @@ -56,9 +57,8 @@ namespace boost { namespace fusion find_if(Sequence const& seq) { typedef typename result_of::find_if::filter filter; - return filter::call(fusion::begin(seq)); + return filter::call(seq); } }} #endif - diff --git a/include/boost/fusion/algorithm/query/find_if_fwd.hpp b/include/boost/fusion/algorithm/query/find_if_fwd.hpp new file mode 100644 index 00000000..adb8f2de --- /dev/null +++ b/include/boost/fusion/algorithm/query/find_if_fwd.hpp @@ -0,0 +1,35 @@ +/*============================================================================= + 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_FIND_IF_FWD_HPP_INCLUDED) +#define BOOST_FUSION_FIND_IF_FWD_HPP_INCLUDED + +#include +#include + +// Forward declaration of find_if algorithm +namespace boost { namespace fusion +{ + namespace result_of + { + template + struct find_if; + } + + template + typename + lazy_disable_if< + is_const + , result_of::find_if + >::type + find_if(Sequence& seq); + + template + typename result_of::find_if::type const + find_if(Sequence const& seq); +}} + +#endif diff --git a/include/boost/fusion/iterator/detail/segmented_next_impl.hpp b/include/boost/fusion/iterator/detail/segmented_next_impl.hpp index 60ead2e5..2a7f6f6c 100644 --- a/include/boost/fusion/iterator/detail/segmented_next_impl.hpp +++ b/include/boost/fusion/iterator/detail/segmented_next_impl.hpp @@ -24,7 +24,7 @@ namespace boost { namespace fusion namespace detail { - template + template struct segmented_begin_impl; //bool is_invalid(stack) @@ -40,7 +40,7 @@ namespace boost { namespace fusion > {}; - ////Advance the first iterator in the range at the + ////Advance the first iterator in the seq at the ////top of a stack of iterator ranges. Return the ////new stack. //auto pop_front_car(stack) @@ -126,7 +126,7 @@ namespace boost { namespace fusion template < typename Stack, - typename Range = + typename Sequence = typename remove_reference< typename add_const< typename result_of::deref< @@ -135,7 +135,7 @@ namespace boost { namespace fusion >::type >::type, typename Result = - typename segmented_begin_impl::type, + typename segmented_begin_impl::type, bool IsInvalid = is_invalid::value> struct segmented_next_impl_recurse2 @@ -149,14 +149,14 @@ namespace boost { namespace fusion } }; - template - struct segmented_next_impl_recurse2 + template + struct segmented_next_impl_recurse2 { typedef Result type; static type call(Stack const & stack) { - return segmented_begin_impl::call(*stack.car.first, stack); + return segmented_begin_impl::call(*stack.car.first, stack); } }; @@ -210,7 +210,7 @@ namespace boost { namespace fusion //auto segmented_next_impl(stack) //{ - // // car(stack) is a range of values, not a range of segments + // // car(stack) is a seq of values, not a seq of segments // auto next = pop_front_car(stack); // if (is_invalid(next)) // return segmented_next_impl_recurse(cdr(next)); diff --git a/include/boost/fusion/sequence/intrinsic/detail/segmented_begin.hpp b/include/boost/fusion/sequence/intrinsic/detail/segmented_begin.hpp index b1c5b907..2e407c6b 100644 --- a/include/boost/fusion/sequence/intrinsic/detail/segmented_begin.hpp +++ b/include/boost/fusion/sequence/intrinsic/detail/segmented_begin.hpp @@ -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 + template struct segmented_begin { typedef segmented_iterator< - typename segmented_begin_impl::type + typename segmented_begin_impl::type > type; - static type call(Range & rng) + static type call(Sequence& seq) { return type( - segmented_begin_impl::call(rng, fusion::nil())); + segmented_begin_impl::call(seq, fusion::nil())); } }; diff --git a/include/boost/fusion/sequence/intrinsic/detail/segmented_begin_impl.hpp b/include/boost/fusion/sequence/intrinsic/detail/segmented_begin_impl.hpp index d75a1e77..5968cd12 100644 --- a/include/boost/fusion/sequence/intrinsic/detail/segmented_begin_impl.hpp +++ b/include/boost/fusion/sequence/intrinsic/detail/segmented_begin_impl.hpp @@ -27,80 +27,80 @@ namespace boost { namespace fusion { namespace detail template struct result; - template - struct result + template + struct result { typedef iterator_range< - typename fusion::result_of::begin::type, - typename fusion::result_of::end::type + typename fusion::result_of::begin::type + , typename fusion::result_of::end::type > range_type; typedef fusion::result< - cons::type>, - fusion::break_ + cons::type> + , fusion::break_ > type; }; - template - typename result::type - operator()(Range& rng, State const&, Context const& context) const + template + typename result::type + operator()(Sequence& seq, State const&, Context const& context) const { typedef iterator_range< - typename fusion::result_of::begin::type, - typename fusion::result_of::end::type + typename fusion::result_of::begin::type + , typename fusion::result_of::end::type > range_type; - return cons(range_type(fusion::begin(rng), fusion::end(rng)), context); + return cons(range_type(fusion::begin(seq), fusion::end(seq)), context); } }; - template ::type::value> + template ::type::value> struct segmented_begin_impl_aux { typedef - segmented_end_impl + segmented_end_impl end_impl; typedef segmented_fold_until_impl< - Range, - result, - Stack, - segmented_begin_fun + Sequence + , result + , 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 - struct segmented_begin_impl_aux + template + struct segmented_begin_impl_aux { - typedef typename result_of::begin::type begin_type; - typedef typename result_of::end::type end_type; + typedef typename result_of::begin::type begin_type; + typedef typename result_of::end::type end_type; typedef iterator_range pair_type; typedef cons 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 + template struct segmented_begin_impl - : segmented_begin_impl_aux + : segmented_begin_impl_aux {}; }}} diff --git a/include/boost/fusion/sequence/intrinsic/detail/segmented_end.hpp b/include/boost/fusion/sequence/intrinsic/detail/segmented_end.hpp index 5287a725..4a3d5bf7 100644 --- a/include/boost/fusion/sequence/intrinsic/detail/segmented_end.hpp +++ b/include/boost/fusion/sequence/intrinsic/detail/segmented_end.hpp @@ -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 + template struct segmented_end { typedef segmented_iterator< - typename segmented_end_impl::type + typename segmented_end_impl::type > type; - static type call(Range & rng) + static type call(Sequence & seq) { return type( - segmented_end_impl::call(rng, fusion::nil())); + segmented_end_impl::call(seq, fusion::nil())); } }; diff --git a/include/boost/fusion/sequence/intrinsic/detail/segmented_end_impl.hpp b/include/boost/fusion/sequence/intrinsic/detail/segmented_end_impl.hpp index 1df8b4bd..149027bc 100644 --- a/include/boost/fusion/sequence/intrinsic/detail/segmented_end_impl.hpp +++ b/include/boost/fusion/sequence/intrinsic/detail/segmented_end_impl.hpp @@ -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 + template struct segmented_end_impl { - BOOST_MPL_ASSERT((traits::is_segmented)); + BOOST_MPL_ASSERT((traits::is_segmented)); typedef typename result_of::end< typename remove_reference< typename add_const< - typename result_of::segments::type + typename result_of::segments::type >::type >::type >::type @@ -47,9 +47,9 @@ namespace boost { namespace fusion { namespace detail typedef iterator_range pair_type; typedef cons 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); } }; diff --git a/include/boost/fusion/sequence/intrinsic/detail/segmented_size.hpp b/include/boost/fusion/sequence/intrinsic/detail/segmented_size.hpp index 3354b651..2af69735 100644 --- a/include/boost/fusion/sequence/intrinsic/detail/segmented_size.hpp +++ b/include/boost/fusion/sequence/intrinsic/detail/segmented_size.hpp @@ -28,14 +28,14 @@ namespace boost { namespace fusion { namespace detail /////////////////////////////////////////////////////////////////////////// template::value> struct segmented_size_impl - : mpl::fold< + : mpl::fold< typename remove_reference< typename add_const< typename result_of::segments::type >::type - >::type, - mpl::size_t<0>, - mpl::plus > + >::type + , mpl::size_t<0> + , mpl::plus > >::type {}; diff --git a/include/boost/fusion/support/detail/segmented_fold_until_impl.hpp b/include/boost/fusion/support/detail/segmented_fold_until_impl.hpp index cdc5eb1e..38d68fc0 100644 --- a/include/boost/fusion/support/detail/segmented_fold_until_impl.hpp +++ b/include/boost/fusion/support/detail/segmented_fold_until_impl.hpp @@ -24,8 +24,8 @@ #include #include -// fun(rng, state, context) -// rng: a non-segmented range +// fun(seq, state, context) +// seq: a non-segmented range // state: the state of the fold so far // context: the path to the current range // @@ -46,8 +46,8 @@ namespace boost { namespace fusion { typedef iterator_range< - Cur, - typename result_of::end< + Cur + , typename result_of::end< typename remove_reference< typename add_const< typename result_of::deref< @@ -118,31 +118,31 @@ namespace boost { namespace fusion namespace detail { template < - typename Begin, - typename End, - typename State, - typename Context, - typename Fun, - bool IsEmpty = result_of::empty< + typename Begin + , typename End + , typename State + , typename Context + , typename Fun + , bool IsEmpty = result_of::empty< typename result_of::value_of::type >::type::value> struct segmented_fold_until_iterate_skip_empty; template < - typename Begin, - typename End, - typename State, - typename Context, - typename Fun, - bool IsDone = result_of::equal_to::type::value> + typename Begin + , typename End + , typename State + , typename Context + , typename Fun + , bool IsDone = result_of::equal_to::type::value> struct segmented_fold_until_iterate; template < - typename Range, - typename State, - typename Context, - typename Fun, - bool IsSegmented = traits::is_segmented::type::value> + typename Sequence + , typename State + , typename Context + , typename Fun + , bool IsSegmented = traits::is_segmented::type::value> struct segmented_fold_until_impl; template @@ -170,65 +170,65 @@ namespace boost { namespace fusion // return segmented_iterator(push_context(cur, end, context)); //} // - //auto segmented_fold_until_impl(rng, state, context, fun) + //auto segmented_fold_until_impl(seq, state, context, fun) //{ - // if (is_segmented(rng)) + // if (is_segmented(seq)) // { - // segmented_fold_until_on_segments(segments(rng), state, context, fun); + // segmented_fold_until_on_segments(segments(seq), state, context, fun); // } // else // { - // return fun(rng, state, context); + // return fun(seq, state, context); // } //} template < - typename Range, - typename State, - typename Context, - typename Fun, - bool IsSegmented> + typename Sequence + , typename State + , typename Context + , typename Fun + , bool IsSegmented> struct segmented_fold_until_impl { typedef segmented_fold_until_on_segments< typename remove_reference< typename add_const< - typename result_of::segments::type + typename result_of::segments::type >::type - >::type, - State, - Context, - Fun + >::type + , State + , Context + , Fun > impl; typedef typename impl::type type; - static type call(Range& rng, State const& state, Context const& context, Fun const& fun) + static type call(Sequence& seq, State const& state, Context const& context, Fun const& fun) { - return impl::call(fusion::segments(rng), state, context, fun); + return impl::call(fusion::segments(seq), state, context, fun); } }; template < - typename Range, - typename State, - typename Context, - typename Fun> - struct segmented_fold_until_impl + typename Sequence + , typename State + , typename Context + , typename Fun> + struct segmented_fold_until_impl { typedef typename boost::result_of::type>::type, - Context const& + Sequence& + , typename add_reference::type>::type + , Context const& )>::type type; - static type call(Range& rng, State const& state, Context const& context, Fun const& fun) + static type call(Sequence& seq, State const& state, Context const& context, Fun const& fun) { - return fun(rng, state.value, context); + return fun(seq, state.value, context); } }; @@ -264,10 +264,10 @@ namespace boost { namespace fusion typename add_const< typename result_of::deref::type >::type - >::type, - State, - next_context_type, - Fun + >::type + , State + , next_context_type + , Fun > fold_recurse_impl; @@ -277,51 +277,51 @@ namespace boost { namespace fusion typedef segmented_fold_until_iterate< - typename result_of::next::type, - End, - next_state_type, - Context, - Fun + typename result_of::next::type + , End + , next_state_type + , Context + , Fun > next_iteration_impl; typedef typename mpl::eval_if< - typename next_state_type::continue_type, - next_iteration_impl, - mpl::identity + typename next_state_type::continue_type + , next_iteration_impl + , mpl::identity >::type type; - static type call(Begin const& beg, End const& end, State const& state, - Context const& context, Fun const& fun) + static type call(Begin const& beg, End const& end, State const& state + , Context const& context, Fun const& fun) { return call(beg, end, state, context, fun, typename next_state_type::continue_type()); } - static type call(Begin const& beg, End const& end, State const& state, - Context const& context, Fun const& fun, mpl::true_) // continue + static type call(Begin const& beg, End const& end, State const& state + , Context const& context, Fun const& fun, mpl::true_) // continue { return next_iteration_impl::call( - fusion::next(beg), - end, - fold_recurse_impl::call( - *beg, - state, - push_context_impl::call(beg, end, context), - fun), - context, - fun); + fusion::next(beg) + , end + , fold_recurse_impl::call( + *beg + , state + , push_context_impl::call(beg, end, context) + , fun) + , context + , fun); } - static type call(Begin const& beg, End const& end, State const& state, - Context const& context, Fun const& fun, mpl::false_) // break + static type call(Begin const& beg, End const& end, State const& state + , Context const& context, Fun const& fun, mpl::false_) // break { return fold_recurse_impl::call( - *beg, - state, - push_context_impl::call(beg, end, context), - fun); + *beg + , state + , push_context_impl::call(beg, end, context) + , fun); } }; @@ -330,18 +330,18 @@ namespace boost { namespace fusion { typedef segmented_fold_until_iterate< - typename result_of::next::type, - End, - State, - Context, - Fun + typename result_of::next::type + , End + , State + , Context + , Fun > impl; typedef typename impl::type type; - static type call(Begin const& beg, End const& end, State const& state, - Context const& context, Fun const& fun) + static type call(Begin const& beg, End const& end, State const& state + , Context const& context, Fun const& fun) { return impl::call(fusion::next(beg), end, state, context, fun); } @@ -356,8 +356,8 @@ namespace boost { namespace fusion typedef typename impl::type type; - static type call(Begin const& beg, End const& end, State const& state, - Context const& context, Fun const& fun) + static type call(Begin const& beg, End const& end, State const& state + , Context const& context, Fun const& fun) { return impl::call(beg, end, state, context, fun); } @@ -368,8 +368,8 @@ namespace boost { namespace fusion { typedef State type; - static type call(Begin const&, End const&, State const& state, - Context const&, Fun const&) + static type call(Begin const&, End const&, State const& state + , Context const&, Fun const&) { return state; } @@ -380,11 +380,11 @@ namespace boost { namespace fusion { typedef segmented_fold_until_iterate< - typename result_of::begin::type, - typename result_of::end::type, - State, - Context, - Fun + typename result_of::begin::type + , typename result_of::end::type + , State + , Context + , Fun > impl; diff --git a/include/boost/fusion/support/segmented_fold_until.hpp b/include/boost/fusion/support/segmented_fold_until.hpp index 670266ce..15f51707 100644 --- a/include/boost/fusion/support/segmented_fold_until.hpp +++ b/include/boost/fusion/support/segmented_fold_until.hpp @@ -7,6 +7,8 @@ #if !defined(BOOST_FUSION_SEGMENTED_FOLD_UNTIL_HPP_INCLUDED) #define BOOST_FUSION_SEGMENTED_FOLD_UNTIL_HPP_INCLUDED +#include +#include #include #include #include @@ -16,45 +18,56 @@ namespace boost { namespace fusion { - //auto segmented_fold_until(rng, state, fun) + //auto segmented_fold_until(seq, state, fun) //{ - // return first(segmented_fold_until_impl(rng, state, nil, fun)); + // return first(segmented_fold_until_impl(seq, state, nil, fun)); //} namespace result_of { - template + template struct segmented_fold_until { typedef detail::segmented_fold_until_impl< - Range, - result, - fusion::nil, - Fun + Sequence + , result + , fusion::nil + , Fun > - impl; + filter; typedef - typename impl::type::value_type + typename filter::type::value_type type; }; } - template - typename result_of::segmented_fold_until::type - segmented_fold_until(Range& rng, State const& state, Fun const& fun) + template + typename + lazy_disable_if< + is_const + , result_of::segmented_fold_until + >::type + segmented_fold_until(Sequence& seq, State const& state, Fun const& fun) { - typedef typename result_of::segmented_fold_until::impl impl; - return impl::call(rng, state, fusion::nil(), fun).value; + typedef + typename result_of::segmented_fold_until::filter + filter; + + return filter::call(seq, state, fusion::nil(), fun).value; } - template - typename result_of::segmented_fold_until::type - segmented_fold_until(Range const& rng, State const& state, Fun const& fun) + template + typename result_of::segmented_fold_until::type + segmented_fold_until(Sequence const& seq, State const& state, Fun const& fun) { - typedef typename result_of::segmented_fold_until::impl impl; - return impl::call(rng, state, fusion::nil(), fun).value; + typedef + typename result_of::segmented_fold_until::filter + filter; + + return filter::call(seq, state, fusion::nil(), fun).value; } }} + #endif diff --git a/include/boost/fusion/view/filter_view/detail/next_impl.hpp b/include/boost/fusion/view/filter_view/detail/next_impl.hpp index a436bfc2..d575d3b3 100644 --- a/include/boost/fusion/view/filter_view/detail/next_impl.hpp +++ b/include/boost/fusion/view/filter_view/detail/next_impl.hpp @@ -65,7 +65,7 @@ namespace boost { namespace fusion static type call(Iterator const& i) { - return type(filter::call(i.first)); + return type(filter::iter_call(i.first)); } }; }; diff --git a/include/boost/fusion/view/filter_view/filter_view_iterator.hpp b/include/boost/fusion/view/filter_view/filter_view_iterator.hpp index 8ce63cbd..5da7bf34 100644 --- a/include/boost/fusion/view/filter_view/filter_view_iterator.hpp +++ b/include/boost/fusion/view/filter_view/filter_view_iterator.hpp @@ -55,7 +55,7 @@ namespace boost { namespace fusion typedef Pred pred_type; filter_iterator(First const& in_first) - : first(filter::call(first_converter::call(in_first))) {} + : first(filter::iter_call(first_converter::call(in_first))) {} first_type first; diff --git a/include/boost/fusion/view/iterator_range/detail/is_segmented_impl.hpp b/include/boost/fusion/view/iterator_range/detail/is_segmented_impl.hpp index 5ca20378..032225dc 100644 --- a/include/boost/fusion/view/iterator_range/detail/is_segmented_impl.hpp +++ b/include/boost/fusion/view/iterator_range/detail/is_segmented_impl.hpp @@ -53,9 +53,9 @@ namespace boost { namespace fusion : is_segmented_iterator { BOOST_MPL_ASSERT_RELATION( - is_segmented_iterator::value, - ==, - is_segmented_iterator::value); + is_segmented_iterator::value + , == + , is_segmented_iterator::value); }; }; } diff --git a/include/boost/fusion/view/iterator_range/detail/segmented_iterator_range.hpp b/include/boost/fusion/view/iterator_range/detail/segmented_iterator_range.hpp index df5f7a93..e7765b2f 100644 --- a/include/boost/fusion/view/iterator_range/detail/segmented_iterator_range.hpp +++ b/include/boost/fusion/view/iterator_range/detail/segmented_iterator_range.hpp @@ -82,16 +82,16 @@ namespace boost { namespace fusion { namespace detail >::type >::type >::type - >::type, - typename Stack::cdr_type::car_type::end_type + >::type + , typename Stack::cdr_type::car_type::end_type >)); typedef iterator_range< typename result_of::next< typename Stack::cdr_type::car_type::begin_type - >::type, - typename result_of::end< + >::type + , typename result_of::end< typename remove_reference< typename add_const< typename result_of::segments< @@ -116,8 +116,8 @@ namespace boost { namespace fusion { namespace detail typedef segment_sequence< typename result_of::push_front< - rest_type const, - typename recurse::type + rest_type const + , typename recurse::type >::type > type; @@ -130,8 +130,8 @@ namespace boost { namespace fusion { namespace detail // make_segment_sequence_front(cdr(stack_begin)))); return type( fusion::push_front( - rest_type(fusion::next(stack.cdr.car.first), fusion::end(fusion::segments(*stack.car.first))), - recurse::call(stack.cdr))); + rest_type(fusion::next(stack.cdr.car.first), fusion::end(fusion::segments(*stack.car.first))) + , recurse::call(stack.cdr))); } }; @@ -149,14 +149,14 @@ namespace boost { namespace fusion { namespace detail >::type >::type >::type - >::type, - typename Stack::cdr_type::car_type::end_type + >::type + , typename Stack::cdr_type::car_type::end_type >)); typedef iterator_range< - typename Stack::cdr_type::car_type::begin_type, - typename result_of::end< + typename Stack::cdr_type::car_type::begin_type + , typename result_of::end< typename remove_reference< typename add_const< typename result_of::deref< @@ -226,8 +226,8 @@ namespace boost { namespace fusion { namespace detail >::type >::type >::type - >::type, - typename Stack::cdr_type::car_type::end_type + >::type + , typename Stack::cdr_type::car_type::end_type >)); typedef @@ -246,8 +246,8 @@ namespace boost { namespace fusion { namespace detail >::type >::type >::type - >::type, - typename Stack::cdr_type::car_type::begin_type + >::type + , typename Stack::cdr_type::car_type::begin_type > rest_type; @@ -258,8 +258,8 @@ namespace boost { namespace fusion { namespace detail typedef segment_sequence< typename result_of::push_back< - rest_type const, - typename recurse::type + rest_type const + , typename recurse::type >::type > type; @@ -272,8 +272,8 @@ namespace boost { namespace fusion { namespace detail // make_segment_sequence_back(cdr(stack_end)))); return type( fusion::push_back( - rest_type(fusion::begin(fusion::segments(*stack.car.first)), stack.cdr.car.first), - recurse::call(stack.cdr))); + rest_type(fusion::begin(fusion::segments(*stack.car.first)), stack.cdr.car.first) + , recurse::call(stack.cdr))); } }; @@ -291,8 +291,8 @@ namespace boost { namespace fusion { namespace detail >::type >::type >::type - >::type, - typename Stack::cdr_type::car_type::end_type + >::type + , typename Stack::cdr_type::car_type::end_type >)); typedef @@ -305,8 +305,8 @@ namespace boost { namespace fusion { namespace detail >::type >::type >::type - >::type, - typename Stack::cdr_type::car_type::begin_type + >::type + , typename Stack::cdr_type::car_type::begin_type > type; @@ -362,19 +362,19 @@ namespace boost { namespace fusion { namespace detail //} template < - typename StackBegin, - typename StackEnd, - int StackBeginSize = StackBegin::size::value, - int StackEndSize = StackEnd::size::value> + typename StackBegin + , typename StackEnd + , int StackBeginSize = StackBegin::size::value + , int StackEndSize = StackEnd::size::value> struct make_segmented_range_reduce; template < - typename StackBegin, - typename StackEnd, - bool SameSegment = + typename StackBegin + , typename StackEnd + , bool SameSegment = result_of::equal_to< - typename StackBegin::car_type::begin_type, - typename StackEnd::car_type::begin_type + typename StackBegin::car_type::begin_type + , typename StackEnd::car_type::begin_type >::type::value> struct make_segmented_range_reduce2 { @@ -382,8 +382,8 @@ namespace boost { namespace fusion { namespace detail iterator_range< typename result_of::next< typename StackBegin::car_type::begin_type - >::type, - typename StackEnd::car_type::begin_type + >::type + , typename StackEnd::car_type::begin_type > rest_type; @@ -391,10 +391,10 @@ namespace boost { namespace fusion { namespace detail segment_sequence< typename result_of::push_back< typename result_of::push_front< - rest_type const, - typename make_segment_sequence_front::type - >::type const, - typename make_segment_sequence_back::type + rest_type const + , typename make_segment_sequence_front::type + >::type const + , typename make_segment_sequence_back::type >::type > type; @@ -412,9 +412,9 @@ namespace boost { namespace fusion { namespace detail return type( fusion::push_back( fusion::push_front( - rest_type(fusion::next(stack_begin.car.first), stack_end.car.first), - make_segment_sequence_front::call(stack_begin)), - make_segment_sequence_back::call(stack_end))); + rest_type(fusion::next(stack_begin.car.first), stack_end.car.first) + , make_segment_sequence_front::call(stack_begin)) + , make_segment_sequence_back::call(stack_end))); } }; @@ -423,8 +423,8 @@ namespace boost { namespace fusion { namespace detail { typedef make_segmented_range_reduce< - typename StackBegin::cdr_type, - typename StackEnd::cdr_type + typename StackBegin::cdr_type + , typename StackEnd::cdr_type > impl; @@ -448,8 +448,8 @@ namespace boost { namespace fusion { namespace detail { typedef iterator_range< - typename StackBegin::car_type::begin_type, - typename StackEnd::car_type::begin_type + typename StackBegin::car_type::begin_type + , typename StackEnd::car_type::begin_type > range_type; @@ -483,8 +483,8 @@ namespace boost { namespace fusion { namespace detail typedef make_segmented_range_reduce< - typename reverse_begin_cons::type, - typename reverse_end_cons::type + typename reverse_begin_cons::type + , typename reverse_end_cons::type > impl; @@ -493,8 +493,8 @@ namespace boost { namespace fusion { namespace detail static type call(Begin const & begin, End const & end) { return impl::call( - reverse_begin_cons::call(begin.context), - reverse_end_cons::call(end.context)); + reverse_begin_cons::call(begin.context) + , reverse_end_cons::call(end.context)); } }; diff --git a/include/boost/fusion/view/iterator_range/detail/segments_impl.hpp b/include/boost/fusion/view/iterator_range/detail/segments_impl.hpp index 5d114615..ede49683 100644 --- a/include/boost/fusion/view/iterator_range/detail/segments_impl.hpp +++ b/include/boost/fusion/view/iterator_range/detail/segments_impl.hpp @@ -29,8 +29,8 @@ namespace boost { namespace fusion { typedef detail::make_segmented_range< - typename Sequence::begin_type, - typename Sequence::end_type + typename Sequence::begin_type + , typename Sequence::end_type > impl; diff --git a/test/algorithm/segmented_find.cpp b/test/algorithm/segmented_find.cpp index 4c4c31a5..3db7b725 100644 --- a/test/algorithm/segmented_find.cpp +++ b/test/algorithm/segmented_find.cpp @@ -7,7 +7,7 @@ ==============================================================================*/ #include #include -#include +#include #include #include "../sequence/tree.hpp" @@ -19,21 +19,21 @@ process_tree(Tree const &tree) { using namespace boost; - typedef typename boost::fusion::result_of::find_s::type short_iter; - typedef typename boost::fusion::result_of::find_s::type float_iter; - typedef typename boost::fusion::result_of::find_s::type not_there_iter; + typedef typename boost::fusion::result_of::find::type short_iter; + typedef typename boost::fusion::result_of::find::type float_iter; + typedef typename boost::fusion::result_of::find::type not_there_iter; // find_if_s of a segmented data structure returns generic // segmented iterators - short_iter si = fusion::find_s(tree); - float_iter fi = fusion::find_s(tree); + short_iter si = fusion::find(tree); + float_iter fi = fusion::find(tree); // they behave like ordinary Fusion iterators ... BOOST_TEST((*si == short('d'))); BOOST_TEST((*fi == float(1))); // Searching for something that's not there should return the end iterator. - not_there_iter nti = fusion::find_s(tree); + not_there_iter nti = fusion::find(tree); BOOST_TEST((nti == fusion::end(tree))); } diff --git a/test/algorithm/segmented_find_if.cpp b/test/algorithm/segmented_find_if.cpp index 14a2af7e..5ee71d10 100644 --- a/test/algorithm/segmented_find_if.cpp +++ b/test/algorithm/segmented_find_if.cpp @@ -7,7 +7,7 @@ ==============================================================================*/ #include #include -#include +#include #include #include #include @@ -22,21 +22,21 @@ process_tree(Tree const &tree) using namespace boost; using mpl::_; - typedef typename boost::fusion::result_of::find_if_s >::type short_iter; - typedef typename boost::fusion::result_of::find_if_s >::type float_iter; - typedef typename boost::fusion::result_of::find_if_s >::type not_there_iter; + typedef typename boost::fusion::result_of::find_if >::type short_iter; + typedef typename boost::fusion::result_of::find_if >::type float_iter; + typedef typename boost::fusion::result_of::find_if >::type not_there_iter; - // find_if_s of a segmented data structure returns generic + // find_if of a segmented data structure returns generic // segmented iterators - short_iter si = fusion::find_if_s >(tree); - float_iter fi = fusion::find_if_s >(tree); + short_iter si = fusion::find_if >(tree); + float_iter fi = fusion::find_if >(tree); // they behave like ordinary Fusion iterators ... BOOST_TEST((*si == short('d'))); BOOST_TEST((*fi == float(1))); // Searching for something that's not there should return the end iterator. - not_there_iter nti = fusion::find_if_s >(tree); + not_there_iter nti = fusion::find_if >(tree); BOOST_TEST((nti == fusion::end(tree))); } diff --git a/test/sequence/segmented_iterator_range.cpp b/test/sequence/segmented_iterator_range.cpp index 4f75d592..55d9e33b 100644 --- a/test/sequence/segmented_iterator_range.cpp +++ b/test/sequence/segmented_iterator_range.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -43,16 +43,16 @@ process_tree(Tree const &tree) using namespace fusion; using mpl::_; - typedef typename boost::fusion::result_of::find_if_s >::type short_iter; - typedef typename boost::fusion::result_of::find_if_s >::type float_iter; + typedef typename boost::fusion::result_of::find_if >::type short_iter; + typedef typename boost::fusion::result_of::find_if >::type float_iter; typedef iterator_range slice_t; BOOST_STATIC_ASSERT(traits::is_segmented::value); - // find_if_s of a segmented data structure returns generic + // find_if of a segmented data structure returns generic // segmented iterators - short_iter si = find_if_s >(tree); - float_iter fi = find_if_s >(tree); + short_iter si = find_if >(tree); + float_iter fi = find_if >(tree); // If you put them in an iterator range, the range // is automatically a segmented data structure.