Ticket #7526: zip_iterator_diff.txt

File zip_iterator_diff.txt, 14.7 KB (added by claas.koehler@…, 10 years ago)

diff of the patched zip_iterator file compared to the 1.50.0 version

Line 
129,217d28
2<
3< //this should probably go to boost/tuple/tuple.hpp
4< namespace boost { namespace tuples{
5<
6< template<int I, class...Args>
7< struct element<I, std::tuple<Args...> > {
8< typedef typename std::tuple_element<I, std::tuple<Args...> >::type type;
9< };
10<
11< }}
12<
13<
14< //helper classes to work with std::tuple
15< namespace helper {
16<
17< //get head of std::tuple
18< template<class T> struct head{
19< typedef decltype( std::get<0>( std::declval<T>() ) ) type;
20< };
21<
22< //get tail of std::tuple
23< template<class T> struct tail{ typedef std::tuple<> type; };
24<
25< //specialisations allow for perfect forwarding
26< template<class T, class... Args>
27< struct tail< std::tuple<T, Args...>& >{
28<
29< typedef typename std::conditional<
30< sizeof...(Args) == 0,
31< std::tuple<>,
32< std::tuple<Args...>&
33< >::type type;
34< };
35<
36< template<class T, class... Args>
37< struct tail< std::tuple<T, Args...> const& >{
38< typedef typename std::conditional<
39< sizeof...(Args) == 0,
40< std::tuple<>,
41< std::tuple<Args...> const&
42< >::type type;
43< };
44<
45< template<class T, class... Args>
46< struct tail< std::tuple<T, Args...>&& >{
47< typedef typename std::conditional<
48< sizeof...(Args) == 0,
49< std::tuple<>,
50< std::tuple<Args...> &&
51< >::type type;
52< };
53<
54<
55< //concatenate 2 tuples
56< template<class Tuple1, class Tuple2> struct concat {
57<
58< typedef decltype( std::tuple_cat(std::declval<Tuple1>(),
59< std::declval<Tuple2>()) ) type;
60<
61< inline static type call(Tuple1&& t1, Tuple2&& t2) {
62< return std::tuple_cat( std::forward<Tuple1>(t1),
63< std::forward<Tuple2>(t2) );
64< }
65< };
66<
67<
68< //wrap mpl meta function to allow return type derivation via decltype
69< template<class F>
70< struct wrap {
71< typedef typename boost::mpl::lambda<F>::type Lambda;
72<
73<
74< template<class... Args>
75< struct result {
76< typedef typename Lambda::template apply<Args...>::type type;
77< };
78<
79< template<class... Args>
80< typename result<Args...>::type operator()(Args...)
81< {
82< return std::declval< typename result<Args...>::type >();
83< }
84< };
85<
86<
87<
88< // Apply unary functor to each member of tuple
89< template<class F,
90< class Tuple,
91< class Output= std::tuple<> >
92< struct apply
93< {
94< typedef typename std::result_of<F(typename head<Tuple>::type)>::type
95< result_type;
96<
97< typedef apply< F,
98< typename tail<Tuple>::type,
99< typename concat<Output,
100< std::tuple<result_type> >::type > next;
101<
102< typedef typename next::type type;
103<
104<
105< //function to implemnt the apply functionality
106< template<int I=0, class T>
107< static typename apply<F, Tuple>::type
108< call(F f, T&& in)
109< {
110< return concat <
111< std::tuple<result_type>,
112< typename apply<
113< F,
114< typename tail<Tuple>::type
115< >::type
116< >::call( std::tuple<result_type>( f( std::get<I>( std::forward<T>(in) ))),
117< next::template call<I+1>(f, std::forward<T>(in) ) );
118< }
119< };
120<
121< //Specialisation for empty tuples
122< template<class F, class Output>
123< struct apply< F, std::tuple<>, Output>
124< {
125< typedef Output type;
126<
127< template<int I=0, class T>
128< inline static typename std::tuple<> call(F, T) { return std::tuple<>(); }
129< };
130<
131< //Successively apply binary operator to tuple members
132< template<class Tuple,
133< class Op,
134< class State >
135< struct accumulate
136< {
137< typedef typename std::result_of<Op(typename head<Tuple>::type,
138< State)>::type result_type;
139<
140<
141< typedef accumulate< typename tail<Tuple>::type,
142< Op,
143< result_type > next;
144<
145< typedef typename next::type type;
146<
147< template<int I=0, class T>
148< static type call(T&& in, Op op, State state)
149< {
150< return next::template call<I+1>(std::forward<T>(in),
151< op,
152< op( std::get<I>(std::forward<T>(in)),
153< state ) );
154< }
155< };//accumulate
156<
157< //Specialisation for empty tuple
158< template<class Op,
159< class State >
160< struct accumulate< std::tuple<>, Op, State>
161< {
162< typedef State type;
163<
164< template<int I=0, class T>
165< static type call(T, Op, State state) { return state; }
166< };
167<
168<
169< //for each specialisation for std::tuples
170< template<size_t I = 0, typename F, typename Tuple>
171< inline typename std::enable_if< I == std::tuple_size<Tuple>::value, F>::type
172< for_each(Tuple&, F f){ return f; }
173<
174< template<size_t I = 0, typename F, typename Tuple>
175< inline typename std::enable_if< I != std::tuple_size<Tuple>::value, F>::type
176< for_each(Tuple& t, F f)
177< {
178< f( std::get<I>(t) );
179< return for_each<I+1>(t, f);
180< }
181<
182<
183<
184< }//namespace helper
185<
186<
187<
188<
189<
190<
191325,348d135
192<
193< // Specialisation for std::tuple
194< template<class... Args, class UnaryMetaFun>
195< struct tuple_meta_transform< std::tuple<Args...>, UnaryMetaFun>
196< {
197< typedef typename helper::apply< helper::wrap<UnaryMetaFun>,
198< std::tuple<Args...> const& >::type type;
199< };
200<
201< // Specialisation for std::pair
202< template<class T1, class T2, class UnaryMetaFun>
203< struct tuple_meta_transform< std::pair<T1, T2>, UnaryMetaFun>
204< {
205< typedef std::pair<
206< typename mpl::apply1<
207< typename mpl::lambda<UnaryMetaFun>::type
208< , T1
209< >::type
210< , typename mpl::apply1<
211< typename mpl::lambda<UnaryMetaFun>::type
212< , T1
213< >::type
214< > type;
215< };
216400,435d186
217< // specialisation for std::tuples
218< template<class... Args, class BinaryMetaFun, typename StartType>
219< struct tuple_meta_accumulate< std::tuple<Args...>,
220< BinaryMetaFun,
221< StartType >
222< {
223< typedef typename helper::accumulate<
224< std::tuple<Args...>,
225< helper::wrap<BinaryMetaFun>,
226< StartType
227< >::type type;
228< };
229<
230< // specialisation for std::pair
231< template<
232< typename T1
233< , typename T2
234< , class BinaryMetaFun
235< , typename StartType
236< >
237< struct tuple_meta_accumulate_impl< std::pair<T1, T2>,
238< BinaryMetaFun,
239< StartType >
240< {
241< typedef typename mpl::apply2<
242< typename mpl::lambda<BinaryMetaFun>::type,
243< mpl::identity<StartType>,
244< typename mpl::apply2<
245< typename mpl::lambda<BinaryMetaFun>::type,
246< T1,
247< T2
248< >::type
249< >::type type;
250< };
251<
252<
253469,470c220,224
254< namespace detail{
255<
256---
257> template<typename Fun>
258> tuples::null_type BOOST_TUPLE_ALGO(tuple_transform)
259> (tuples::null_type const&, Fun BOOST_TUPLE_ALGO_TERMINATOR)
260> { return tuples::null_type(); }
261>
262472,476c226,236
263< struct tuple_transform_impl {
264<
265< static typename tuple_meta_transform<Tuple, Fun>::type
266< BOOST_TUPLE_ALGO(call)(const Tuple& t, Fun f BOOST_TUPLE_ALGO_RECURSE )
267< {
268---
269> typename tuple_meta_transform<
270> Tuple
271> , Fun
272> >::type
273>
274> BOOST_TUPLE_ALGO(tuple_transform)(
275> const Tuple& t,
276> Fun f
277> BOOST_TUPLE_ALGO_RECURSE
278> )
279> {
280481,492c241,250
281<
282< return tuples::cons<
283< BOOST_DEDUCED_TYPENAME mpl::apply1<
284< Fun, BOOST_DEDUCED_TYPENAME Tuple::head_type
285< >::type
286< , transformed_tail_type
287< >(
288< f(boost::tuples::get<0>(t)),
289< tuple_transform_impl<BOOST_DEDUCED_TYPENAME Tuple::tail_type,
290< Fun>::call( t.get_tail(), f)
291< );
292< }
293---
294>
295> return tuples::cons<
296> BOOST_DEDUCED_TYPENAME mpl::apply1<
297> Fun, BOOST_DEDUCED_TYPENAME Tuple::head_type
298> >::type
299> , transformed_tail_type
300> >(
301> f(boost::tuples::get<0>(t)), tuple_transform(t.get_tail(), f)
302> );
303> }
304495,499c253,265
305< static typename tuple_meta_transform<Tuple, Fun>::type
306< call(const Tuple& t, Fun f)
307< {
308< return call_impl(t, f, 1);
309< }
310---
311> template<typename Tuple, typename Fun>
312> typename tuple_meta_transform<
313> Tuple
314> , Fun
315> >::type
316>
317> tuple_transform(
318> const Tuple& t,
319> Fun f
320> )
321> {
322> return tuple_transform_impl(t, f, 1);
323> }
324501,542d266
325< };//tuple_transform_impl
326<
327<
328< template<typename Fun>
329< struct tuple_transform_impl<tuples::null_type, Fun> {
330<
331< static tuples::null_type
332< BOOST_TUPLE_ALGO(call)(tuples::null_type const&,
333< Fun BOOST_TUPLE_ALGO_TERMINATOR)
334< {
335< return tuples::null_type();
336< }
337< };
338<
339<
340< // specialisation for std::tuples
341< template<typename...Args, typename Fun>
342< struct tuple_transform_impl <std::tuple<Args...>, Fun> {
343<
344< template<class T>
345< inline static
346< typename tuple_meta_transform< std::tuple<Args...>, Fun>::type
347< call(T&& t, Fun f )
348< {
349< return helper::apply<Fun, T&&>::template call<0>(f, std::forward<T>(t) );
350< }
351< };
352<
353< //specialisation for std::pair
354< template<typename T1, typename T2, typename Fun>
355< struct tuple_transform_impl< std::tuple<T1, T2>, Fun> {
356<
357< static typename tuple_meta_transform<std::tuple<T1, T2>, Fun>::type
358< call(const std::tuple<T1, T2>& t, Fun f)
359< {
360< typedef typename tuple_meta_transform<std::tuple<T1, T2>, Fun>::type
361< return_type;
362<
363< return return_type( f(t.first), f(t.second) );
364< }
365< };
366<
367545a270,277
368> template<typename Fun>
369> Fun BOOST_TUPLE_ALGO(tuple_for_each)(
370> tuples::null_type
371> , Fun f BOOST_TUPLE_ALGO_TERMINATOR
372> )
373> { return f; }
374>
375>
376547,549c279,282
377< struct tuple_for_each_impl {
378< static Fun BOOST_TUPLE_ALGO(call)( Tuple& t, Fun f BOOST_TUPLE_ALGO_RECURSE)
379< {
380---
381> Fun BOOST_TUPLE_ALGO(tuple_for_each)(
382> Tuple& t
383> , Fun f BOOST_TUPLE_ALGO_RECURSE)
384> {
385551,554c284,286
386< return tuple_for_each_impl<typename Tuple::tail_type,
387< Fun>::call( t.get_tail(), f);
388< }
389<
390---
391> return tuple_for_each(t.get_tail(), f);
392> }
393>
394556c288,293
395< static Fun call(Tuple& t, Fun f)
396---
397> template<typename Tuple, typename Fun>
398> Fun
399> tuple_for_each(
400> Tuple& t,
401> Fun f
402> )
403558c295
404< return call_impl(t, f, 1);
405---
406> return tuple_for_each_impl(t, f, 1);
407561,595d297
408< };
409<
410< template<typename Fun>
411< struct tuple_for_each_impl<tuples::null_type, Fun> {
412< inline static Fun call( tuples::null_type,
413< Fun f BOOST_TUPLE_ALGO_TERMINATOR)
414< {
415< return f;
416< }
417< };
418<
419<
420< // for_each algorithm for std::tuple
421< template<typename... Args , typename Fun>
422< struct tuple_for_each_impl< std::tuple<Args...>, Fun> {
423<
424< inline static Fun call(std::tuple<Args...>& t, Fun f)
425< {
426< return helper::for_each(t, f);
427< }
428<
429< };
430<
431< // for_each algorithm for std::pair
432< template<typename T1, typename T2 , typename Fun>
433< struct tuple_for_each_impl< std::pair<T1, T2>, Fun> {
434<
435< inline static Fun call(std::pair<T1, T2>& t, Fun f)
436< {
437< f(t.first);
438< f(t.second);
439< return f;
440< }
441<
442< };
443602,656c304,305
444< template<typename Tuple1, typename Tuple2>
445< struct tuple_equal_impl{
446< static bool call(const Tuple1& t1, const Tuple2& t2){
447< return t1.get_head() == t2.get_head() &&
448< tuple_equal(t1.get_tail(), t2.get_tail());
449< }
450< };
451<
452< template<>
453< struct tuple_equal_impl<tuples::null_type, tuples::null_type> {
454< inline static bool call(tuples::null_type, tuples::null_type){
455< return true;
456< }
457< };
458<
459< // Equality of std::tuples.
460< template<class... Args1, class... Args2>
461< struct tuple_equal_impl< std::tuple<Args1...>, std::tuple<Args2...> > {
462<
463< inline static bool call( const std::tuple<Args1...>& t1,
464< const std::tuple<Args2...>& t2 )
465< {
466< return t1 == t2;
467< }
468< };
469<
470< // Equality of std::pair
471< template<class T1, class T2, class U1, class U2>
472< struct tuple_equal_impl< std::pair<T1, T2>, std::pair<U1, U2> > {
473<
474< inline static bool call( const std::pair<T1, T2>& t1,
475< const std::pair<U1, U2>& t2 )
476< {
477< return t1 == t2;
478< }
479< };
480<
481< }//namespace detail
482<
483<
484< //Forward template functions to respective implementations
485<
486< template<class Tuple, class Fun>
487< inline typename tuple_meta_transform<Tuple, Fun>::type
488< tuple_transform(const Tuple& t, Fun f)
489< {
490< return detail::tuple_transform_impl<Tuple, Fun>::call(t, f);
491< }
492<
493<
494< template<typename Tuple, typename Fun>
495< inline Fun tuple_for_each(Tuple& t, Fun f)
496< {
497< return detail::tuple_for_each_impl<Tuple, Fun>::call(t, f);
498< }
499---
500> inline bool tuple_equal(tuples::null_type, tuples::null_type)
501> { return true; }
502659c308,311
503< inline bool tuple_equal(Tuple1 const& t1, Tuple2 const& t2)
504---
505> bool tuple_equal(
506> Tuple1 const& t1,
507> Tuple2 const& t2
508> )
509661c313,314
510< return detail::tuple_equal_impl<Tuple1, Tuple2>::call(t1, t2);
511---
512> return t1.get_head() == t2.get_head() &&
513> tuple_equal(t1.get_tail(), t2.get_tail());