Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2007 Tobias Schwinger
|
Chris@16
|
3
|
Chris@16
|
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 ==============================================================================*/
|
Chris@16
|
7
|
Chris@16
|
8 #if !defined(BOOST_FUSION_REPETITIVE_VIEW_NEXT_IMPL_HPP_INCLUDED)
|
Chris@16
|
9 #define BOOST_FUSION_REPETITIVE_VIEW_NEXT_IMPL_HPP_INCLUDED
|
Chris@16
|
10
|
Chris@101
|
11 #include <boost/fusion/support/config.hpp>
|
Chris@16
|
12 #include <boost/fusion/iterator/next.hpp>
|
Chris@16
|
13 #include <boost/fusion/iterator/equal_to.hpp>
|
Chris@16
|
14
|
Chris@16
|
15 namespace boost { namespace fusion
|
Chris@16
|
16 {
|
Chris@16
|
17 struct repetitive_view_iterator_tag;
|
Chris@16
|
18
|
Chris@16
|
19 template <typename Sequence, typename Pos>
|
Chris@16
|
20 struct repetitive_view_iterator;
|
Chris@16
|
21
|
Chris@16
|
22 namespace extension
|
Chris@16
|
23 {
|
Chris@16
|
24 template <typename Tag>
|
Chris@16
|
25 struct next_impl;
|
Chris@16
|
26
|
Chris@16
|
27 template <>
|
Chris@16
|
28 struct next_impl<repetitive_view_iterator_tag>
|
Chris@16
|
29 {
|
Chris@16
|
30 template<typename Iterator,
|
Chris@16
|
31 bool Last = result_of::equal_to<typename Iterator::end_type,
|
Chris@16
|
32 typename result_of::next<
|
Chris@16
|
33 typename Iterator::pos_type
|
Chris@16
|
34 >::type>::value >
|
Chris@16
|
35 struct apply_nonempty // <Iterator,false>
|
Chris@16
|
36 {
|
Chris@16
|
37 // advanvce to next position
|
Chris@16
|
38
|
Chris@16
|
39 typedef repetitive_view_iterator<
|
Chris@16
|
40 typename Iterator::sequence_type,
|
Chris@16
|
41 typename result_of::next<typename Iterator::pos_type>::type
|
Chris@16
|
42 >
|
Chris@16
|
43 type;
|
Chris@16
|
44
|
Chris@101
|
45 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
46 static type call(Iterator const& i)
|
Chris@16
|
47 {
|
Chris@16
|
48 return type(i.seq, next(i.pos));
|
Chris@16
|
49 }
|
Chris@16
|
50 };
|
Chris@16
|
51 template <typename Iterator>
|
Chris@16
|
52 struct apply_nonempty<Iterator,true>
|
Chris@16
|
53 {
|
Chris@16
|
54 // reset to beginning
|
Chris@16
|
55
|
Chris@16
|
56 typedef repetitive_view_iterator<
|
Chris@16
|
57 typename Iterator::sequence_type,
|
Chris@16
|
58 typename Iterator::first_type
|
Chris@16
|
59 >
|
Chris@16
|
60 type;
|
Chris@16
|
61
|
Chris@101
|
62 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
63 static type call(Iterator const& i)
|
Chris@16
|
64 {
|
Chris@16
|
65 return type(i.seq);
|
Chris@16
|
66 }
|
Chris@16
|
67 };
|
Chris@16
|
68
|
Chris@16
|
69 template <typename Iterator,
|
Chris@16
|
70 bool Empty = result_of::equal_to<typename Iterator::end_type,
|
Chris@16
|
71 typename Iterator::pos_type>::value >
|
Chris@16
|
72 struct apply // <Iterator,false>
|
Chris@16
|
73 : apply_nonempty<Iterator>
|
Chris@16
|
74 { };
|
Chris@16
|
75
|
Chris@16
|
76 template <typename Iterator>
|
Chris@16
|
77 struct apply<Iterator,true>
|
Chris@16
|
78 {
|
Chris@16
|
79 // eps^n = eps
|
Chris@16
|
80
|
Chris@16
|
81 typedef Iterator type;
|
Chris@16
|
82
|
Chris@101
|
83 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
84 static type call(Iterator const& i)
|
Chris@16
|
85 {
|
Chris@16
|
86 return type(i);
|
Chris@16
|
87 }
|
Chris@16
|
88 };
|
Chris@16
|
89 };
|
Chris@16
|
90 }
|
Chris@16
|
91 }}
|
Chris@16
|
92
|
Chris@16
|
93 #endif
|
Chris@16
|
94
|