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/workaround.hpp> 25 #include <boost/intrusive/detail/iterator.hpp> 26 #include <boost/intrusive/pointer_traits.hpp> 27 #include <boost/intrusive/detail/mpl.hpp> 28 #include <boost/intrusive/detail/is_stateful_value_traits.hpp> 29 30 namespace boost { 31 namespace intrusive { 32 33 template<class ValueTraits> 34 struct value_traits_pointers 35 { 36 typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT 37 (boost::intrusive::detail:: 38 , ValueTraits, value_traits_ptr 39 , typename boost::intrusive::pointer_traits<typename ValueTraits::node_traits::node_ptr>::template 40 rebind_pointer<ValueTraits>::type) value_traits_ptr; 41 42 typedef typename boost::intrusive::pointer_traits<value_traits_ptr>::template 43 rebind_pointer<ValueTraits const>::type const_value_traits_ptr; 44 }; 45 46 template<class ValueTraits, bool IsConst, class Category> 47 struct iiterator 48 { 49 typedef ValueTraits value_traits; 50 typedef typename value_traits::node_traits node_traits; 51 typedef typename node_traits::node node; 52 typedef typename node_traits::node_ptr node_ptr; 53 typedef ::boost::intrusive::pointer_traits<node_ptr> nodepointer_traits_t; 54 typedef typename nodepointer_traits_t::template 55 rebind_pointer<void>::type void_pointer; 56 typedef typename ValueTraits::value_type value_type; 57 typedef typename ValueTraits::pointer nonconst_pointer; 58 typedef typename ValueTraits::const_pointer yesconst_pointer; 59 typedef typename ::boost::intrusive::pointer_traits 60 <nonconst_pointer>::reference nonconst_reference; 61 typedef typename ::boost::intrusive::pointer_traits 62 <yesconst_pointer>::reference yesconst_reference; 63 typedef typename nodepointer_traits_t::difference_type difference_type; 64 typedef typename detail::if_c 65 <IsConst, yesconst_pointer, nonconst_pointer>::type pointer; 66 typedef typename detail::if_c 67 <IsConst, yesconst_reference, nonconst_reference>::type reference; 68 typedef iterator 69 < Category 70 , value_type 71 , difference_type 72 , pointer 73 , reference 74 > iterator_type; 75 typedef typename value_traits_pointers 76 <ValueTraits>::value_traits_ptr value_traits_ptr; 77 typedef typename value_traits_pointers 78 <ValueTraits>::const_value_traits_ptr const_value_traits_ptr; 79 static const bool stateful_value_traits = 80 detail::is_stateful_value_traits<value_traits>::value; 81 }; 82 83 template<class NodePtr, class StoredPointer, bool StatefulValueTraits = true> 84 struct iiterator_members 85 { 86 iiterator_membersboost::intrusive::iiterator_members87 BOOST_INTRUSIVE_FORCEINLINE iiterator_members() 88 : nodeptr_()//Value initialization to achieve "null iterators" (N3644) 89 {} 90 iiterator_membersboost::intrusive::iiterator_members91 BOOST_INTRUSIVE_FORCEINLINE iiterator_members(const NodePtr &n_ptr, const StoredPointer &data) 92 : nodeptr_(n_ptr), ptr_(data) 93 {} 94 get_ptrboost::intrusive::iiterator_members95 BOOST_INTRUSIVE_FORCEINLINE StoredPointer get_ptr() const 96 { return ptr_; } 97 98 NodePtr nodeptr_; 99 StoredPointer ptr_; 100 }; 101 102 template<class NodePtr, class StoredPointer> 103 struct iiterator_members<NodePtr, StoredPointer, false> 104 { iiterator_membersboost::intrusive::iiterator_members105 BOOST_INTRUSIVE_FORCEINLINE iiterator_members() 106 : nodeptr_()//Value initialization to achieve "null iterators" (N3644) 107 {} 108 iiterator_membersboost::intrusive::iiterator_members109 BOOST_INTRUSIVE_FORCEINLINE iiterator_members(const NodePtr &n_ptr, const StoredPointer &) 110 : nodeptr_(n_ptr) 111 {} 112 get_ptrboost::intrusive::iiterator_members113 BOOST_INTRUSIVE_FORCEINLINE StoredPointer get_ptr() const 114 { return StoredPointer(); } 115 116 NodePtr nodeptr_; 117 }; 118 119 } //namespace intrusive 120 } //namespace boost 121 122 #endif //BOOST_INTRUSIVE_DETAIL_IITERATOR_HPP 123