fix skip-list iterators
authorkhizmax <libcds.dev@gmail.com>
Mon, 10 Nov 2014 18:35:18 +0000 (21:35 +0300)
committerkhizmax <libcds.dev@gmail.com>
Mon, 10 Nov 2014 18:35:18 +0000 (21:35 +0300)
cds/container/details/skip_list_base.h
cds/intrusive/skip_list_nogc.h

index e7fd70995028eb3434d4daf25a7a13f5762b9028..a5258968481597aebf76527d449e94ee4abdb18d 100644 (file)
@@ -219,7 +219,8 @@ namespace cds { namespace container {
                 typedef typename node_type::stored_value_type   value_type;
                 static bool const c_isConst = intrusive_iterator::c_isConst;
 
-                typedef typename std::conditional< c_isConst, value_type const &, value_type &>::type   value_ref;
+                typedef typename std::conditional< c_isConst, value_type const&, value_type&>::type   value_ref;
+                template <typename FwdIt> friend class iterator;
 
                 intrusive_iterator      m_It;
 
@@ -228,11 +229,6 @@ namespace cds { namespace container {
                     : m_It( it )
                 {}
 
-                intrusive_iterator const& underlying_iterator() const
-                {
-                    return m_It;
-                }
-
             public:
                 iterator()
                     : m_It()
@@ -268,7 +264,7 @@ namespace cds { namespace container {
                 template <typename FwIt>
                 bool operator ==(iterator<FwIt> const& i ) const
                 {
-                    return m_It == i.underlying_iterator();
+                    return m_It == i.m_It;
                 }
                 template <typename FwIt>
                 bool operator !=(iterator<FwIt> const& i ) const
index 43e7cee873eaffb341848057338ce64c2b3c2c8c..db592592b34e801688ba1cd373a3a61262caf40e 100644 (file)
@@ -126,13 +126,14 @@ namespace cds { namespace intrusive {
             typedef BackOff                             back_off;
             typedef typename node_traits::node_type     node_type;
             typedef typename node_traits::value_type    value_type;
-            static bool const c_isConst = IsConst;
+            static CDS_CONSTEXPR bool const c_isConst = IsConst;
 
             typedef typename std::conditional< c_isConst, value_type const &, value_type &>::type   value_ref;
+            friend class iterator< gc, node_traits, back_off, !c_isConst >;
 
         protected:
-            typedef typename node_type::atomic_ptr   atomic_ptr;
-            node_type *             m_pNode;
+            typedef typename node_type::atomic_ptr atomic_ptr;
+            node_type * m_pNode;
 
         public: // for internal use only!!!
             iterator( node_type& refHead )
@@ -146,11 +147,6 @@ namespace cds { namespace intrusive {
                 return it;
             }
 
-            node_type * node() const
-            {
-                return m_pNode;
-            }
-
         public:
             iterator()
                 : m_pNode( nullptr )
@@ -193,7 +189,7 @@ namespace cds { namespace intrusive {
             template <typename Bkoff, bool C>
             bool operator ==(iterator<gc, node_traits, Bkoff, C> const& i ) const
             {
-                return m_pNode == i.node();
+                return m_pNode == i.m_pNode;
             }
             template <typename Bkoff, bool C>
             bool operator !=(iterator<gc, node_traits, Bkoff, C> const& i ) const