Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74430 - in sandbox/SOC/2009/fusion/boost/fusion: algorithm/iteration/detail algorithm/query/detail container/list container/map container/set container/vector include iterator iterator/detail support support/internal view/iterator_range/detail
From: mr.chr.schmidt_at_[hidden]
Date: 2011-09-17 02:37:55


Author: cschmidt
Date: 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
New Revision: 74430
URL: http://svn.boost.org/trac/boost/changeset/74430

Log:
Fusion: updates
Added:
   sandbox/SOC/2009/fusion/boost/fusion/algorithm/iteration/detail/fold_segmented.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/algorithm/iteration/detail/for_each_segmented.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/algorithm/query/detail/find_if_segmented.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/algorithm/query/detail/find_segmented.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/container/list/as_list.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/container/map/as_map.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/container/set/as_set.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/container/vector/as_vector.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/include/adt.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/include/basic_iterator.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/include/enable_comparison.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/include/is_segmented.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/include/limits.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/include/segmented_iterator.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/include/segments.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/iterator/detail/next_segmented_impl.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/iterator/detail/segment_sequence.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/iterator/detail/segmented_equal_to.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/iterator/detail/segmented_iterator.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/iterator/segmented_iterator.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/support/internal/segmented_fold_until.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/support/internal/segmented_fold_until_impl.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/support/is_segmented.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/view/iterator_range/detail/is_segmented_impl.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/view/iterator_range/detail/segmented_iterator_range.hpp (contents, props changed)
   sandbox/SOC/2009/fusion/boost/fusion/view/iterator_range/detail/segments_impl.hpp (contents, props changed)

Added: sandbox/SOC/2009/fusion/boost/fusion/algorithm/iteration/detail/fold_segmented.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/algorithm/iteration/detail/fold_segmented.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,56 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_FUSION_ALGORITHM_ITERATION_DETAIL_FOLD_SEGMENTED_HPP
+#define BOOST_FUSION_ALGORITHM_ITERATION_DETAIL_FOLD_SEGMENTED_HPP
+
+#include <boost/fusion/support/internal/segmented_fold_until.hpp>
+
+namespace boost { namespace fusion { namespace detail
+{
+ template <typename Fun>
+ struct segmented_fold_fun
+ {
+ explicit segmented_fold_fun(Fun const& f)
+ : fun(f)
+ {}
+
+ Fun fun;
+
+ template <typename Sequence, typename State, typename Context>
+ struct apply
+ {
+ typedef typename result_of::fold<Sequence, State, Fun>::type type;
+ typedef mpl::true_ continue_type;
+
+ static type call(Sequence& seq, State const& state, Context const&, segmented_fold_fun const& fun)
+ {
+ return fusion::fold(seq, state, fun.fun);
+ }
+ };
+ };
+
+ template <typename Sequence, typename State, typename Fun>
+ struct result_of_fold<Sequence, State, Fun, true>
+ {
+ typedef typename
+ result_of::segmented_fold_until<
+ Sequence,
+ State,
+ segmented_fold_fun<typename remove_reference<Fun>::type>
+ >::type
+ type;
+
+ static type
+ call(State state, Sequence seq, Fun fun)
+ {
+ return fusion::segmented_fold_until(seq, state, segmented_fold_fun<typename remove_reference<Fun>::type>(fun));
+ }
+ };
+}}}
+
+#endif

Added: sandbox/SOC/2009/fusion/boost/fusion/algorithm/iteration/detail/for_each_segmented.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/algorithm/iteration/detail/for_each_segmented.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,64 @@
+/*==============================================================================
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_FUSION_ALGORITHM_ITERATION_DETAIL_FOR_EACH_SEGMENTED_HPP
+#define BOOST_FUSION_ALGORITHM_ITERATION_DETAIL_FOR_EACH_SEGMENTED_HPP
+
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/void.hpp>
+#include <boost/fusion/support/void.hpp>
+#include <boost/fusion/support/internal/segmented_fold_until.hpp>
+
+namespace boost { namespace fusion
+{
+ template<typename Seq, typename F>
+ void
+ for_each(BOOST_FUSION_R_ELSE_CLREF(Seq) seq,
+ BOOST_FUSION_RREF_ELSE_OBJ(F) f);
+
+#ifdef BOOST_FUSION_NO_RVALUE_REFERENCES
+ template<typename Seq, typename F>
+ void
+ for_each(Seq& seq,F f);
+#endif
+}}
+
+namespace boost { namespace fusion { namespace detail
+{
+ template <typename Fun>
+ struct segmented_for_each_fun
+ {
+ explicit segmented_for_each_fun(Fun const& f)
+ : fun(f)
+ {}
+
+ Fun const& fun;
+
+ template <typename Sequence, typename State, typename Context>
+ struct apply
+ {
+ typedef mpl::void_ type;
+ typedef mpl::true_ continue_type;
+
+ static type call(Sequence& seq, State const&, Context const&, segmented_for_each_fun const& fun)
+ {
+ fusion::for_each(seq, fun.fun);
+ return type();
+ }
+ };
+ };
+
+ template<typename SeqRef, typename F>
+ void
+ for_each(SeqRef seq, F const& f, mpl::true_) // segmented implementation
+ {
+ fusion::segmented_fold_until(seq, mpl::void_(), segmented_for_each_fun<F>(f));
+ }
+}}}
+
+
+#endif

Added: sandbox/SOC/2009/fusion/boost/fusion/algorithm/query/detail/find_if_segmented.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/algorithm/query/detail/find_if_segmented.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,126 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_FUSION_ALGORITHM_QUERY_DETAIL_FIND_IF_SEGMENTED_HPP
+#define BOOST_FUSION_ALGORITHM_QUERY_DETAIL_FIND_IF_SEGMENTED_HPP
+
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/identity.hpp>
+#include <boost/fusion/iterator/equal_to.hpp>
+#include <boost/fusion/sequence/intrinsic/end.hpp>
+#include <boost/fusion/support/internal/segmented_fold_until.hpp>
+
+namespace boost { namespace fusion
+{
+ namespace result_of
+ {
+ template<typename Seq, typename Pred>
+ struct find_if;
+ }
+
+ template<typename Pred, typename Seq>
+ typename result_of::find_if<BOOST_FUSION_R_ELSE_CLREF(Seq), Pred>::type
+ find_if(BOOST_FUSION_R_ELSE_CLREF(Seq) seq);
+
+#ifdef BOOST_FUSION_NO_RVALUE_REFERENCES
+ template<typename Pred, typename Seq>
+ BOOST_FUSION_EXPLICIT_TEMPLATE_NON_CONST_ARG_OVERLOAD(
+ result_of::find_if<,Seq,&,Pred>)
+ find_if(Seq& seq);
+#endif
+}}
+
+namespace boost { namespace fusion
+{
+ namespace result_of
+ {
+ template<typename Seq, typename T>
+ struct find;
+ }
+
+ template<typename T, typename Seq>
+ typename result_of::find<BOOST_FUSION_R_ELSE_CLREF(Seq), T>::type
+ find(BOOST_FUSION_R_ELSE_CLREF(Seq) seq);
+
+#ifdef BOOST_FUSION_NO_RVALUE_REFERENCES
+ template<typename T, typename Seq>
+ BOOST_FUSION_EXPLICIT_TEMPLATE_NON_CONST_ARG_OVERLOAD(
+ result_of::find<,Seq,&, T>)
+ find(Seq& seq);
+#endif
+}}
+
+namespace boost { namespace fusion { namespace detail
+{
+ template <typename Pred>
+ struct find_if_segmented_fun
+ {
+ template <typename Sequence, typename State, typename Context>
+ struct apply
+ {
+ typedef
+ typename result_of::find_if<Sequence, Pred>::type
+ iterator_type;
+
+ typedef
+ typename result_of::equal_to<
+ iterator_type
+ , typename result_of::end<Sequence>::type
+ >::type
+ continue_type;
+
+ typedef
+ typename mpl::eval_if<
+ continue_type
+ , mpl::identity<State>
+ , result_of::make_segmented_iterator<
+ iterator_type
+ , Context
+ >
+ >::type
+ type;
+
+ static type call(Sequence& seq, State const&state, Context const& context, find_if_segmented_fun)
+ {
+ return call_impl(seq, state, context, continue_type());
+ }
+
+ static type call_impl(Sequence&, State const&state, Context const&, mpl::true_)
+ {
+ return state;
+ }
+
+ static type call_impl(Sequence& seq, State const&, Context const& context, mpl::false_)
+ {
+ return fusion::make_segmented_iterator(fusion::find_if<Pred>(seq), context);
+ }
+ };
+ };
+
+ template <typename Sequence, typename Pred>
+ struct find_if_segmented
+ {
+ typedef
+ typename result_of::segmented_fold_until<
+ Sequence
+ , typename result_of::end<Sequence>::type
+ , find_if_segmented_fun<Pred>
+ >::type
+ type;
+
+ static type
+ call(Sequence& seq)
+ {
+ return fusion::segmented_fold_until(
+ seq
+ , fusion::end(seq)
+ , find_if_segmented_fun<Pred>());
+ }
+ };
+}}}
+
+#endif

Added: sandbox/SOC/2009/fusion/boost/fusion/algorithm/query/detail/find_segmented.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/algorithm/query/detail/find_segmented.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,105 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_FUSION_ALGORITHM_QUERY_DETAIL_FIND_SEGMENTED_HPP
+#define BOOST_FUSION_ALGORITHM_QUERY_DETAIL_FIND_SEGMENTED_HPP
+
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/identity.hpp>
+#include <boost/fusion/iterator/equal_to.hpp>
+#include <boost/fusion/sequence/intrinsic/end.hpp>
+#include <boost/fusion/support/internal/segmented_fold_until.hpp>
+
+namespace boost { namespace fusion
+{
+ namespace result_of
+ {
+ template<typename Seq, typename T>
+ struct find;
+ }
+
+ template<typename T, typename Seq>
+ typename result_of::find<BOOST_FUSION_R_ELSE_CLREF(Seq), T>::type
+ find(BOOST_FUSION_R_ELSE_CLREF(Seq) seq);
+
+#ifdef BOOST_FUSION_NO_RVALUE_REFERENCES
+ template<typename T, typename Seq>
+ BOOST_FUSION_EXPLICIT_TEMPLATE_NON_CONST_ARG_OVERLOAD(
+ result_of::find<,Seq,&, T>)
+ find(Seq& seq);
+#endif
+}}
+
+namespace boost { namespace fusion { namespace detail
+{
+ template <typename T>
+ struct segmented_find_fun
+ {
+ template <typename Sequence, typename State, typename Context>
+ struct apply
+ {
+ typedef
+ typename result_of::find<Sequence, T>::type
+ iterator_type;
+
+ typedef
+ typename result_of::equal_to<
+ iterator_type
+ , typename result_of::end<Sequence>::type
+ >::type
+ continue_type;
+
+ typedef
+ typename mpl::eval_if<
+ continue_type
+ , mpl::identity<State>
+ , result_of::make_segmented_iterator<
+ iterator_type
+ , Context
+ >
+ >::type
+ type;
+
+ static type call(Sequence& seq, State const&state, Context const& context, segmented_find_fun)
+ {
+ return call_impl(seq, state, context, continue_type());
+ }
+
+ static type call_impl(Sequence&, State const&state, Context const&, mpl::true_)
+ {
+ return state;
+ }
+
+ static type call_impl(Sequence& seq, State const&, Context const& context, mpl::false_)
+ {
+ return fusion::make_segmented_iterator(fusion::find<T>(seq), context);
+ }
+ };
+ };
+
+ template <typename Sequence, typename T>
+ struct find_segmented
+ {
+ typedef
+ typename result_of::segmented_fold_until<
+ Sequence
+ , typename result_of::end<Sequence>::type
+ , segmented_find_fun<T>
+ >::type
+ type;
+
+ static type call(Sequence& seq)
+ {
+ return fusion::segmented_fold_until(
+ seq
+ , fusion::end(seq)
+ , detail::segmented_find_fun<T>());
+ }
+ };
+}}}
+
+#endif

Added: sandbox/SOC/2009/fusion/boost/fusion/container/list/as_list.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/container/list/as_list.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,13 @@
+/*==============================================================================
+ Copyright (c) 2011 Christopher Schmidt
+
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_FUSION_CONTAINER_LIST_AS_LIST_HPP
+#define BOOST_FUSION_CONTAINER_LIST_AS_LIST_HPP
+
+#include <boost/fusion/container/list/convert.hpp>
+
+#endif

Added: sandbox/SOC/2009/fusion/boost/fusion/container/map/as_map.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/container/map/as_map.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,13 @@
+/*==============================================================================
+ Copyright (c) 2011 Christopher Schmidt
+
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_FUSION_CONTAINER_MAP_AS_MAP_HPP
+#define BOOST_FUSION_CONTAINER_MAP_AS_MAP_HPP
+
+#include <boost/fusion/container/map/convert.hpp>
+
+#endif

Added: sandbox/SOC/2009/fusion/boost/fusion/container/set/as_set.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/container/set/as_set.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,13 @@
+/*==============================================================================
+ Copyright (c) 2011 Christopher Schmidt
+
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_FUSION_CONTAINER_SET_AS_SET_HPP
+#define BOOST_FUSION_CONTAINER_SEt_AS_SET_HPP
+
+#include <boost/fusion/container/set/convert.hpp>
+
+#endif

Added: sandbox/SOC/2009/fusion/boost/fusion/container/vector/as_vector.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/container/vector/as_vector.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,13 @@
+/*==============================================================================
+ Copyright (c) 2011 Christopher Schmidt
+
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_FUSION_CONTAINER_VECTOR_AS_VECTOR_HPP
+#define BOOST_FUSION_CONTAINER_VECTOR_AS_VECTOR_HPP
+
+#include <boost/fusion/container/vector/convert.hpp>
+
+#endif

Added: sandbox/SOC/2009/fusion/boost/fusion/include/adt.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/include/adt.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,8 @@
+/*==============================================================================
+ <Generated via libs/fusion/scripts/generate-includes.el>
+
+ 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)
+==============================================================================*/
+
+#include <boost/fusion/adapted/adt.hpp>

Added: sandbox/SOC/2009/fusion/boost/fusion/include/basic_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/include/basic_iterator.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,8 @@
+/*==============================================================================
+ <Generated via libs/fusion/scripts/generate-includes.el>
+
+ 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)
+==============================================================================*/
+
+#include <boost/fusion/iterator/basic_iterator.hpp>

Added: sandbox/SOC/2009/fusion/boost/fusion/include/enable_comparison.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/include/enable_comparison.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,8 @@
+/*==============================================================================
+ <Generated via libs/fusion/scripts/generate-includes.el>
+
+ 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)
+==============================================================================*/
+
+#include <boost/fusion/sequence/comparison/enable_comparison.hpp>

Added: sandbox/SOC/2009/fusion/boost/fusion/include/is_segmented.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/include/is_segmented.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,8 @@
+/*==============================================================================
+ <Generated via libs/fusion/scripts/generate-includes.el>
+
+ 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)
+==============================================================================*/
+
+#include <boost/fusion/support/is_segmented.hpp>

Added: sandbox/SOC/2009/fusion/boost/fusion/include/limits.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/include/limits.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,13 @@
+/*==============================================================================
+ <Generated via libs/fusion/scripts/generate-includes.el>
+
+ 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)
+==============================================================================*/
+
+#include <boost/fusion/container/list/limits.hpp>
+#include <boost/fusion/container/map/limits.hpp>
+#include <boost/fusion/container/set/limits.hpp>
+#include <boost/fusion/container/vector/limits.hpp>
+#include <boost/fusion/functional/adapter/limits.hpp>
+#include <boost/fusion/functional/invocation/limits.hpp>

Added: sandbox/SOC/2009/fusion/boost/fusion/include/segmented_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/include/segmented_iterator.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,8 @@
+/*==============================================================================
+ <Generated via libs/fusion/scripts/generate-includes.el>
+
+ 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)
+==============================================================================*/
+
+#include <boost/fusion/iterator/segmented_iterator.hpp>

Added: sandbox/SOC/2009/fusion/boost/fusion/include/segments.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/include/segments.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,8 @@
+/*==============================================================================
+ <Generated via libs/fusion/scripts/generate-includes.el>
+
+ 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)
+==============================================================================*/
+
+#include <boost/fusion/sequence/intrinsic/segments.hpp>

Added: sandbox/SOC/2009/fusion/boost/fusion/iterator/detail/next_segmented_impl.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/iterator/detail/next_segmented_impl.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,255 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_FUSION_ITERATOR_DETAIL_NEXT_SEGMENTED_IMPL_HPP
+#define BOOST_FUSION_ITERATOR_DETAIL_NEXT_SEGMENTED_IMPL_HPP
+
+#include <boost/type_traits/add_const.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/fusion/iterator/equal_to.hpp>
+#include <boost/fusion/container/list/list_fwd.hpp>
+#include <boost/fusion/iterator/next.hpp>
+#include <boost/fusion/iterator/deref.hpp>
+
+namespace boost { namespace fusion
+{
+ template <typename First, typename Second>
+ struct iterator_range;
+
+ template <typename Context>
+ struct segmented_iterator;
+
+ namespace detail
+ {
+ template <typename Sequence, typename Stack>
+ struct segmented_begin_impl;
+
+ //bool is_invalid(stack)
+ //{
+ // return empty(car(stack));
+ //}
+
+ template <typename Stack>
+ struct is_invalid
+ : result_of::equal_to<
+ typename Stack::car_type::begin_type,
+ typename Stack::car_type::end_type
+ >
+ {};
+
+ ////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)
+ //{
+ // return cons(iterator_range(next(begin(car(stack))), end(car(stack))), cdr(stack));
+ //}
+
+ template <typename Stack>
+ struct pop_front_car
+ {
+ typedef
+ iterator_range<
+ typename result_of::next<
+ typename Stack::car_type::begin_type
+ >::type
+ , typename Stack::car_type::end_type
+ >
+ car_type;
+
+ typedef
+ cons<car_type, typename Stack::cdr_type>
+ type;
+
+ static type call(Stack const & stack)
+ {
+ return type(
+ car_type(fusion::next(stack.car.first), stack.car.last),
+ stack.cdr);
+ }
+ };
+
+ template <
+ typename Stack,
+ typename Next = typename pop_front_car<Stack>::type,
+ bool IsInvalid = is_invalid<Next>::value,
+ int StackSize = Stack::size::value>
+ struct segmented_next_impl_recurse;
+
+ // Handle the case where the top of the stack has no usable
+ //auto segmented_next_impl_recurse3(stack)
+ //{
+ // if (size(stack) == 1)
+ // return cons(iterator_range(end(car(stack)), end(car(stack))), nil);
+ // else
+ // return segmented_next_impl_recurse(stack.cdr);
+ //}
+
+ template <
+ typename Stack,
+ int StackSize = Stack::size::value>
+ struct segmented_next_impl_recurse3
+ {
+ typedef segmented_next_impl_recurse<typename Stack::cdr_type> impl;
+ typedef typename impl::type type;
+
+ static type call(Stack const & stack)
+ {
+ return impl::call(stack.cdr);
+ }
+ };
+
+ template <typename Stack>
+ struct segmented_next_impl_recurse3<Stack, 1>
+ {
+ typedef typename Stack::car_type::end_type end_type;
+ typedef iterator_range<end_type, end_type> range_type;
+ typedef cons<range_type> type;
+
+ static type call(Stack const & stack)
+ {
+ return type(range_type(stack.car.last, stack.car.last));
+ }
+ };
+
+ //auto segmented_next_impl_recurse2(stack)
+ //{
+ // auto res = segmented_begin_impl(front(car(stack)), stack);
+ // if (is_invalid(res))
+ // return segmented_next_impl_recurse3(stack);
+ // else
+ // return res;
+ //}
+
+ template <
+ typename Stack,
+ typename Sequence =
+ typename remove_reference<
+ typename add_const<
+ typename result_of::deref<
+ typename Stack::car_type::begin_type
+ >::type
+ >::type
+ >::type,
+ typename Result =
+ typename segmented_begin_impl<Sequence, Stack>::type,
+ bool IsInvalid =
+ is_invalid<Result>::value>
+ struct segmented_next_impl_recurse2
+ {
+ typedef segmented_next_impl_recurse3<Stack> impl;
+ typedef typename impl::type type;
+
+ static type call(Stack const & stack)
+ {
+ return impl::call(stack);
+ }
+ };
+
+ template <typename Stack, typename Sequence, typename Result>
+ struct segmented_next_impl_recurse2<Stack, Sequence, Result, false>
+ {
+ typedef Result type;
+
+ static type call(Stack const & stack)
+ {
+ return segmented_begin_impl<Sequence, Stack>::call(*stack.car.first, stack);
+ }
+ };
+
+ //auto segmented_next_impl_recurse(stack)
+ //{
+ // auto next = pop_front_car(stack);
+ // if (is_invalid(next))
+ // if (1 == size(stack))
+ // return next;
+ // else
+ // return segmented_next_impl_recurse(cdr(stack));
+ // else
+ // return segmented_next_impl_recurse2(next)
+ //}
+
+ template <typename Stack, typename Next, bool IsInvalid, int StackSize>
+ struct segmented_next_impl_recurse
+ {
+ typedef
+ typename segmented_next_impl_recurse<typename Stack::cdr_type>::type
+ type;
+
+ static type call(Stack const& stack)
+ {
+ return segmented_next_impl_recurse<typename Stack::cdr_type>::call(stack.cdr);
+ }
+ };
+
+ template <typename Stack, typename Next>
+ struct segmented_next_impl_recurse<Stack, Next, true, 1>
+ {
+ typedef Next type;
+
+ static type call(Stack const & stack)
+ {
+ return pop_front_car<Stack>::call(stack);
+ }
+ };
+
+ template <typename Stack, typename Next, int StackSize>
+ struct segmented_next_impl_recurse<Stack, Next, false, StackSize>
+ {
+ typedef segmented_next_impl_recurse2<Next> impl;
+ typedef typename impl::type type;
+
+ static type call(Stack const & stack)
+ {
+ return impl::call(pop_front_car<Stack>::call(stack));
+ }
+ };
+
+ //auto segmented_next_impl(stack)
+ //{
+ // // 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));
+ // else
+ // return next;
+ //}
+
+ template <
+ typename Stack,
+ typename Next = typename pop_front_car<Stack>::type,
+ bool IsInvalid = is_invalid<Next>::value>
+ struct segmented_next_impl_aux
+ {
+ typedef segmented_next_impl_recurse<typename Stack::cdr_type> impl;
+ typedef typename impl::type type;
+
+ static type call(Stack const & stack)
+ {
+ return impl::call(stack.cdr);
+ }
+ };
+
+ template <typename Stack, typename Next>
+ struct segmented_next_impl_aux<Stack, Next, false>
+ {
+ typedef Next type;
+
+ static type call(Stack const & stack)
+ {
+ return pop_front_car<Stack>::call(stack);
+ }
+ };
+
+ template <typename Stack>
+ struct segmented_next_impl
+ : segmented_next_impl_aux<Stack>
+ {};
+ }
+}}
+
+#endif

Added: sandbox/SOC/2009/fusion/boost/fusion/iterator/detail/segment_sequence.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/iterator/detail/segment_sequence.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,91 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_FUSION_ITERATOR_DETAIL_SEGMENT_SEQUENECE_HPP
+#define BOOST_FUSION_ITERATOR_DETAIL_SEGMENT_SEQUENECE_HPP
+
+#include <boost/mpl/bool.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/fusion/support/tag_of.hpp>
+#include <boost/fusion/support/is_view.hpp>
+#include <boost/fusion/support/category_of.hpp>
+
+namespace boost { namespace fusion { namespace traits
+{
+ template<typename>
+ struct category_of;
+}}}
+
+namespace boost { namespace fusion { namespace detail
+{
+ struct segment_sequence_tag {};
+
+ // Here, Sequence is a sequence of ranges (which may or may not be
+ // segmented).
+ template<typename Sequence>
+ struct segment_sequence
+ {
+ typedef fusion_sequence_tag tag;
+ typedef segment_sequence_tag fusion_tag;
+ typedef typename traits::is_view<Sequence>::type is_view;
+ typedef typename traits::category_of<Sequence>::type category;
+ typedef Sequence sequence_type;
+ sequence_type sequence;
+
+ explicit segment_sequence(Sequence const & seq)
+ : sequence(seq)
+ {}
+ };
+}
+
+namespace extension
+{
+ template<typename Tag>
+ struct is_sequence_impl;
+
+ template<>
+ struct is_sequence_impl<detail::segment_sequence_tag>
+ {
+ template<typename Sequence>
+ struct apply
+ : mpl::true_
+ {};
+ };
+
+ template<typename Tag>
+ struct is_segmented_impl;
+
+ template<>
+ struct is_segmented_impl<detail::segment_sequence_tag>
+ {
+ template<typename Sequence>
+ struct apply
+ : mpl::true_
+ {};
+ };
+
+ template<typename Tag>
+ struct segments_impl;
+
+ template<>
+ struct segments_impl<detail::segment_sequence_tag>
+ {
+ template<typename Seq>
+ struct apply
+ {
+ typedef typename detail::remove_reference<Seq>::type seq;
+ typedef typename seq::sequence_type type;
+
+ static type call(Seq seq)
+ {
+ return seq.sequence;
+ }
+ };
+ };
+}}}
+
+#endif

Added: sandbox/SOC/2009/fusion/boost/fusion/iterator/detail/segmented_equal_to.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/iterator/detail/segmented_equal_to.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,42 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_FUSION_ITERATOR_DETAIL_SEGMENTED_EQUAL_TO_IMPL_HPP
+#define BOOST_FUSION_ITERATOR_DETAIL_SEGMENTED_EQUAL_TO_IMPL_HPP
+
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/fusion/iterator/equal_to.hpp>
+
+namespace boost { namespace fusion
+{
+ struct nil;
+
+ namespace detail
+ {
+ template <typename Stack1, typename Stack2>
+ struct segmented_equal_to
+ : mpl::and_<
+ segmented_equal_to<
+ typename Stack1::cdr_type,
+ typename Stack2::cdr_type
+ >
+ , result_of::equal_to<
+ typename Stack1::car_type::begin_type,
+ typename Stack2::car_type::begin_type
+ >
+ >
+ {};
+
+ template <>
+ struct segmented_equal_to<fusion::nil, fusion::nil>
+ : mpl::true_
+ {};
+ }
+}}
+
+#endif

Added: sandbox/SOC/2009/fusion/boost/fusion/iterator/detail/segmented_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/iterator/detail/segmented_iterator.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,147 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_FUSION_SEGMENTED_ITERATOR_DETAIL_SEGMENTED_ITERATOR_HPP
+#define BOOST_FUSION_SEGMENTED_ITERATOR_DETAIL_SEGMENTED_ITERATOR_HPP
+
+#include <boost/mpl/bool.hpp>
+#include <boost/fusion/iterator/iterator_facade.hpp>
+#include <boost/fusion/iterator/deref.hpp>
+#include <boost/fusion/iterator/deref_data.hpp>
+#include <boost/fusion/iterator/key_of.hpp>
+#include <boost/fusion/iterator/value_of.hpp>
+#include <boost/fusion/iterator/value_of_data.hpp>
+#include <boost/fusion/iterator/detail/segmented_equal_to.hpp>
+
+namespace boost { namespace fusion
+{
+ struct nil;
+ struct forward_traversal_tag;
+
+ namespace detail
+ {
+ template <typename Stack>
+ struct segmented_next_impl;
+ }
+
+ // A segmented iterator wraps a "context", which is a cons list
+ // of ranges, the frontmost is range over values and the rest
+ // are ranges over internal segments.
+ template <typename Context>
+ struct segmented_iterator
+ : iterator_facade<segmented_iterator<Context>, forward_traversal_tag>
+ {
+ explicit segmented_iterator(Context const& ctx)
+ : context(ctx)
+ {}
+
+ //auto deref(it)
+ //{
+ // return deref(begin(car(it.context)))
+ //}
+ template <typename It>
+ struct deref
+ {
+ typedef typename detail::remove_reference<It>::type it;
+ typedef
+ typename result_of::deref<
+ typename it::context_type::car_type::begin_type
+ >::type
+ type;
+
+ static type call(It it)
+ {
+ return *it.context.car.first;
+ }
+ };
+
+ //auto deref_data(it)
+ //{
+ // return deref_data(begin(car(it.context)))
+ //}
+ template <typename It>
+ struct deref_data
+ {
+ typedef typename detail::remove_reference<It>::type it;
+ typedef
+ typename result_of::deref_data<
+ typename It::context_type::car_type::begin_type
+ >::type
+ type;
+
+ static type call(It it)
+ {
+ return fusion::deref_data(it.context.car.first);
+ }
+ };
+
+ //auto key_of(it)
+ //{
+ // return key_of(begin(car(it.context)))
+ //}
+ template <typename It>
+ struct key_of
+ : result_of::key_of<typename detail::remove_reference<It>::type::context_type::car_type::begin_type>
+ {};
+
+ //auto value_of(it)
+ //{
+ // return value_of(begin(car(it.context)))
+ //}
+ template <typename It>
+ struct value_of
+ : result_of::value_of<typename detail::remove_reference<It>::type::context_type::car_type::begin_type>
+ {};
+
+ //auto value_of_data(it)
+ //{
+ // return value_of_data(begin(car(it.context)))
+ //}
+ template <typename It>
+ struct value_of_data
+ : result_of::value_of_data<typename detail::remove_reference<It>::type::context_type::car_type::begin_type>
+ {};
+
+ // Compare all the segment iterators in each stack, starting with
+ // the bottom-most.
+ template <
+ typename It1
+ , typename It2
+ , int Size1 = detail::remove_reference<It1>::type::context_type::size::value
+ , int Size2 = detail::remove_reference<It2>::type::context_type::size::value
+ >
+ struct equal_to
+ : mpl::false_
+ {};
+
+ template <typename It1, typename It2, int Size>
+ struct equal_to<It1, It2, Size, Size>
+ : detail::segmented_equal_to<
+ typename detail::remove_reference<It1>::type::context_type
+ , typename detail::remove_reference<It2>::type::context_type
+ >
+ {};
+
+ template <typename It>
+ struct next
+ {
+ typedef detail::segmented_next_impl<typename detail::remove_reference<It>::type::context_type> impl;
+ typedef segmented_iterator<typename impl::type> type;
+
+ static type call(It it)
+ {
+ return type(impl::call(it.context));
+ }
+ };
+
+ typedef Context context_type;
+ context_type context;
+ };
+
+}}
+
+#endif

Added: sandbox/SOC/2009/fusion/boost/fusion/iterator/segmented_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/iterator/segmented_iterator.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,14 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_FUSION_ITERATOR_SEGMENTED_ITERATOR_HPP
+#define BOOST_FUSION_ITERATOR_SEGMENTED_ITERATOR_HPP
+
+#include <boost/fusion/iterator/detail/segmented_iterator.hpp>
+#include <boost/fusion/iterator/detail/next_segmented_impl.hpp>
+
+#endif

Added: sandbox/SOC/2009/fusion/boost/fusion/support/internal/segmented_fold_until.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/support/internal/segmented_fold_until.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,74 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_FUSION_SUPPORT_INTERNAL_SEGMENTED_FOLD_UNTIL_HPP
+#define BOOST_FUSION_SUPPORT_INTERNAL_SEGMENTED_FOLD_UNTIL_HPP
+
+#include <boost/type_traits/is_const.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <boost/fusion/support/internal/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>
+#include <boost/fusion/sequence/intrinsic/empty.hpp>
+#include <boost/fusion/container/list/cons.hpp>
+
+namespace boost { namespace fusion
+{
+ //auto segmented_fold_until(seq, state, fun)
+ //{
+ // return first(segmented_fold_until_impl(seq, state, nil, fun));
+ //}
+
+ namespace result_of
+ {
+ template <typename Sequence, typename State, typename Fun>
+ struct segmented_fold_until
+ {
+ typedef
+ detail::segmented_fold_until_impl<
+ Sequence
+ , State
+ , fusion::nil
+ , Fun
+ >
+ filter;
+
+ typedef
+ typename filter::type
+ type;
+ };
+ }
+
+ template <typename Sequence, typename State, typename Fun>
+ typename
+ lazy_disable_if<
+ is_const<Sequence>
+ , result_of::segmented_fold_until<Sequence, State, Fun>
+ >::type
+ segmented_fold_until(Sequence& seq, State const& state, Fun const& fun)
+ {
+ typedef
+ typename result_of::segmented_fold_until<Sequence, State, Fun>::filter
+ filter;
+
+ return filter::call(seq, state, fusion::nil(), fun);
+ }
+
+ template <typename Sequence, typename State, typename Fun>
+ typename result_of::segmented_fold_until<Sequence const, State, Fun>::type
+ segmented_fold_until(Sequence const& seq, State const& state, Fun const& fun)
+ {
+ typedef
+ typename result_of::segmented_fold_until<Sequence const, State, Fun>::filter
+ filter;
+
+ return filter::call(seq, state, fusion::nil(), fun);
+ }
+}}
+
+#endif

Added: sandbox/SOC/2009/fusion/boost/fusion/support/internal/segmented_fold_until_impl.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/support/internal/segmented_fold_until_impl.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,429 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_FUSION_SUPPORT_INTERNAL_SEGMENTED_FOLD_UNTIL_IMPL_HPP
+#define BOOST_FUSION_SUPPORT_INTERNAL_SEGMENTED_FOLD_UNTIL_IMPL_HPP
+
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/identity.hpp>
+#include <boost/utility/result_of.hpp>
+#include <boost/type_traits/add_const.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+
+#include <boost/fusion/container/list/list_fwd.hpp>
+#include <boost/fusion/sequence/intrinsic/begin.hpp>
+#include <boost/fusion/sequence/intrinsic/end.hpp>
+#include <boost/fusion/sequence/intrinsic/empty.hpp>
+#include <boost/fusion/iterator/equal_to.hpp>
+#include <boost/fusion/iterator/deref.hpp>
+#include <boost/fusion/iterator/next.hpp>
+#include <boost/fusion/support/is_segmented.hpp>
+#include <boost/fusion/sequence/intrinsic/segments.hpp>
+
+// fun(seq, state, context)
+// seq: a non-segmented range
+// state: the state of the fold so far
+// context: the path to the current range
+//
+// returns: (state', fcontinue)
+
+namespace boost { namespace fusion
+{
+ template <typename First, typename Last>
+ struct iterator_range;
+
+ template <typename Context>
+ struct segmented_iterator;
+
+ namespace result_of
+ {
+ template<typename>
+ struct begin;
+
+ template<typename>
+ struct end;
+
+ template <typename Cur, typename Context>
+ struct make_segmented_iterator
+ {
+ typedef
+ iterator_range<
+ Cur
+ , typename result_of::end<
+ typename remove_reference<
+ typename add_const<
+ typename result_of::deref<
+ typename Context::car_type::begin_type
+ >::type
+ >::type
+ >::type
+ >::type
+ >
+ range_type;
+
+ typedef
+ segmented_iterator<cons<range_type, Context> >
+ type;
+ };
+ }
+
+ template<typename Seq>
+ typename lazy_enable_if<
+ traits::is_sequence<BOOST_FUSION_R_ELSE_CLREF(Seq)>
+ , result_of::begin<BOOST_FUSION_R_ELSE_CLREF(Seq)>
+ >::type
+ begin(BOOST_FUSION_R_ELSE_CLREF(Seq) seq);
+
+#ifdef BOOST_FUSION_NO_RVALUE_REFERENCES
+ template<typename Seq>
+ typename lazy_enable_if<
+ traits::is_sequence<Seq&>
+ , result_of::begin<Seq&>
+ >::type
+ begin(Seq& seq);
+#endif
+
+ template<typename Seq>
+ typename lazy_enable_if<
+ traits::is_sequence<BOOST_FUSION_R_ELSE_CLREF(Seq)>
+ , result_of::end<BOOST_FUSION_R_ELSE_CLREF(Seq)>
+ >::type
+ end(BOOST_FUSION_R_ELSE_CLREF(Seq) seq);
+
+#ifdef BOOST_FUSION_NO_RVALUE_REFERENCES
+ template<typename Seq>
+ typename lazy_enable_if<
+ traits::is_sequence<Seq&>
+ , result_of::end<Seq&>
+ >::type
+ end(Seq& seq);
+#endif
+
+ template <typename Cur, typename Context>
+ typename result_of::make_segmented_iterator<Cur, Context>::type
+ make_segmented_iterator(Cur const& cur, Context const& context)
+ {
+ typedef result_of::make_segmented_iterator<Cur, Context> impl_type;
+ typedef typename impl_type::type type;
+ typedef typename impl_type::range_type range_type;
+ return type(cons<range_type, Context>(range_type(cur, fusion::end(*context.car.first)), context));
+ }
+
+ namespace detail
+ {
+ template <
+ typename Begin
+ , typename End
+ , typename State
+ , typename Context
+ , typename Fun
+ , bool IsEmpty
+ >
+ struct segmented_fold_until_iterate_skip_empty;
+
+ template <
+ typename Begin
+ , typename End
+ , typename State
+ , typename Context
+ , typename Fun
+ , bool IsDone = result_of::equal_to<Begin, End>::type::value
+ >
+ struct segmented_fold_until_iterate;
+
+ template <
+ typename Sequence
+ , typename State
+ , typename Context
+ , typename Fun
+ , bool IsSegmented = traits::is_segmented<Sequence>::type::value
+ >
+ struct segmented_fold_until_impl;
+
+ template <typename Segments, typename State, typename Context, typename Fun>
+ struct segmented_fold_until_on_segments;
+
+ //auto push_context(cur, end, context)
+ //{
+ // return push_back(context, segment_sequence(iterator_range(cur, end)));
+ //}
+
+ template <typename Cur, typename End, typename Context>
+ struct push_context
+ {
+ typedef iterator_range<Cur, End> range_type;
+ typedef cons<range_type, Context> type;
+
+ static type call(Cur const& cur, End const& end, Context const& context)
+ {
+ return cons<range_type, Context>(range_type(cur, end), context);
+ }
+ };
+
+ //auto make_segmented_iterator(cur, end, context)
+ //{
+ // return segmented_iterator(push_context(cur, end, context));
+ //}
+ //
+ //auto segmented_fold_until_impl(seq, state, context, fun)
+ //{
+ // if (is_segmented(seq))
+ // {
+ // segmented_fold_until_on_segments(segments(seq), state, context, fun);
+ // }
+ // else
+ // {
+ // return fun(seq, state, context);
+ // }
+ //}
+
+ template <
+ 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<Sequence>::type
+ >::type
+ >::type
+ , State
+ , Context
+ , Fun
+ >
+ impl;
+
+ typedef typename impl::type type;
+ typedef typename impl::continue_type continue_type;
+
+ static type call(Sequence& seq, State const& state, Context const& context, Fun const& fun)
+ {
+ return impl::call(fusion::segments(seq), state, context, fun);
+ }
+ };
+
+ template <
+ typename Sequence
+ , typename State
+ , typename Context
+ , typename Fun
+ >
+ struct segmented_fold_until_impl<Sequence, State, Context, Fun, false>
+ {
+ typedef
+ typename Fun::template apply<Sequence, State, Context>
+ apply_type;
+
+ typedef typename apply_type::type type;
+ typedef typename apply_type::continue_type continue_type;
+
+ static type call(Sequence& seq, State const& state, Context const& context, Fun const& fun)
+ {
+ return apply_type::call(seq, state, context, fun);
+ }
+ };
+
+ //auto segmented_fold_until_on_segments(segs, state, context, fun)
+ //{
+ // auto cur = begin(segs), end = end(segs);
+ // for (; cur != end; ++cur)
+ // {
+ // if (empty(*cur))
+ // continue;
+ // auto context` = push_context(cur, end, context);
+ // state = segmented_fold_until_impl(*cur, state, context`, fun);
+ // if (!second(state))
+ // return state;
+ // }
+ //}
+
+ template <typename Apply>
+ struct continue_wrap
+ {
+ typedef typename Apply::continue_type type;
+ };
+
+ template <typename Begin, typename End, typename State, typename Context, typename Fun, bool IsEmpty>
+ struct segmented_fold_until_iterate_skip_empty
+ {
+ // begin != end and !empty(*begin)
+ typedef
+ push_context<Begin, End, Context>
+ push_context_impl;
+
+ typedef
+ typename push_context_impl::type
+ next_context_type;
+
+ typedef
+ segmented_fold_until_impl<
+ typename remove_reference<
+ typename add_const<
+ typename result_of::deref<Begin>::type
+ >::type
+ >::type
+ , State
+ , next_context_type
+ , Fun
+ >
+ fold_recurse_impl;
+
+ typedef
+ typename fold_recurse_impl::type
+ next_state_type;
+
+ typedef
+ segmented_fold_until_iterate<
+ typename result_of::next<Begin>::type
+ , End
+ , next_state_type
+ , Context
+ , Fun
+ >
+ next_iteration_impl;
+
+ typedef
+ typename mpl::eval_if<
+ typename fold_recurse_impl::continue_type
+ , next_iteration_impl
+ , mpl::identity<next_state_type>
+ >::type
+ type;
+
+ typedef
+ typename mpl::eval_if<
+ typename fold_recurse_impl::continue_type
+ , continue_wrap<next_iteration_impl>
+ , mpl::identity<mpl::false_>
+ >::type
+ continue_type;
+
+ 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 fold_recurse_impl::continue_type());
+ }
+
+ 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);
+ }
+
+ 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);
+ }
+ };
+
+ template <typename Begin, typename End, typename State, typename Context, typename Fun>
+ struct segmented_fold_until_iterate_skip_empty<Begin, End, State, Context, Fun, true>
+ {
+ typedef
+ segmented_fold_until_iterate<
+ typename result_of::next<Begin>::type
+ , End
+ , State
+ , Context
+ , Fun
+ >
+ impl;
+
+ typedef typename impl::type type;
+ typedef typename impl::continue_type continue_type;
+
+ 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);
+ }
+ };
+
+ template <typename Begin, typename End, typename State, typename Context, typename Fun, bool IsDone>
+ struct segmented_fold_until_iterate
+ {
+ typedef
+ typename result_of::empty<
+ typename remove_reference<
+ typename result_of::deref<Begin>::type
+ >::type
+ >::type
+ empty_type;
+
+ typedef
+ segmented_fold_until_iterate_skip_empty<Begin, End, State, Context, Fun, empty_type::value>
+ impl;
+
+ typedef typename impl::type type;
+ typedef typename impl::continue_type continue_type;
+
+ 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);
+ }
+ };
+
+ template <typename Begin, typename End, typename State, typename Context, typename Fun>
+ struct segmented_fold_until_iterate<Begin, End, State, Context, Fun, true>
+ {
+ typedef State type;
+ typedef mpl::true_ continue_type;
+
+ static type call(Begin const&, End const&, State const& state
+ , Context const&, Fun const&)
+ {
+ return state;
+ }
+ };
+
+ template <typename Segments, typename State, typename Context, typename Fun>
+ struct segmented_fold_until_on_segments
+ {
+ typedef
+ segmented_fold_until_iterate<
+ typename result_of::begin<Segments>::type
+ , typename result_of::end<Segments>::type
+ , State
+ , Context
+ , Fun
+ >
+ impl;
+
+ typedef typename impl::type type;
+ typedef typename impl::continue_type continue_type;
+
+ static type call(Segments& segs, State const& state, Context const& context, Fun const& fun)
+ {
+ return impl::call(fusion::begin(segs), fusion::end(segs), state, context, fun);
+ }
+ };
+ }
+}}
+
+#endif

Added: sandbox/SOC/2009/fusion/boost/fusion/support/is_segmented.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/support/is_segmented.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,41 @@
+/*==============================================================================
+ Copyright (c) 2006 Eric Niebler
+ Copyright (c) 2011 Christopher Schmidt
+
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_FUSION_SUPPORT_IS_SEGMENTED_HPP
+#define BOOST_FUSION_SUPPORT_IS_SEGMENTED_HPP
+
+#include <boost/fusion/support/internal/base.hpp>
+#include <boost/fusion/support/tag_of.hpp>
+#include <boost/mpl/bool.hpp>
+
+namespace boost { namespace fusion
+{
+ namespace extension
+ {
+ template<typename>
+ struct is_segmented_impl
+ {
+ template<typename>
+ struct apply
+ : mpl::false_
+ {};
+ };
+ }
+
+ namespace traits
+ {
+ template<typename T>
+ struct is_segmented
+ : extension::is_segmented_impl<
+ typename traits::tag_of<T>::type
+ >::template apply<T>
+ {};
+ }
+}}
+
+#endif

Added: sandbox/SOC/2009/fusion/boost/fusion/view/iterator_range/detail/is_segmented_impl.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/view/iterator_range/detail/is_segmented_impl.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,75 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_FUSION_ITERATOR_RANGE_DETAIL_IS_SEGMENTED_HPP
+#define BOOST_FUSION_ITERATOR_RANGE_DETAIL_IS_SEGMENTED_HPP
+
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/bool.hpp>
+
+namespace boost { namespace fusion
+{
+ struct iterator_range_tag;
+
+ template <typename Context>
+ struct segmented_iterator;
+
+ namespace extension
+ {
+ template <typename Tag>
+ struct is_segmented_impl;
+
+ // An iterator_range of segmented_iterators is segmented
+ template <>
+ struct is_segmented_impl<iterator_range_tag>
+ {
+ private:
+ template <typename Iterator>
+ struct is_segmented_iterator
+ : mpl::false_
+ {};
+
+ template <typename Iterator>
+ struct is_segmented_iterator<Iterator &>
+ : is_segmented_iterator<Iterator>
+ {};
+
+#ifndef BOOST_FUSION_NO_RVALUE_REFERENCES
+ template <typename Iterator>
+ struct is_segmented_iterator<Iterator &&>
+ : is_segmented_iterator<Iterator>
+ {};
+#endif
+
+ template <typename Iterator>
+ struct is_segmented_iterator<Iterator const>
+ : is_segmented_iterator<Iterator>
+ {};
+
+ template <typename Context>
+ struct is_segmented_iterator<segmented_iterator<Context> >
+ : mpl::true_
+ {};
+
+ public:
+ template <typename Seq>
+ struct apply
+ : is_segmented_iterator<typename detail::remove_reference<Seq>::type::begin_type>::type
+
+ {
+ typedef typename detail::remove_reference<Seq>::type seq;
+
+ BOOST_FUSION_STATIC_ASSERT(
+ is_segmented_iterator<typename seq::begin_type>::value
+ ==
+ is_segmented_iterator<typename seq::end_type>::value)
+ };
+ };
+ }
+}}
+
+#endif

Added: sandbox/SOC/2009/fusion/boost/fusion/view/iterator_range/detail/segmented_iterator_range.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/view/iterator_range/detail/segmented_iterator_range.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,506 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_FUSION_ITERATOR_RANGE_DETAIL_SEGMENTED_ITERATOR_RANGE_HPP
+#define BOOST_FUSION_ITERATOR_RANGE_DETAIL_SEGMENTED_ITERATOR_RANGE_HPP
+
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/add_const.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/fusion/support/tag_of.hpp>
+#include <boost/fusion/sequence/intrinsic/begin.hpp>
+#include <boost/fusion/sequence/intrinsic/end.hpp>
+#include <boost/fusion/iterator/next.hpp>
+#include <boost/fusion/iterator/deref.hpp>
+#include <boost/fusion/sequence/intrinsic/segments.hpp>
+#include <boost/fusion/algorithm/transformation/push_back.hpp>
+#include <boost/fusion/algorithm/transformation/push_front.hpp>
+#include <boost/fusion/iterator/equal_to.hpp>
+#include <boost/fusion/container/list/detail/reverse_cons.hpp>
+#include <boost/fusion/iterator/detail/segment_sequence.hpp>
+
+// Invariants:
+// - Each segmented iterator has a stack
+// - Each value in the stack is an iterator range
+// - The range at the top of the stack points to values
+// - All other ranges point to ranges
+// - The front of each range in the stack (besides the
+// topmost) is the range above it
+
+namespace boost { namespace fusion
+{
+ template <typename First, typename Last>
+ struct iterator_range;
+}}
+
+namespace boost { namespace fusion { namespace detail
+{
+ //auto make_segment_sequence_front(stack_begin)
+ //{
+ // switch (size(stack_begin))
+ // {
+ // case 1:
+ // return nil;
+ // case 2:
+ // // car(cdr(stack_begin)) is a range over values.
+ // assert(end(front(car(stack_begin))) == end(car(cdr(stack_begin))));
+ // return iterator_range(begin(car(cdr(stack_begin))), end(front(car(stack_begin))));
+ // default:
+ // // car(cdr(stack_begin)) is a range over segments. We replace the
+ // // front with a view that is restricted.
+ // assert(end(segments(front(car(stack_begin)))) == end(car(cdr(stack_begin))));
+ // return segment_sequence(
+ // push_front(
+ // // The following could be a segment_sequence. It then gets wrapped
+ // // in a single_view, and push_front puts it in a join_view with the
+ // // following iterator_range.
+ // iterator_range(next(begin(car(cdr(stack_begin)))), end(segments(front(car(stack_begin))))),
+ // make_segment_sequence_front(cdr(stack_begin))));
+ // }
+ //}
+
+ template <typename Stack, std::size_t Size = Stack::size::value>
+ struct make_segment_sequence_front
+ {
+ // assert(end(segments(front(car(stack_begin)))) == end(car(cdr(stack_begin))));
+ BOOST_FUSION_MPL_ASSERT((
+ result_of::equal_to<
+ typename result_of::end<
+ typename remove_reference<
+ typename add_const<
+ typename result_of::segments<
+ typename remove_reference<
+ typename add_const<
+ typename result_of::deref<
+ typename Stack::car_type::begin_type
+ >::type
+ >::type
+ >::type
+ >::type
+ >::type
+ >::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<
+ typename remove_reference<
+ typename add_const<
+ typename result_of::segments<
+ typename remove_reference<
+ typename add_const<
+ typename result_of::deref<
+ typename Stack::car_type::begin_type
+ >::type
+ >::type
+ >::type
+ >::type
+ >::type
+ >::type
+ >::type
+ >
+ rest_type;
+
+ typedef
+ make_segment_sequence_front<typename Stack::cdr_type>
+ recurse;
+
+ typedef
+ segment_sequence<
+ typename result_of::push_front<
+ rest_type const
+ , typename recurse::type
+ >::type
+ >
+ type;
+
+ static type call(Stack const& stack)
+ {
+ //return segment_sequence(
+ // push_front(
+ // iterator_range(next(begin(car(cdr(stack_begin)))), end(segments(front(car(stack_begin))))),
+ // 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)));
+ }
+ };
+
+ template <typename Stack>
+ struct make_segment_sequence_front<Stack, 2>
+ {
+ // assert(end(front(car(stack_begin))) == end(car(cdr(stack_begin))));
+ BOOST_FUSION_MPL_ASSERT((
+ result_of::equal_to<
+ typename result_of::end<
+ typename remove_reference<
+ typename add_const<
+ typename result_of::deref<
+ typename Stack::car_type::begin_type
+ >::type
+ >::type
+ >::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 remove_reference<
+ typename add_const<
+ typename result_of::deref<
+ typename Stack::car_type::begin_type
+ >::type
+ >::type
+ >::type
+ >::type
+ >
+ type;
+
+ static type call(Stack const& stack)
+ {
+ // return iterator_range(begin(car(cdr(stack_begin))), end(front(car(stack_begin))));
+ return type(stack.cdr.car.first, fusion::end(*stack.car.first));
+ }
+ };
+
+ template <typename Stack>
+ struct make_segment_sequence_front<Stack, 1>
+ {
+ typedef typename Stack::cdr_type type; // nil
+
+ static type call(Stack const &stack)
+ {
+ return stack.cdr;
+ }
+ };
+
+ //auto make_segment_sequence_back(stack_end)
+ //{
+ // switch (size(stack_end))
+ // {
+ // case 1:
+ // return nil;
+ // case 2:
+ // // car(cdr(stack_back)) is a range over values.
+ // assert(end(front(car(stack_end))) == end(car(cdr(stack_end))));
+ // return iterator_range(begin(front(car(stack_end))), begin(car(cdr(stack_end))));
+ // default:
+ // // car(cdr(stack_begin)) is a range over segments. We replace the
+ // // back with a view that is restricted.
+ // assert(end(segments(front(car(stack_end)))) == end(car(cdr(stack_end))));
+ // return segment_sequence(
+ // push_back(
+ // iterator_range(begin(segments(front(car(stack_end)))), begin(car(cdr(stack_end)))),
+ // make_segment_sequence_back(cdr(stack_end))));
+ // }
+ //}
+
+ template <typename Stack, std::size_t Size = Stack::size::value>
+ struct make_segment_sequence_back
+ {
+ // assert(end(segments(front(car(stack_begin)))) == end(car(cdr(stack_begin))));
+ BOOST_FUSION_MPL_ASSERT((
+ result_of::equal_to<
+ typename result_of::end<
+ typename remove_reference<
+ typename add_const<
+ typename result_of::segments<
+ typename remove_reference<
+ typename add_const<
+ typename result_of::deref<
+ typename Stack::car_type::begin_type
+ >::type
+ >::type
+ >::type
+ >::type
+ >::type
+ >::type
+ >::type
+ , typename Stack::cdr_type::car_type::end_type
+ >))
+
+ typedef
+ iterator_range<
+ typename result_of::begin<
+ typename remove_reference<
+ typename add_const<
+ typename result_of::segments<
+ typename remove_reference<
+ typename add_const<
+ typename result_of::deref<
+ typename Stack::car_type::begin_type
+ >::type
+ >::type
+ >::type
+ >::type
+ >::type
+ >::type
+ >::type
+ , typename Stack::cdr_type::car_type::begin_type
+ >
+ rest_type;
+
+ typedef
+ make_segment_sequence_back<typename Stack::cdr_type>
+ recurse;
+
+ typedef
+ segment_sequence<
+ typename result_of::push_back<
+ rest_type const
+ , typename recurse::type
+ >::type
+ >
+ type;
+
+ static type call(Stack const& stack)
+ {
+ // return segment_sequence(
+ // push_back(
+ // iterator_range(begin(segments(front(car(stack_end)))), begin(car(cdr(stack_end)))),
+ // 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)));
+ }
+ };
+
+ template <typename Stack>
+ struct make_segment_sequence_back<Stack, 2>
+ {
+ // assert(end(front(car(stack_end))) == end(car(cdr(stack_end))));
+ BOOST_FUSION_MPL_ASSERT((
+ result_of::equal_to<
+ typename result_of::end<
+ typename remove_reference<
+ typename add_const<
+ typename result_of::deref<
+ typename Stack::car_type::begin_type
+ >::type
+ >::type
+ >::type
+ >::type
+ , typename Stack::cdr_type::car_type::end_type
+ >))
+
+ typedef
+ iterator_range<
+ typename result_of::begin<
+ typename remove_reference<
+ typename add_const<
+ typename result_of::deref<
+ typename Stack::car_type::begin_type
+ >::type
+ >::type
+ >::type
+ >::type
+ , typename Stack::cdr_type::car_type::begin_type
+ >
+ type;
+
+ static type call(Stack const& stack)
+ {
+ // return iterator_range(begin(front(car(stack_end))), begin(car(cdr(stack_end))));
+ return type(fusion::begin(*stack.car.first), stack.cdr.car.first);
+ }
+ };
+
+ template <typename Stack>
+ struct make_segment_sequence_back<Stack, 1>
+ {
+ typedef typename Stack::cdr_type type; // nil
+
+ static type call(Stack const& stack)
+ {
+ return stack.cdr;
+ }
+ };
+
+ //auto make_segmented_range_reduce(stack_begin, stack_end)
+ //{
+ // if (size(stack_begin) == 1 && size(stack_end) == 1)
+ // {
+ // return segment_sequence(
+ // single_view(
+ // iterator_range(begin(car(stack_begin)), begin(car(stack_end)))));
+ // }
+ // else
+ // {
+ // // We are in the case where both begin_stack and/or end_stack have
+ // // more than one element. Throw away any part of the tree where
+ // // begin and end refer to the same segment.
+ // if (begin(car(stack_begin)) == begin(car(stack_end)))
+ // {
+ // return make_segmented_range_reduce(cdr(stack_begin), cdr(stack_end));
+ // }
+ // else
+ // {
+ // // We are in the case where begin_stack and end_stack (a) have
+ // // more than one element each, and (b) they point to different
+ // // segments. We must construct a segmented sequence.
+ // return segment_sequence(
+ // push_back(
+ // push_front(
+ // iterator_range(
+ // fusion::next(begin(car(stack_begin))),
+ // begin(car(stack_end))), // a range of (possibly segmented) ranges.
+ // make_segment_sequence_front(stack_begin)), // should be a (possibly segmented) range.
+ // make_segment_sequence_back(stack_end))); // should be a (possibly segmented) range.
+ // }
+ // }
+ //}
+
+ template <
+ 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 =
+ result_of::equal_to<
+ typename StackBegin::car_type::begin_type
+ , typename StackEnd::car_type::begin_type
+ >::type::value>
+ struct make_segmented_range_reduce2
+ {
+ typedef
+ iterator_range<
+ typename result_of::next<
+ typename StackBegin::car_type::begin_type
+ >::type
+ , typename StackEnd::car_type::begin_type
+ >
+ rest_type;
+
+ typedef
+ segment_sequence<
+ typename result_of::push_back<
+ typename result_of::push_front<
+ rest_type const
+ , typename make_segment_sequence_front<StackBegin>::type
+ >::type const
+ , typename make_segment_sequence_back<StackEnd>::type
+ >::type
+ >
+ type;
+
+ static type call(StackBegin stack_begin, StackEnd stack_end)
+ {
+ //return segment_sequence(
+ // push_back(
+ // push_front(
+ // iterator_range(
+ // fusion::next(begin(car(stack_begin))),
+ // begin(car(stack_end))), // a range of (possibly segmented) ranges.
+ // make_segment_sequence_front(stack_begin)), // should be a (possibly segmented) range.
+ // make_segment_sequence_back(stack_end))); // should be a (possibly segmented) range.
+ return type(
+ fusion::push_back(
+ fusion::push_front(
+ rest_type(fusion::next(stack_begin.car.first), stack_end.car.first)
+ , make_segment_sequence_front<StackBegin>::call(stack_begin))
+ , make_segment_sequence_back<StackEnd>::call(stack_end)));
+ }
+ };
+
+ template <typename StackBegin, typename StackEnd>
+ struct make_segmented_range_reduce2<StackBegin, StackEnd, true>
+ {
+ typedef
+ make_segmented_range_reduce<
+ typename StackBegin::cdr_type
+ , typename StackEnd::cdr_type
+ >
+ impl;
+
+ typedef
+ typename impl::type
+ type;
+
+ static type call(StackBegin stack_begin, StackEnd stack_end)
+ {
+ return impl::call(stack_begin.cdr, stack_end.cdr);
+ }
+ };
+
+ template <typename StackBegin, typename StackEnd, int StackBeginSize, int StackEndSize>
+ struct make_segmented_range_reduce
+ : make_segmented_range_reduce2<StackBegin, StackEnd>
+ {};
+
+ template <typename StackBegin, typename StackEnd>
+ struct make_segmented_range_reduce<StackBegin, StackEnd, 1, 1>
+ {
+ typedef
+ iterator_range<
+ typename StackBegin::car_type::begin_type
+ , typename StackEnd::car_type::begin_type
+ >
+ range_type;
+
+ typedef
+ single_view<range_type>
+ segment_type;
+
+ typedef
+ segment_sequence<segment_type>
+ type;
+
+ static type call(StackBegin stack_begin, StackEnd stack_end)
+ {
+ //return segment_sequence(
+ // single_view(
+ // iterator_range(begin(car(stack_begin)), begin(car(stack_end)))));
+ return type(segment_type(range_type(stack_begin.car.first, stack_end.car.first)));
+ }
+ };
+
+ //auto make_segmented_range(begin, end)
+ //{
+ // return make_segmented_range_reduce(reverse(begin.context), reverse(end.context));
+ //}
+
+ template <typename Begin, typename End>
+ struct make_segmented_range
+ {
+ typedef reverse_cons<typename Begin::context_type> reverse_begin_cons;
+ typedef reverse_cons<typename End::context_type> reverse_end_cons;
+
+ typedef
+ make_segmented_range_reduce<
+ typename reverse_begin_cons::type
+ , typename reverse_end_cons::type
+ >
+ impl;
+
+ typedef typename impl::type type;
+
+ static type call(Begin const& begin, End const& end)
+ {
+ return impl::call(
+ reverse_begin_cons::call(begin.context)
+ , reverse_end_cons::call(end.context));
+ }
+ };
+
+}}}
+
+#endif

Added: sandbox/SOC/2009/fusion/boost/fusion/view/iterator_range/detail/segments_impl.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/fusion/boost/fusion/view/iterator_range/detail/segments_impl.hpp 2011-09-17 02:37:50 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,53 @@
+/*=============================================================================
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_FUSION_ITERATOR_RANGE_DETAIL_SEGMENTED_IMPL_HPP
+#define BOOST_FUSION_ITERATOR_RANGE_DETAIL_SEGMENTED_IMPL_HPP
+
+#include <boost/fusion/sequence/intrinsic/segments.hpp>
+#include <boost/fusion/support/is_segmented.hpp>
+#include <boost/fusion/view/iterator_range/detail/segmented_iterator_range.hpp>
+
+namespace boost { namespace fusion
+{
+ struct iterator_range_tag;
+
+ namespace extension
+ {
+ template <typename Tag>
+ struct segments_impl;
+
+ template <>
+ struct segments_impl<iterator_range_tag>
+ {
+ template <typename Seq>
+ struct apply
+ {
+ typedef typename detail::remove_reference<Seq>::type seq;
+ typedef
+ detail::make_segmented_range<
+ typename seq::begin_type
+ , typename seq::end_type
+ >
+ impl;
+
+ BOOST_FUSION_MPL_ASSERT((traits::is_segmented<typename impl::type>))
+
+ typedef
+ typename result_of::segments<typename impl::type>::type
+ type;
+
+ static type call(Seq seq)
+ {
+ return fusion::segments(impl::call(seq.first, seq.last));
+ }
+ };
+ };
+ }
+}}
+
+#endif


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk