|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r73899 - in trunk: boost/fusion/algorithm/iteration boost/fusion/algorithm/iteration/detail boost/fusion/algorithm/iteration/ext_ libs/fusion/test/algorithm
From: eric_at_[hidden]
Date: 2011-08-18 18:10:00
Author: eric_niebler
Date: 2011-08-18 18:09:59 EDT (Thu, 18 Aug 2011)
New Revision: 73899
URL: http://svn.boost.org/trac/boost/changeset/73899
Log:
make for_each aware of segments
Added:
trunk/boost/fusion/algorithm/iteration/detail/segmented_for_each.hpp
- copied, changed from r73898, /trunk/boost/fusion/algorithm/iteration/ext_/for_each_s.hpp
trunk/boost/fusion/algorithm/iteration/for_each_fwd.hpp (contents, props changed)
Removed:
trunk/boost/fusion/algorithm/iteration/ext_/for_each_s.hpp
Text files modified:
trunk/boost/fusion/algorithm/iteration/detail/for_each.hpp | 12 ++++++++++--
trunk/boost/fusion/algorithm/iteration/detail/segmented_for_each.hpp | 32 +++++++-------------------------
trunk/boost/fusion/algorithm/iteration/for_each.hpp | 14 ++++++--------
trunk/libs/fusion/test/algorithm/segmented_for_each.cpp | 4 ++--
4 files changed, 25 insertions(+), 37 deletions(-)
Modified: trunk/boost/fusion/algorithm/iteration/detail/for_each.hpp
==============================================================================
--- trunk/boost/fusion/algorithm/iteration/detail/for_each.hpp (original)
+++ trunk/boost/fusion/algorithm/iteration/detail/for_each.hpp 2011-08-18 18:09:59 EDT (Thu, 18 Aug 2011)
@@ -13,6 +13,7 @@
#include <boost/fusion/iterator/next.hpp>
#include <boost/fusion/iterator/deref.hpp>
#include <boost/fusion/iterator/distance.hpp>
+#include <boost/fusion/support/category_of.hpp>
#include <boost/mpl/bool.hpp>
namespace boost { namespace fusion {
@@ -36,7 +37,7 @@
template <typename Sequence, typename F, typename Tag>
inline void
- for_each(Sequence& seq, F const& f, Tag)
+ for_each_dispatch(Sequence& seq, F const& f, Tag)
{
detail::for_each_linear(
fusion::begin(seq)
@@ -117,12 +118,19 @@
template <typename Sequence, typename F>
inline void
- for_each(Sequence& seq, F const& f, random_access_traversal_tag)
+ for_each_dispatch(Sequence& seq, F const& f, random_access_traversal_tag)
{
typedef typename result_of::begin<Sequence>::type begin;
typedef typename result_of::end<Sequence>::type end;
for_each_unrolled<result_of::distance<begin, end>::type::value>::call(fusion::begin(seq), f);
}
+
+ template <typename Sequence, typename F>
+ inline void
+ for_each(Sequence& seq, F const& f, mpl::false_) // unsegmented implementation
+ {
+ detail::for_each_dispatch(seq, f, typename traits::category_of<Sequence>::type());
+ }
}}}
Copied: trunk/boost/fusion/algorithm/iteration/detail/segmented_for_each.hpp (from r73898, /trunk/boost/fusion/algorithm/iteration/ext_/for_each_s.hpp)
==============================================================================
--- /trunk/boost/fusion/algorithm/iteration/ext_/for_each_s.hpp (original)
+++ trunk/boost/fusion/algorithm/iteration/detail/segmented_for_each.hpp 2011-08-18 18:09:59 EDT (Thu, 18 Aug 2011)
@@ -4,11 +4,12 @@
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_FOR_EACH_S_HPP_INCLUDED)
-#define BOOST_FUSION_FOR_EACH_S_HPP_INCLUDED
+#if !defined(BOOST_FUSION_SEGMENTED_FOR_EACH_HPP_INCLUDED)
+#define BOOST_FUSION_SEGMENTED_FOR_EACH_HPP_INCLUDED
+#include <boost/mpl/bool.hpp>
#include <boost/fusion/support/void.hpp>
-#include <boost/fusion/algorithm/iteration/for_each.hpp>
+#include <boost/fusion/algorithm/iteration/for_each_fwd.hpp>
#include <boost/fusion/support/segmented_fold_until.hpp>
namespace boost { namespace fusion { namespace detail
@@ -35,32 +36,13 @@
}
};
};
-}}}
-
-namespace boost { namespace fusion
-{
- namespace result_of
- {
- template <typename Sequence, typename F>
- struct for_each_s
- {
- typedef void type;
- };
- }
template <typename Sequence, typename F>
inline void
- for_each_s(Sequence& seq, F const& f)
+ for_each(Sequence& seq, F const& f, mpl::true_) // segmented implementation
{
- fusion::segmented_fold_until(seq, void_(), detail::segmented_for_each_fun<F>(f));
+ fusion::segmented_fold_until(seq, void_(), segmented_for_each_fun<F>(f));
}
-
- template <typename Sequence, typename F>
- inline void
- for_each_s(Sequence const& seq, F const& f)
- {
- fusion::segmented_fold_until(seq, void_(), detail::segmented_for_each_fun<F>(f));
- }
-}}
+}}}
#endif
Deleted: trunk/boost/fusion/algorithm/iteration/ext_/for_each_s.hpp
==============================================================================
--- trunk/boost/fusion/algorithm/iteration/ext_/for_each_s.hpp 2011-08-18 18:09:59 EDT (Thu, 18 Aug 2011)
+++ (empty file)
@@ -1,66 +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_FOR_EACH_S_HPP_INCLUDED)
-#define BOOST_FUSION_FOR_EACH_S_HPP_INCLUDED
-
-#include <boost/fusion/support/void.hpp>
-#include <boost/fusion/algorithm/iteration/for_each.hpp>
-#include <boost/fusion/support/segmented_fold_until.hpp>
-
-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 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 void_();
- }
- };
- };
-}}}
-
-namespace boost { namespace fusion
-{
- namespace result_of
- {
- template <typename Sequence, typename F>
- struct for_each_s
- {
- typedef void type;
- };
- }
-
- template <typename Sequence, typename F>
- inline void
- for_each_s(Sequence& seq, F const& f)
- {
- fusion::segmented_fold_until(seq, void_(), detail::segmented_for_each_fun<F>(f));
- }
-
- template <typename Sequence, typename F>
- inline void
- for_each_s(Sequence const& seq, F const& f)
- {
- fusion::segmented_fold_until(seq, void_(), detail::segmented_for_each_fun<F>(f));
- }
-}}
-
-#endif
Modified: trunk/boost/fusion/algorithm/iteration/for_each.hpp
==============================================================================
--- trunk/boost/fusion/algorithm/iteration/for_each.hpp (original)
+++ trunk/boost/fusion/algorithm/iteration/for_each.hpp 2011-08-18 18:09:59 EDT (Thu, 18 Aug 2011)
@@ -9,11 +9,11 @@
#define BOOST_FUSION_FOR_EACH_20070527_0943
#include <boost/fusion/algorithm/iteration/detail/for_each.hpp>
+#include <boost/fusion/algorithm/iteration/detail/segmented_for_each.hpp>
+#include <boost/fusion/support/is_segmented.hpp>
-#include <boost/fusion/support/category_of.hpp>
-
-namespace boost { namespace fusion {
-
+namespace boost { namespace fusion
+{
namespace result_of
{
template <typename Sequence, typename F>
@@ -23,20 +23,18 @@
};
}
- struct random_access_traversal_tag;
-
template <typename Sequence, typename F>
inline void
for_each(Sequence& seq, F const& f)
{
- detail::for_each(seq, f, typename traits::category_of<Sequence>::type());
+ detail::for_each(seq, f, typename traits::is_segmented<Sequence>::type());
}
template <typename Sequence, typename F>
inline void
for_each(Sequence const& seq, F const& f)
{
- detail::for_each(seq, f, typename traits::category_of<Sequence>::type());
+ detail::for_each(seq, f, typename traits::is_segmented<Sequence>::type());
}
}}
Added: trunk/boost/fusion/algorithm/iteration/for_each_fwd.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/fusion/algorithm/iteration/for_each_fwd.hpp 2011-08-18 18:09:59 EDT (Thu, 18 Aug 2011)
@@ -0,0 +1,27 @@
+/*=============================================================================
+ 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_FOR_EACH_FWD_HPP_INCLUDED)
+#define BOOST_FUSION_FOR_EACH_FWD_HPP_INCLUDED
+
+namespace boost { namespace fusion
+{
+ namespace result_of
+ {
+ template <typename Sequence, typename F>
+ struct for_each;
+ }
+
+ template <typename Sequence, typename F>
+ void
+ for_each(Sequence& seq, F const& f);
+
+ template <typename Sequence, typename F>
+ void
+ for_each(Sequence const& seq, F const& f);
+}}
+
+#endif
Modified: trunk/libs/fusion/test/algorithm/segmented_for_each.cpp
==============================================================================
--- trunk/libs/fusion/test/algorithm/segmented_for_each.cpp (original)
+++ trunk/libs/fusion/test/algorithm/segmented_for_each.cpp 2011-08-18 18:09:59 EDT (Thu, 18 Aug 2011)
@@ -7,7 +7,7 @@
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
-#include <boost/fusion/algorithm/iteration/ext_/for_each_s.hpp>
+#include <boost/fusion/algorithm/iteration/for_each.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include "../sequence/tree.hpp"
@@ -26,7 +26,7 @@
using namespace boost::fusion;
{
- for_each_s(
+ for_each(
make_tree(
make_vector(double(0),'B')
, make_tree(
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