1/////////////////////////////////////////////////////////////////////////////
2//
3// (C) Copyright Ion Gaztanaga 2006-2014
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
9// See http://www.boost.org/libs/intrusive for documentation.
10//
11/////////////////////////////////////////////////////////////////////////////
12
13#ifndef BOOST_INTRUSIVE_DETAIL_IITERATOR_HPP
14#define BOOST_INTRUSIVE_DETAIL_IITERATOR_HPP
15
16#ifndef BOOST_CONFIG_HPP
17# include <boost/config.hpp>
18#endif
19
20#if defined(BOOST_HAS_PRAGMA_ONCE)
21# pragma once
22#endif
23
24#include <boost/intrusive/detail/iterator.hpp>
25#include <boost/intrusive/pointer_traits.hpp>
26#include <boost/intrusive/detail/mpl.hpp>
27#include <boost/intrusive/detail/is_stateful_value_traits.hpp>
28
29namespace boost {
30namespace intrusive {
31
32template<class ValueTraits>
33struct value_traits_pointers
34{
35 typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT
36 (boost::intrusive::detail::
37 , ValueTraits, value_traits_ptr
38 , typename boost::intrusive::pointer_traits<typename ValueTraits::node_traits::node_ptr>::template
39 rebind_pointer<ValueTraits>::type) value_traits_ptr;
40
41 typedef typename boost::intrusive::pointer_traits<value_traits_ptr>::template
42 rebind_pointer<ValueTraits const>::type const_value_traits_ptr;
43};
44
45template<class ValueTraits, bool IsConst, class Category>
46struct iiterator
47{
48 typedef ValueTraits value_traits;
49 typedef typename value_traits::node_traits node_traits;
50 typedef typename node_traits::node node;
51 typedef typename node_traits::node_ptr node_ptr;
52 typedef ::boost::intrusive::pointer_traits<node_ptr> nodepointer_traits_t;
53 typedef typename nodepointer_traits_t::template
54 rebind_pointer<void>::type void_pointer;
55 typedef typename ValueTraits::value_type value_type;
56 typedef typename ValueTraits::pointer nonconst_pointer;
57 typedef typename ValueTraits::const_pointer yesconst_pointer;
58 typedef typename ::boost::intrusive::pointer_traits
59 <nonconst_pointer>::reference nonconst_reference;
60 typedef typename ::boost::intrusive::pointer_traits
61 <yesconst_pointer>::reference yesconst_reference;
62 typedef typename nodepointer_traits_t::difference_type difference_type;
63 typedef typename detail::if_c
64 <IsConst, yesconst_pointer, nonconst_pointer>::type pointer;
65 typedef typename detail::if_c
66 <IsConst, yesconst_reference, nonconst_reference>::type reference;
67 typedef iterator
68 < Category
69 , value_type
70 , difference_type
71 , pointer
72 , reference
73 > iterator_traits;
74 typedef typename value_traits_pointers
75 <ValueTraits>::value_traits_ptr value_traits_ptr;
76 typedef typename value_traits_pointers
77 <ValueTraits>::const_value_traits_ptr const_value_traits_ptr;
78 static const bool stateful_value_traits =
79 detail::is_stateful_value_traits<value_traits>::value;
80};
81
82template<class NodePtr, class StoredPointer, bool StatefulValueTraits = true>
83struct iiterator_members
84{
85
86 iiterator_members()
87 : nodeptr_()//Value initialization to achieve "null iterators" (N3644)
88 {}
89
90 iiterator_members(const NodePtr &n_ptr, const StoredPointer &data)
91 : nodeptr_(n_ptr), ptr_(data)
92 {}
93
94 StoredPointer get_ptr() const
95 { return ptr_; }
96
97 NodePtr nodeptr_;
98 StoredPointer ptr_;
99};
100
101template<class NodePtr, class StoredPointer>
102struct iiterator_members<NodePtr, StoredPointer, false>
103{
104 iiterator_members()
105 : nodeptr_()//Value initialization to achieve "null iterators" (N3644)
106 {}
107
108 iiterator_members(const NodePtr &n_ptr, const StoredPointer &)
109 : nodeptr_(n_ptr)
110 {}
111
112 StoredPointer get_ptr() const
113 { return StoredPointer(); }
114
115 NodePtr nodeptr_;
116};
117
118} //namespace intrusive
119} //namespace boost
120
121#endif //BOOST_INTRUSIVE_DETAIL_IITERATOR_HPP
122