fix doc example typo
[boost.git] / boost / fusion / algorithm / iteration / ext_ / for_each_s.hpp
blob9e571d0fe125027c06cedff78575a68b4ced3f04
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>
16 // fwd declarations
17 namespace boost { namespace fusion
19 template <typename Sequence, typename F>
20 void
21 for_each_s(Sequence& seq, F const& f);
23 template <typename Sequence, typename F>
24 void
25 for_each_s(Sequence const& seq, F const& f);
28 namespace boost { namespace fusion { namespace detail
30 template<typename F>
31 struct for_each_s_bind
33 explicit for_each_s_bind(F const &f)
34 : f_(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_);
48 private:
49 F const &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);
63 }}}
65 namespace boost { namespace fusion
67 namespace result_of
69 template <typename Sequence, typename F>
70 struct for_each_s
72 typedef void type;
76 template <typename Sequence, typename F>
77 inline void
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>
84 inline void
85 for_each_s(Sequence const& seq, F const& f)
87 detail::for_each_s(seq, f, traits::is_segmented<Sequence>());
91 #endif