1 | /*=============================================================================
|
---|
2 | Copyright (c) 2003 Joel de Guzman
|
---|
3 | Copyright (c) 2004 Peder Holt
|
---|
4 | Copyright (c) 2005 Eric Niebler
|
---|
5 |
|
---|
6 | Use, modification and distribution is subject to the Boost Software
|
---|
7 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
---|
8 | http://www.boost.org/LICENSE_1_0.txt)
|
---|
9 | ==============================================================================*/
|
---|
10 | #if !defined(FUSION_ITERATOR_DETAIL_CONS_ITERATOR_NEXT_TRAITS_HPP)
|
---|
11 | #define FUSION_ITERATOR_DETAIL_CONS_ITERATOR_NEXT_TRAITS_HPP
|
---|
12 |
|
---|
13 | #include <boost/spirit/fusion/detail/config.hpp>
|
---|
14 | #include <boost/spirit/fusion/iterator/next.hpp>
|
---|
15 | #include <boost/spirit/fusion/iterator/equal_to.hpp>
|
---|
16 | #include <boost/mpl/eval_if.hpp>
|
---|
17 | #include <boost/mpl/identity.hpp>
|
---|
18 | #include <boost/type_traits/is_const.hpp>
|
---|
19 | #include <boost/type_traits/add_const.hpp>
|
---|
20 |
|
---|
21 | namespace boost { namespace fusion
|
---|
22 | {
|
---|
23 | struct cons_iterator_tag;
|
---|
24 |
|
---|
25 | template <typename Cons>
|
---|
26 | struct cons_iterator;
|
---|
27 |
|
---|
28 | namespace cons_detail
|
---|
29 | {
|
---|
30 | template <typename Iterator>
|
---|
31 | struct next_traits_impl
|
---|
32 | {
|
---|
33 | typedef typename Iterator::cons_type cons_type;
|
---|
34 | typedef typename cons_type::cdr_type cdr_type;
|
---|
35 |
|
---|
36 | typedef cons_iterator<
|
---|
37 | typename mpl::eval_if<
|
---|
38 | is_const<cons_type>
|
---|
39 | , add_const<cdr_type>
|
---|
40 | , mpl::identity<cdr_type>
|
---|
41 | >::type>
|
---|
42 | type;
|
---|
43 |
|
---|
44 | static type
|
---|
45 | call(Iterator const& i)
|
---|
46 | {
|
---|
47 | return type(detail::ref(i.cons.cdr));
|
---|
48 | }
|
---|
49 | };
|
---|
50 | }
|
---|
51 |
|
---|
52 | namespace meta
|
---|
53 | {
|
---|
54 | template <typename Tag>
|
---|
55 | struct next_impl;
|
---|
56 |
|
---|
57 | template <>
|
---|
58 | struct next_impl<cons_iterator_tag>
|
---|
59 | {
|
---|
60 | template <typename Iterator>
|
---|
61 | struct apply : cons_detail::next_traits_impl<Iterator> {};
|
---|
62 | };
|
---|
63 | }
|
---|
64 | }}
|
---|
65 |
|
---|
66 | #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
---|
67 |
|
---|
68 | namespace boost { namespace mpl
|
---|
69 | {
|
---|
70 | template <typename Iterator>
|
---|
71 | struct next;
|
---|
72 |
|
---|
73 | template <typename Cons>
|
---|
74 | struct next<fusion::cons_iterator<Cons> >
|
---|
75 | : fusion::cons_detail::next_traits_impl<fusion::cons_iterator<Cons> >
|
---|
76 | {
|
---|
77 | };
|
---|
78 | }}
|
---|
79 |
|
---|
80 | #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
---|
81 |
|
---|
82 | #endif
|
---|
83 |
|
---|
84 |
|
---|