1 | /*=============================================================================
|
---|
2 | Copyright (c) 2003 Joel de Guzman
|
---|
3 | Copyright (c) 2004 Peder Holt
|
---|
4 |
|
---|
5 | Use, modification and distribution is subject to the Boost Software
|
---|
6 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
---|
7 | http://www.boost.org/LICENSE_1_0.txt)
|
---|
8 | ==============================================================================*/
|
---|
9 | #if !defined(FUSION_ITERATOR_DETAIL_JOINT_VIEW_ITERATOR_NEXT_TRAITS_HPP)
|
---|
10 | #define FUSION_ITERATOR_DETAIL_JOINT_VIEW_ITERATOR_NEXT_TRAITS_HPP
|
---|
11 |
|
---|
12 | #include <boost/spirit/fusion/detail/config.hpp>
|
---|
13 | #include <boost/spirit/fusion/iterator/next.hpp>
|
---|
14 | #include <boost/spirit/fusion/iterator/equal_to.hpp>
|
---|
15 | #include <boost/mpl/if.hpp>
|
---|
16 |
|
---|
17 | namespace boost { namespace fusion
|
---|
18 | {
|
---|
19 | struct joint_view_iterator_tag;
|
---|
20 |
|
---|
21 | template <typename View1, typename View2>
|
---|
22 | struct joint_view;
|
---|
23 |
|
---|
24 | template <typename First, typename Last, typename Concat>
|
---|
25 | struct joint_view_iterator;
|
---|
26 |
|
---|
27 | namespace join_view_detail {
|
---|
28 | template<typename Iterator>
|
---|
29 | struct next_traits_impl {
|
---|
30 | typedef typename Iterator::first_type first_type;
|
---|
31 | typedef typename Iterator::last_type last_type;
|
---|
32 | typedef typename Iterator::concat_type concat_type;
|
---|
33 | typedef typename meta::next<first_type>::type next_type;
|
---|
34 | typedef meta::equal_to<next_type, last_type> equal_to;
|
---|
35 |
|
---|
36 | typedef typename
|
---|
37 | mpl::if_<
|
---|
38 | equal_to
|
---|
39 | , concat_type
|
---|
40 | , joint_view_iterator<next_type, last_type, concat_type>
|
---|
41 | >::type
|
---|
42 | type;
|
---|
43 |
|
---|
44 | static type
|
---|
45 | call(Iterator const& i);
|
---|
46 | };
|
---|
47 |
|
---|
48 | template<typename Iterator>
|
---|
49 | typename next_traits_impl<Iterator>::type
|
---|
50 | call(Iterator const& i, mpl::true_)
|
---|
51 | {
|
---|
52 | return i.concat;
|
---|
53 | }
|
---|
54 |
|
---|
55 | template<typename Iterator>
|
---|
56 | typename next_traits_impl<Iterator>::type
|
---|
57 | call(Iterator const& i, mpl::false_)
|
---|
58 | {
|
---|
59 | typedef typename next_traits_impl<Iterator>::type type;
|
---|
60 | return type(fusion::next(i.first), i.concat);
|
---|
61 | }
|
---|
62 |
|
---|
63 | template<typename Iterator>
|
---|
64 | typename next_traits_impl<Iterator>::type
|
---|
65 | next_traits_impl<Iterator>::call(Iterator const& i)
|
---|
66 | {
|
---|
67 | return join_view_detail::call(i, equal_to());
|
---|
68 | }
|
---|
69 | }
|
---|
70 |
|
---|
71 | namespace meta
|
---|
72 | {
|
---|
73 | template <typename Tag>
|
---|
74 | struct next_impl;
|
---|
75 |
|
---|
76 | template <>
|
---|
77 | struct next_impl<joint_view_iterator_tag>
|
---|
78 | {
|
---|
79 | template <typename Iterator>
|
---|
80 | struct apply : join_view_detail::next_traits_impl<Iterator>
|
---|
81 | {};
|
---|
82 | };
|
---|
83 | }
|
---|
84 | }}
|
---|
85 |
|
---|
86 | #endif
|
---|
87 |
|
---|
88 |
|
---|