Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / fusion / view / zip_view / detail / advance_impl.hpp
1 /*=============================================================================
2     Copyright (c) 2001-2011 Joel de Guzman
3     Copyright (c) 2006 Dan Marsden
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 #if !defined(FUSION_ADVANCE_IMPL_20061024_2021)
9 #define FUSION_ADVANCE_IMPL_20061024_2021
10
11 #include <boost/fusion/support/config.hpp>
12 #include <boost/fusion/view/zip_view/zip_view_iterator_fwd.hpp>
13 #include <boost/fusion/iterator/advance.hpp>
14 #include <boost/fusion/algorithm/transformation/transform.hpp>
15 #include <boost/type_traits/remove_reference.hpp>
16
17 namespace boost { namespace fusion {
18
19     struct zip_view_iterator_tag;
20
21     namespace detail
22     {
23         template<typename N>
24         struct poly_advance
25         {
26             template<typename Sig>
27             struct result;
28
29             template<typename N1, typename It>
30             struct result<poly_advance<N1>(It)>
31             {
32                 typedef typename remove_reference<It>::type it;
33                 typedef typename result_of::advance<it,N>::type type;
34             };
35
36             template<typename It>
37             BOOST_FUSION_GPU_ENABLED
38             typename result<poly_advance(It)>::type
39             operator()(const It& it) const
40             {
41                 return fusion::advance<N>(it);
42             }
43         };
44     }
45
46     namespace extension
47     {
48         template<typename Tag>
49         struct advance_impl;
50
51         template<>
52         struct advance_impl<zip_view_iterator_tag>
53         {
54             template<typename It, typename N>
55             struct apply
56             {
57                 typedef zip_view_iterator<
58                     typename result_of::transform<typename It::iterators, detail::poly_advance<N> >::type> type;
59
60                 BOOST_FUSION_GPU_ENABLED
61                 static type
62                 call(It const& it)
63                 {
64                     return type(
65                         fusion::transform(it.iterators_, detail::poly_advance<N>()));
66                 }
67             };
68         };
69     }
70 }}
71
72 #endif