1 /*=============================================================================
2 Copyright (c) 2006 Eric Niebler
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 #if !defined(FUSION_FOR_EACH_S_05022006_1027)
8 #define FUSION_FOR_EACH_S_05022006_1027
10 #include <boost/mpl/assert.hpp>
11 #include <boost/utility/enable_if.hpp>
12 #include <boost/fusion/algorithm/iteration/for_each.hpp>
13 #include <boost/fusion/sequence/intrinsic/ext_/segments.hpp>
14 #include <boost/fusion/support/ext_/is_segmented.hpp>
17 namespace boost
{ namespace fusion
19 template <typename Sequence
, typename F
>
21 for_each_s(Sequence
& seq
, F
const& f
);
23 template <typename Sequence
, typename F
>
25 for_each_s(Sequence
const& seq
, F
const& f
);
28 namespace boost
{ namespace fusion
{ namespace detail
31 struct for_each_s_bind
33 explicit for_each_s_bind(F
const &f
)
37 template<typename Sequence
>
38 void operator ()(Sequence
&seq
) const
40 fusion::for_each_s(seq
, this->f_
);
43 template<typename Sequence
>
44 void operator ()(Sequence
const &seq
) const
46 fusion::for_each_s(seq
, this->f_
);
52 template<typename Sequence
, typename F
>
53 void for_each_s(Sequence
&seq
, F
const &f
, mpl::true_
)
55 fusion::for_each_s(fusion::segments(seq
), for_each_s_bind
<F
>(f
));
58 template<typename Sequence
, typename F
>
59 void for_each_s(Sequence
&seq
, F
const &f
, mpl::false_
)
61 fusion::for_each(seq
, f
);
65 namespace boost
{ namespace fusion
69 template <typename Sequence
, typename F
>
76 template <typename Sequence
, typename F
>
78 for_each_s(Sequence
& seq
, F
const& f
)
80 detail::for_each_s(seq
, f
, traits::is_segmented
<Sequence
>());
83 template <typename Sequence
, typename F
>
85 for_each_s(Sequence
const& seq
, F
const& f
)
87 detail::for_each_s(seq
, f
, traits::is_segmented
<Sequence
>());