1 /*
2  Copyright 2011 Mario Mulansky
3  Copyright 2012 Karsten Ahnert
4 
5  Distributed under the Boost Software License, Version 1.0.
6  (See accompanying file LICENSE_1_0.txt or
7  copy at http://www.boost.org/LICENSE_1_0.txt)
8  */
9 
10 
11 /* nested range algebra */
12 
13 #ifndef NESTED_RANGE_ALGEBRA
14 #define NESTED_RANGE_ALGEBRA
15 
16 namespace detail {
17 
18     template< class Iterator1 , class Iterator2 , class Iterator3 , class Operation , class Algebra >
for_each3(Iterator1 first1,Iterator1 last1,Iterator2 first2,Iterator3 first3,Operation op,Algebra & algebra)19     void for_each3( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3, Operation op , Algebra &algebra )
20 {
21     for( ; first1 != last1 ; )
22         algebra.for_each3( *first1++ , *first2++ , *first3++ , op );
23 }
24 }
25 
26 
27 template< class InnerAlgebra >
28 struct nested_range_algebra
29 {
30 
nested_range_algebranested_range_algebra31     nested_range_algebra()
32         : m_inner_algebra()
33     { }
34 
35     template< class S1 , class S2 , class S3 , class Op >
for_each3nested_range_algebra36     void for_each3( S1 &s1 , S2 &s2 , S3 &s3 , Op op )
37     {
38         detail::for_each3( boost::begin( s1 ) , boost::end( s1 ) , boost::begin( s2 ) , boost::begin( s3 ) , op , m_inner_algebra );
39     }
40 
41 
42 private:
43     InnerAlgebra m_inner_algebra;
44 };
45 
46 #endif
47