~ubuntu-branches/ubuntu/trusty/deal.ii/trusty

« back to all changes in this revision

Viewing changes to contrib/boost/include/boost/fusion/algorithm/iteration/detail/for_each.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam C. Powell, IV, Adam C. Powell, IV, Denis Barbier
  • Date: 2010-07-29 13:47:01 UTC
  • mfrom: (3.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100729134701-akb8jb3stwge8tcm
Tags: 6.3.1-1
[ Adam C. Powell, IV ]
* Changed to source format 3.0 (quilt).
* Changed maintainer to debian-science with Adam Powell as uploader.
* Added source lintian overrides about Adam Powell's name.
* Added Vcs info on git repository.
* Bumped Standards-Version.
* Changed stamp-patch to patch target and fixed its application criterion.
* Moved make_dependencies and expand_instantiations to a versioned directory
  to avoid shlib package conflicts.

[ Denis Barbier ]
* New upstream release (closes: #562332).
  + Added libtbb support.
  + Forward-ported all patches.
* Updates for new PETSc version, including workaround for different versions
  of petsc and slepc.
* Add debian/watch.
* Update to debhelper 7.
* Added pdebuild patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*=============================================================================
 
2
    Copyright (c) 2001-2006 Joel de Guzman
 
3
 
 
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_05052005_1028)
 
8
#define FUSION_FOR_EACH_05052005_1028
 
9
 
 
10
#include <boost/fusion/sequence/intrinsic/begin.hpp>
 
11
#include <boost/fusion/sequence/intrinsic/end.hpp>
 
12
#include <boost/fusion/iterator/equal_to.hpp>
 
13
#include <boost/fusion/iterator/next.hpp>
 
14
#include <boost/fusion/iterator/deref.hpp>
 
15
#include <boost/fusion/iterator/distance.hpp>
 
16
#include <boost/mpl/bool.hpp>
 
17
 
 
18
namespace boost { namespace fusion {
 
19
namespace detail
 
20
{
 
21
    template <typename First, typename Last, typename F>
 
22
    inline void
 
23
    for_each_linear(First const&, Last const&, F const&, mpl::true_)
 
24
    {
 
25
    }
 
26
        
 
27
    template <typename First, typename Last, typename F>
 
28
    inline void
 
29
    for_each_linear(First const& first, Last const& last, F const& f, mpl::false_)
 
30
    {
 
31
        f(*first);
 
32
        detail::for_each_linear(fusion::next(first), last, f, 
 
33
                                result_of::equal_to<typename result_of::next<First>::type, Last>());
 
34
    }
 
35
 
 
36
 
 
37
    template <typename Sequence, typename F, typename Tag>
 
38
    inline void
 
39
    for_each(Sequence& seq, F const& f, Tag)
 
40
    {
 
41
        detail::for_each_linear(
 
42
                                fusion::begin(seq)
 
43
                                , fusion::end(seq)
 
44
                                , f
 
45
                                , result_of::equal_to<
 
46
                                typename result_of::begin<Sequence>::type
 
47
                                , typename result_of::end<Sequence>::type>());
 
48
    }
 
49
 
 
50
    template<int N>
 
51
    struct for_each_unrolled
 
52
    {
 
53
        template<typename I0, typename F>
 
54
        static void call(I0 const& i0, F const& f)
 
55
        {
 
56
            f(*i0);
 
57
            typedef typename result_of::next<I0>::type I1;
 
58
            I1 i1(fusion::next(i0));
 
59
            f(*i1);
 
60
            typedef typename result_of::next<I1>::type I2;
 
61
            I2 i2(fusion::next(i1));
 
62
            f(*i2);
 
63
            typedef typename result_of::next<I2>::type I3;
 
64
            I3 i3(fusion::next(i2));
 
65
            f(*i3);
 
66
            for_each_unrolled<N-4>::call(fusion::next(i3), f);
 
67
        }
 
68
    };
 
69
 
 
70
    template<>
 
71
    struct for_each_unrolled<3>
 
72
    {
 
73
        template<typename I0, typename F>
 
74
        static void call(I0 const& i0, F const& f)
 
75
        {
 
76
            f(*i0);
 
77
            typedef typename result_of::next<I0>::type I1;
 
78
            I1 i1(fusion::next(i0));
 
79
            f(*i1);
 
80
            typedef typename result_of::next<I1>::type I2;
 
81
            I2 i2(fusion::next(i1));
 
82
            f(*i2);
 
83
        }
 
84
    };
 
85
 
 
86
    template<>
 
87
    struct for_each_unrolled<2>
 
88
    {
 
89
        template<typename I0, typename F>
 
90
        static void call(I0 const& i0, F const& f)
 
91
        {
 
92
            f(*i0);
 
93
            typedef typename result_of::next<I0>::type I1;
 
94
            I1 i1(fusion::next(i0));
 
95
            f(*i1);
 
96
        }
 
97
    };
 
98
 
 
99
    template<>
 
100
    struct for_each_unrolled<1>
 
101
    {
 
102
        template<typename I0, typename F>
 
103
        static void call(I0 const& i0, F const& f)
 
104
        {
 
105
            f(*i0);
 
106
        }
 
107
    };
 
108
 
 
109
    template<>
 
110
    struct for_each_unrolled<0>
 
111
    {
 
112
        template<typename It, typename F>
 
113
        static void call(It const&, F const&)
 
114
        {
 
115
        }
 
116
    };
 
117
 
 
118
    template <typename Sequence, typename F>
 
119
    inline void
 
120
    for_each(Sequence& seq, F const& f, random_access_traversal_tag)
 
121
    {
 
122
        typedef typename result_of::begin<Sequence>::type begin;
 
123
        typedef typename result_of::end<Sequence>::type end;
 
124
        for_each_unrolled<result_of::distance<begin, end>::type::value>::call(fusion::begin(seq), f);
 
125
    }
 
126
}}}
 
127
 
 
128
 
 
129
#endif
 
130