1/*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
3 Copyright (c) 2005 Eric Niebler
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_CONS_ITERATOR_07172005_0849)
9#define FUSION_CONS_ITERATOR_07172005_0849
10
11#include <boost/fusion/support/config.hpp>
12#include <boost/type_traits/add_const.hpp>
13#include <boost/fusion/support/iterator_base.hpp>
14#include <boost/fusion/container/list/detail/deref_impl.hpp>
15#include <boost/fusion/container/list/detail/next_impl.hpp>
16#include <boost/fusion/container/list/detail/value_of_impl.hpp>
17#include <boost/fusion/container/list/detail/equal_to_impl.hpp>
18#include <boost/fusion/container/list/list_fwd.hpp>
19
20namespace boost { namespace fusion
21{
22 struct nil_;
23 struct cons_iterator_tag;
24 struct forward_traversal_tag;
25
26 template <typename Cons>
27 struct cons_iterator_identity;
28
29 template <typename Cons = nil_>
30 struct cons_iterator : iterator_base<cons_iterator<Cons> >
31 {
32 typedef cons_iterator_tag fusion_tag;
33 typedef forward_traversal_tag category;
34 typedef Cons cons_type;
35 typedef cons_iterator_identity<
36 typename add_const<Cons>::type>
37 identity;
38
39 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
40 explicit cons_iterator(cons_type& in_cons) BOOST_NOEXCEPT
41 : cons(in_cons) {}
42
43 cons_type& cons;
44
45 // silence MSVC warning C4512: assignment operator could not be generated
46 BOOST_DELETED_FUNCTION(cons_iterator& operator= (cons_iterator const&))
47 };
48
49 struct nil_iterator : iterator_base<nil_iterator>
50 {
51 typedef forward_traversal_tag category;
52 typedef cons_iterator_tag fusion_tag;
53 typedef nil_ cons_type;
54 typedef cons_iterator_identity<
55 add_const<nil_>::type>
56 identity;
57
58 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
59 nil_iterator() BOOST_NOEXCEPT {}
60 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
61 explicit nil_iterator(nil_ const&) BOOST_NOEXCEPT {}
62 };
63
64 template <>
65 struct cons_iterator<nil_> : nil_iterator
66 {
67 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
68 cons_iterator() BOOST_NOEXCEPT {}
69 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
70 explicit cons_iterator(nil_ const&) BOOST_NOEXCEPT {}
71 };
72
73 template <>
74 struct cons_iterator<nil_ const> : nil_iterator
75 {
76 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
77 cons_iterator() BOOST_NOEXCEPT {}
78 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
79 explicit cons_iterator(nil_ const&) BOOST_NOEXCEPT {}
80 };
81
82 template <>
83 struct cons_iterator<list<> > : nil_iterator
84 {
85 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
86 cons_iterator() BOOST_NOEXCEPT {}
87 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
88 explicit cons_iterator(nil_ const&) BOOST_NOEXCEPT {}
89 };
90
91 template <>
92 struct cons_iterator<list<> const> : nil_iterator
93 {
94 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
95 cons_iterator() BOOST_NOEXCEPT {}
96 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
97 explicit cons_iterator(nil_ const&) BOOST_NOEXCEPT {}
98 };
99}}
100
101#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
102namespace std
103{
104 template <typename Cons>
105 struct iterator_traits< ::boost::fusion::cons_iterator<Cons> >
106 { };
107}
108#endif
109
110#endif
111

source code of include/boost/fusion/container/list/cons_iterator.hpp