]> https://gitweb.dealii.org/ - dealii.git/blob
71730abf079e0e52b293d1b322e3e2a379e4de9c
[dealii.git] /
1 /*=============================================================================
2     Copyright (c) 2009-2010 Christopher Schmidt
3     Copyright (c) 2001-2011 Joel de Guzman
4
5     Distributed under the Boost Software License, Version 1.0. (See accompanying
6     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7
8     This is an auto-generated file. Do not edit!
9 ==============================================================================*/
10 namespace boost { namespace fusion
11 {
12     namespace detail
13     {
14         template<typename State, typename It, typename F>
15         struct reverse_fold_lvalue_state
16           : boost::result_of<
17                 F(
18                 typename add_reference<typename add_const<State>::type>::type,
19                 typename fusion::result_of::deref<It>::type)
20             >
21         {};
22         template<typename Result,int N>
23         struct unrolled_reverse_fold
24         {
25             template<typename State, typename It0, typename F>
26             static Result
27             call(State const& state,It0 const& it0,F f)
28             {
29                 typedef typename
30                     result_of::prior<
31                         It0 const
32                     >::type
33                 It1;
34                 It1 it1 = fusion::prior(it0);
35                 typedef typename
36                     result_of::prior<
37                         It1
38                     >::type
39                 It2;
40                 It2 it2 = fusion::prior(it1);
41                 typedef typename
42                     result_of::prior<
43                         It2
44                     >::type
45                 It3;
46                 It3 it3 = fusion::prior(it2);
47                 typedef typename reverse_fold_lvalue_state<State,It0,F>::type State1;
48                 State1 const state1=f(state,fusion::deref(it0));
49                 typedef typename reverse_fold_lvalue_state<State1,It1,F>::type State2;
50                 State2 const state2=f(state1,fusion::deref(it1));
51                 typedef typename reverse_fold_lvalue_state<State2,It2,F>::type State3;
52                 State3 const state3=f(state2,fusion::deref(it2));
53                 return unrolled_reverse_fold<
54                     Result
55                   , N-4
56                 >::call(
57                     f(state3,fusion::deref(it3)),
58                     fusion::prior(it3),
59                     f);
60             }
61         };
62         template<typename Result>
63         struct unrolled_reverse_fold<Result,3>
64         {
65             template<typename State, typename It0, typename F>
66             static Result
67             call(State const& state,It0 const& it0,F f)
68             {
69                 typedef typename
70                     result_of::prior<
71                         It0 const
72                     >::type
73                 It1;
74                 It1 it1 = fusion::prior(it0);
75                 typedef typename
76                     result_of::prior<
77                         It1
78                     >::type
79                 It2;
80                 It2 it2 = fusion::prior(it1);
81                 typedef typename reverse_fold_lvalue_state<State,It0,F>::type State1;
82                 State1 const state1=f(state,fusion::deref(it0));
83                 typedef typename reverse_fold_lvalue_state<State1,It1,F>::type State2;
84                 State2 const state2=f(state1,fusion::deref(it1));
85                 return f(state2,fusion::deref(it2));
86             }
87         };
88         template<typename Result>
89         struct unrolled_reverse_fold<Result,2>
90         {
91             template<typename State, typename It0, typename F>
92             static Result
93             call(State const& state,It0 const& it0,F f)
94             {
95                 typedef typename reverse_fold_lvalue_state<State,It0,F>::type State1;
96                 State1 const state1=f(state,fusion::deref(it0));
97                 return f(
98                     state1,
99                     fusion::deref( fusion::prior(it0)));
100             }
101         };
102         template<typename Result>
103         struct unrolled_reverse_fold<Result,1>
104         {
105             template<typename State, typename It0, typename F>
106             static Result
107             call(State const& state,It0 const& it0,F f)
108             {
109                 return f(state,
110                     fusion::deref(it0));
111             }
112         };
113         template<typename Result>
114         struct unrolled_reverse_fold<Result,0>
115         {
116             template<typename State, typename It0, typename F>
117             static Result
118             call(State const& state,It0 const& it0, F)
119             {
120                 return static_cast<Result>(state);
121             }
122         };
123         template<typename StateRef, typename It0, typename F, int N>
124         struct result_of_unrolled_reverse_fold
125         {
126             typedef typename
127                 reverse_fold_lvalue_state<
128                     StateRef
129                   , It0 const
130                   , F
131                 >::type
132             rest1;
133             typedef typename
134                 result_of::prior<
135                     It0 const
136                 >::type
137             it1;
138             typedef typename
139                 reverse_fold_lvalue_state<
140                     rest1
141                   , it1
142                   , F
143                 >::type
144             rest2;
145             typedef typename
146                 result_of::prior<it1>::type
147             it2;
148             typedef typename
149                 reverse_fold_lvalue_state<
150                     rest2
151                   , it2
152                   , F
153                 >::type
154             rest3;
155             typedef typename
156                 result_of::prior<it2>::type
157             it3;
158             typedef typename
159                 result_of_unrolled_reverse_fold<
160                     typename reverse_fold_lvalue_state<
161                         rest3
162                       , it3
163                       , F
164                     >::type
165                   , typename result_of::prior<
166                         it3
167                     >::type
168                   , F
169                   , N-4
170                 >::type
171             type;
172         };
173         template<typename StateRef, typename It0, typename F>
174         struct result_of_unrolled_reverse_fold<
175             StateRef
176           , It0
177           , F
178           , 3
179         >
180         {
181             typedef typename
182                 reverse_fold_lvalue_state<
183                     StateRef
184                   , It0 const
185                   , F
186                 >::type
187             rest1;
188             typedef typename
189                 result_of::prior<
190                     It0 const
191                 >::type
192             it1;
193             typedef typename
194                 reverse_fold_lvalue_state<
195                     typename reverse_fold_lvalue_state<
196                         rest1
197                       , it1
198                       , F
199                     >::type
200                   , typename result_of::prior<
201                         it1 const
202                     >::type const
203                   , F
204                 >::type
205             type;
206         };
207         template<typename StateRef, typename It0, typename F>
208         struct result_of_unrolled_reverse_fold<
209             StateRef
210           , It0
211           , F
212           , 2
213         >
214           : reverse_fold_lvalue_state<
215                 typename reverse_fold_lvalue_state<
216                     StateRef
217                   , It0 const
218                   , F
219                 >::type
220               , typename result_of::prior<
221                     It0 const
222                 >::type const
223               , F
224             >
225         {};
226         template<typename StateRef, typename It0, typename F>
227         struct result_of_unrolled_reverse_fold<
228             StateRef
229           , It0
230           , F
231           , 1
232         >
233           : reverse_fold_lvalue_state<
234                 StateRef
235               , It0 const
236               , F
237             >
238         {};
239         template<typename StateRef, typename It0, typename F>
240         struct result_of_unrolled_reverse_fold<
241             StateRef
242           , It0
243           , F
244           , 0
245         >
246         {
247             typedef StateRef type;
248         };
249         template<typename StateRef, typename It0, typename F, int SeqSize>
250         struct result_of_first_unrolledreverse_fold
251         {
252             typedef typename
253                 result_of_unrolled_reverse_fold<
254                     typename boost::result_of<
255                         F(
256                             StateRef,
257                             typename fusion::result_of::deref< It0 const>::type
258                         )
259                     >::type
260                   , typename result_of::prior<
261                         It0 const
262                     >::type
263                   , F
264                   , SeqSize-1
265                 >::type
266             type;
267         };
268         template<int SeqSize, typename StateRef, typename Seq, typename F>
269         struct reverse_fold_impl
270         {
271             typedef typename
272                 result_of_first_unrolledreverse_fold<
273                     StateRef
274                   , typename fusion::result_of::prior< typename result_of::end<Seq>::type >::type
275                   , F
276                   , SeqSize
277                 >::type
278             type;
279             static type
280             call(StateRef state, Seq& seq, F f)
281             {
282                 typedef
283                     unrolled_reverse_fold<
284                         type
285                       , SeqSize
286                     >
287                 unrolled_impl;
288                 return unrolled_impl::call(
289                     state,
290                     fusion::prior( fusion::end(seq)),
291                     f);
292             }
293         };
294         template<typename StateRef, typename Seq, typename F>
295         struct reverse_fold_impl<0,StateRef,Seq,F>
296         {
297             typedef StateRef type;
298             static StateRef
299             call(StateRef state, Seq&, F)
300             {
301                 return static_cast<StateRef>(state);
302             }
303         };
304         template<typename Seq, typename State, typename F, bool IsSegmented>
305         struct result_of_reverse_fold
306           : reverse_fold_impl<
307                 result_of::size<Seq>::value
308               , typename add_reference<
309                     typename add_const<State>::type
310                 >::type
311               , Seq
312               , F
313             >
314         {};
315     }
316     namespace result_of
317     {
318         template<typename Seq, typename State, typename F>
319         struct reverse_fold
320           : detail::result_of_reverse_fold<
321                 Seq
322               , State
323               , F
324               , traits::is_segmented<Seq>::type::value
325             >
326         {};
327     }
328     template<typename Seq, typename State, typename F>
329     inline typename result_of::reverse_fold<
330         Seq
331       , State const
332       , F
333     >::type
334     reverse_fold(Seq& seq, State const& state, F f)
335     {
336         return result_of::reverse_fold<Seq,State const,F>::call(
337             state,
338             seq,
339             f);
340     }
341     template<typename Seq, typename State, typename F>
342     inline typename result_of::reverse_fold<
343         Seq const
344       , State const
345       , F
346     >::type
347     reverse_fold(Seq const& seq, State const& state, F f)
348     {
349         return result_of::reverse_fold<Seq const,State const,F>::call(
350             state,
351             seq,
352             f);
353     }
354     template<typename Seq, typename State, typename F>
355     inline typename result_of::reverse_fold<
356         Seq
357       , State const
358       , F
359     >::type
360     reverse_fold(Seq& seq, State& state, F f)
361     {
362         return result_of::reverse_fold<Seq,State,F>::call(
363             state,
364             seq,
365             f);
366     }
367     template<typename Seq, typename State, typename F>
368     inline typename result_of::reverse_fold<
369         Seq const
370       , State const
371       , F
372     >::type
373     reverse_fold(Seq const& seq, State& state, F f)
374     {
375         return result_of::reverse_fold<Seq const,State,F>::call(
376             state,
377             seq,
378             f);
379     }
380 }}

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.