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