movable guarded_ptr: LazyList, MichaelList
authorkhizmax <khizmax@gmail.com>
Tue, 18 Nov 2014 16:10:51 +0000 (19:10 +0300)
committerkhizmax <khizmax@gmail.com>
Tue, 18 Nov 2014 16:10:51 +0000 (19:10 +0300)
12 files changed:
cds/container/impl/lazy_kvlist.h
cds/container/impl/lazy_list.h
cds/container/impl/michael_kvlist.h
cds/container/impl/michael_list.h
cds/intrusive/impl/lazy_list.h
cds/intrusive/impl/michael_list.h
tests/test-hdr/ordered_list/hdr_intrusive_lazy.h
tests/test-hdr/ordered_list/hdr_intrusive_michael.h
tests/test-hdr/ordered_list/hdr_lazy.h
tests/test-hdr/ordered_list/hdr_lazy_kv.h
tests/test-hdr/ordered_list/hdr_michael.h
tests/test-hdr/ordered_list/hdr_michael_kv.h

index 953b5bc1cb25a4551df3f737ce6fdcf9e3397a8d..e8b83f7a7cbc001194618e5465ae86ea95454784 100644 (file)
@@ -118,7 +118,7 @@ namespace cds { namespace container {
 
     public:
         /// Guarded pointer
-        typedef cds::gc::guarded_ptr< gc, node_type, value_type, details::guarded_ptr_cast_map<node_type, value_type> > guarded_ptr;
+        typedef typename gc::template guarded_ptr< node_type, value_type, details::guarded_ptr_cast_map<node_type, value_type> > guarded_ptr;
 
     protected:
         //@cond
@@ -514,8 +514,8 @@ namespace cds { namespace container {
         /// Extracts the item from the list with specified \p key
         /** \anchor cds_nonintrusive_LazyKVList_hp_extract
             The function searches an item with key equal to \p key,
-            unlinks it from the list, and returns it in \p dest parameter.
-            If the item with key equal to \p key is not found the function returns \p false.
+            unlinks it from the list, and returns it as \p guarded_ptr.
+            If \p key is not found the function returns an empty guarded pointer.
 
             Note the compare functor should accept a parameter of type \p K that can be not the same as \p key_type.
 
@@ -527,24 +527,26 @@ namespace cds { namespace container {
             ord_list theList;
             // ...
             {
-                ord_list::guarded_ptr gp;
-                theList.extract( gp, 5 );
-                // Deal with gp
-                // ...
-
+                ord_list::guarded_ptr gp( theList.extract( 5 ));
+                if ( gp ) {
+                    // Deal with gp
+                    // ...
+                }
                 // Destructor of gp releases internal HP guard and frees the item
             }
             \endcode
         */
         template <typename K>
-        bool extract( guarded_ptr& dest, K const& key )
+        guarded_ptr extract( K const& key )
         {
-            return extract_at( head(), dest.guard(), key, intrusive_key_comparator() );
+            guarded_ptr gp;
+            extract_at( head(), gp.guard(), key, intrusive_key_comparator() );
+            return gp;
         }
 
         /// Extracts the item from the list with comparing functor \p pred
         /**
-            The function is an analog of \ref cds_nonintrusive_LazyKVList_hp_extract "extract(guarded_ptr&, K const&)"
+            The function is an analog of \ref cds_nonintrusive_LazyKVList_hp_extract "extract(K const&)"
             but \p pred predicate is used for key comparing.
 
             \p Less functor has the semantics like \p std::less but should take arguments of type \ref key_type and \p K
@@ -552,10 +554,12 @@ namespace cds { namespace container {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename K, typename Less>
-        bool extract_with( guarded_ptr& dest, K const& key, Less pred )
+        guarded_ptr extract_with( K const& key, Less pred )
         {
             CDS_UNUSED( pred );
-            return extract_at( head(), dest.guard(), key, typename maker::template less_wrapper<Less>::type() );
+            guarded_ptr gp;
+            extract_at( head(), gp.guard(), key, typename maker::template less_wrapper<Less>::type() );
+            return gp;
         }
 
         /// Finds the key \p key
@@ -624,9 +628,8 @@ namespace cds { namespace container {
         /// Finds \p key and return the item found
         /** \anchor cds_nonintrusive_LazyKVList_hp_get
             The function searches the item with key equal to \p key
-            and assigns the item found to guarded pointer \p ptr.
-            The function returns \p true if \p key is found, and \p false otherwise.
-            If \p key is not found the \p ptr parameter is not changed.
+            and returns the item found as a guarded pointer.
+            If \p key is not found the functions returns an empty \p guarded_ptr.
 
             @note Each \p guarded_ptr object uses one GC's guard which can be limited resource.
 
@@ -636,8 +639,8 @@ namespace cds { namespace container {
             ord_list theList;
             // ...
             {
-                ord_list::guarded_ptr gp;
-                if ( theList.get( gp, 5 )) {
+                ord_list::guarded_ptr gp( theList.get( 5 ));
+                if ( gp ) {
                     // Deal with gp
                     //...
                 }
@@ -649,14 +652,16 @@ namespace cds { namespace container {
             should accept a parameter of type \p K that can be not the same as \p key_type.
         */
         template <typename K>
-        bool get( guarded_ptr& ptr, K const& key )
+        guarded_ptr get( K const& key )
         {
-            return get_at( head(), ptr.guard(), key, intrusive_key_comparator() );
+            guarded_ptr gp;
+            get_at( head(), gp.guard(), key, intrusive_key_comparator() );
+            return gp;
         }
 
         /// Finds the key \p val and return the item found
         /**
-            The function is an analog of \ref cds_nonintrusive_LazyKVList_hp_get "get(guarded_ptr& ptr, K const&)"
+            The function is an analog of \ref cds_nonintrusive_LazyKVList_hp_get "get(K const&)"
             but \p pred is used for comparing the keys.
 
             \p Less functor has the semantics like \p std::less but should take arguments of type \ref key_type and \p K
@@ -664,10 +669,12 @@ namespace cds { namespace container {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename K, typename Less>
-        bool get_with( guarded_ptr& ptr, K const& key, Less pred )
+        guarded_ptr get_with( K const& key, Less pred )
         {
             CDS_UNUSED( pred );
-            return get_at( head(), ptr.guard(), key, typename maker::template less_wrapper<Less>::type() );
+            guarded_ptr gp;
+            get_at( head(), gp.guard(), key, typename maker::template less_wrapper<Less>::type() );
+            return gp;
         }
 
         /// Checks if the list is empty
@@ -753,9 +760,9 @@ namespace cds { namespace container {
         }
 
         template <typename K, typename Compare>
-        bool extract_at( head_type& refHead, typename gc::Guard& dest, K const& key, Compare cmp )
+        bool extract_at( head_type& refHead, typename guarded_ptr::native_guard& guard, K const& key, Compare cmp )
         {
-            return base_class::extract_at( &refHead, dest, key, cmp );
+            return base_class::extract_at( &refHead, guard, key, cmp );
         }
 
         template <typename K, typename Func>
@@ -784,7 +791,7 @@ namespace cds { namespace container {
         }
 
         template <typename K, typename Compare>
-        bool get_at( head_type& refHead, typename gc::Guard& guard, K const& key, Compare cmp )
+        bool get_at( head_type& refHead, typename guarded_ptr::native_guard& guard, K const& key, Compare cmp )
         {
             return base_class::get_at( &refHead, guard, key, cmp );
         }
index c61f030a4aa299fc29222d5452a0cb8c73d28f10..be0cc0bcd030806c8d0bdc907c9db8cb81752cf0 100644 (file)
@@ -125,7 +125,7 @@ namespace cds { namespace container {
 
     public:
         /// Guarded pointer
-        typedef cds::gc::guarded_ptr< gc, node_type, value_type, details::guarded_ptr_cast_set<node_type, value_type> > guarded_ptr;
+        typedef typename gc::template guarded_ptr< node_type, value_type, details::guarded_ptr_cast_set<node_type, value_type> > guarded_ptr;
 
     private:
         //@cond
@@ -490,8 +490,8 @@ namespace cds { namespace container {
         /// Extracts the item from the list with specified \p key
         /** \anchor cds_nonintrusive_LazyList_hp_extract
             The function searches an item with key equal to \p key,
-            unlinks it from the list, and returns it in \p dest parameter.
-            If the item with key equal to \p key is not found the function returns \p false.
+            unlinks it from the list, and returns it as \p guarded_ptr.
+            If \p key is not found the function returns an empty guarded pointer.
 
             Note the compare functor should accept a parameter of type \p Q that can be not the same as \p value_type.
 
@@ -503,24 +503,26 @@ namespace cds { namespace container {
             ord_list theList;
             // ...
             {
-                ord_list::guarded_ptr gp;
-                theList.extract( gp, 5 );
-                // Deal with gp
-                // ...
-
+                ord_list::guarded_ptr gp(theList.extract( 5 ));
+                if ( gp ) {
+                    // Deal with gp
+                    // ...
+                }
                 // Destructor of gp releases internal HP guard and frees the item
             }
             \endcode
         */
         template <typename Q>
-        bool extract( guarded_ptr& dest, Q const& key )
+        guarded_ptr extract( Q const& key )
         {
-            return extract_at( head(), dest.guard(), key, intrusive_key_comparator() );
+            guarded_ptr gp;
+            extract_at( head(), gp.guard(), key, intrusive_key_comparator() );
+            return gp;
         }
 
         /// Extracts the item from the list with comparing functor \p pred
         /**
-            The function is an analog of \ref cds_nonintrusive_LazyList_hp_extract "extract(guarded_ptr&, Q const&)"
+            The function is an analog of \ref cds_nonintrusive_LazyList_hp_extract "extract(Q const&)"
             but \p pred predicate is used for key comparing.
 
             \p Less functor has the semantics like \p std::less but should take arguments of type \ref value_type and \p Q
@@ -528,10 +530,12 @@ namespace cds { namespace container {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename Q, typename Less>
-        bool extract_with( guarded_ptr& dest, Q const& key, Less pred )
+        guarded_ptr extract_with( Q const& key, Less pred )
         {
             CDS_UNUSED( pred );
-            return extract_at( head(), dest.guard(), key, typename maker::template less_wrapper<Less>::type() );
+            guarded_ptr gp;
+            extract_at( head(), gp.guard(), key, typename maker::template less_wrapper<Less>::type() );
+            return gp;
         }
 
         /// Finds the key \p key
@@ -618,9 +622,8 @@ namespace cds { namespace container {
         /// Finds the key \p key and return the item found
         /** \anchor cds_nonintrusive_LazyList_hp_get
             The function searches the item with key equal to \p key
-            and assigns the item found to guarded pointer \p ptr.
-            The function returns \p true if \p key is found, and \p false otherwise.
-            If \p key is not found the \p ptr parameter is not changed.
+            and returns the item found as \p guarded_ptr.
+            If \p key is not found the function returns an empty guarded pointer.
 
             @note Each \p guarded_ptr object uses one GC's guard which can be limited resource.
 
@@ -630,8 +633,8 @@ namespace cds { namespace container {
             ord_list theList;
             // ...
             {
-                ord_list::guarded_ptr gp;
-                if ( theList.get( gp, 5 )) {
+                ord_list::guarded_ptr gp( theList.get( 5 ));
+                if ( gp ) {
                     // Deal with gp
                     //...
                 }
@@ -643,14 +646,16 @@ namespace cds { namespace container {
             should accept a parameter of type \p Q that can be not the same as \p value_type.
         */
         template <typename Q>
-        bool get( guarded_ptr& ptr, Q const& key )
+        guarded_ptr get( Q const& key )
         {
-            return get_at( head(), ptr.guard(), key, intrusive_key_comparator() );
+            guarded_ptr gp;
+            get_at( head(), gp.guard(), key, intrusive_key_comparator() );
+            return gp;
         }
 
         /// Finds the key \p key and return the item found
         /**
-            The function is an analog of \ref cds_nonintrusive_LazyList_hp_get "get( guarded_ptr& ptr, Q const&)"
+            The function is an analog of \ref cds_nonintrusive_LazyList_hp_get "get( Q const&)"
             but \p pred is used for comparing the keys.
 
             \p Less functor has the semantics like \p std::less but should take arguments of type \ref value_type and \p Q
@@ -658,10 +663,12 @@ namespace cds { namespace container {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename Q, typename Less>
-        bool get_with( guarded_ptr& ptr, Q const& key, Less pred )
+        guarded_ptr get_with( Q const& key, Less pred )
         {
             CDS_UNUSED( pred );
-            return get_at( head(), ptr.guard(), key, typename maker::template less_wrapper<Less>::type() );
+            guarded_ptr gp;
+            get_at( head(), gp.guard(), key, typename maker::template less_wrapper<Less>::type() );
+            return gp;
         }
 
         /// Checks whether the list is empty
@@ -735,9 +742,9 @@ namespace cds { namespace container {
         }
 
         template <typename Q, typename Compare>
-        bool extract_at( head_type& refHead, typename gc::Guard& dest, Q const& key, Compare cmp )
+        bool extract_at( head_type& refHead, typename guarded_ptr::native_guard& guard, Q const& key, Compare cmp )
         {
-            return base_class::extract_at( &refHead, dest, key, cmp );
+            return base_class::extract_at( &refHead, guard, key, cmp );
         }
 
         template <typename Q, typename Func>
@@ -766,7 +773,7 @@ namespace cds { namespace container {
         }
 
         template <typename Q, typename Compare>
-        bool get_at( head_type& refHead, typename gc::Guard& guard, Q const& key, Compare cmp )
+        bool get_at( head_type& refHead, typename guarded_ptr::native_guard& guard, Q const& key, Compare cmp )
         {
             return base_class::get_at( &refHead, guard, key, cmp );
         }
index f0c766a62e4648014568b4c7b6c55d4555a1d617..a31103e4949be5c38b61cb80e183431e39356d52 100644 (file)
@@ -121,7 +121,7 @@ namespace cds { namespace container {
 
     public:
         /// Guarded pointer
-        typedef cds::gc::guarded_ptr< gc, node_type, value_type, details::guarded_ptr_cast_map<node_type, value_type> > guarded_ptr;
+        typedef typename gc::template guarded_ptr< node_type, value_type, details::guarded_ptr_cast_map<node_type, value_type> > guarded_ptr;
 
     protected:
         //@cond
@@ -520,13 +520,13 @@ namespace cds { namespace container {
         /// Extracts the item from the list with specified \p key
         /** \anchor cds_nonintrusive_MichaelKVList_hp_extract
             The function searches an item with key equal to \p key,
-            unlinks it from the list, and returns it in \p dest parameter.
-            If the item with key equal to \p key is not found the function returns \p false.
+            unlinks it from the list, and returns it as \p guarded_ptr.
+            If \p key is not found the function returns an empty guarded pointer.
 
             Note the compare functor should accept a parameter of type \p K that can be not the same as \p key_type.
 
-            The \ref disposer specified in \p Traits class template parameter is called automatically
-            by garbage collector \p GC specified in class' template parameters when returned \ref guarded_ptr object
+            The \p disposer specified in \p Traits class template parameter is called automatically
+            by garbage collector \p GC specified in class' template parameters when returned \p guarded_ptr object
             will be destroyed or released.
             @note Each \p guarded_ptr object uses the GC's guard that can be limited resource.
 
@@ -536,24 +536,26 @@ namespace cds { namespace container {
             ord_list theList;
             // ...
             {
-                ord_list::guarded_ptr gp;
-                theList.extract( gp, 5 );
-                // Deal with gp
-                // ...
-
+                ord_list::guarded_ptr gp(theList.extract( 5 ));
+                if ( gp ) {
+                    // Deal with gp
+                    // ...
+                }
                 // Destructor of gp releases internal HP guard
             }
             \endcode
         */
         template <typename K>
-        bool extract( guarded_ptr& dest, K const& key )
+        guarded_ptr extract( K const& key )
         {
-            return extract_at( head(), dest.guard(), key, intrusive_key_comparator() );
+            guarded_ptr gp;
+            extract_at( head(), gp.guard(), key, intrusive_key_comparator() );
+            return gp;
         }
 
         /// Extracts the item from the list with comparing functor \p pred
         /**
-            The function is an analog of \ref cds_nonintrusive_MichaelKVList_hp_extract "extract(guarded_ptr&, K const&)"
+            The function is an analog of \ref cds_nonintrusive_MichaelKVList_hp_extract "extract(K const&)"
             but \p pred predicate is used for key comparing.
 
             \p Less functor has the semantics like \p std::less but should take arguments of type \ref key_type and \p K
@@ -561,10 +563,12 @@ namespace cds { namespace container {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename K, typename Less>
-        bool extract_with( guarded_ptr& dest, K const& key, Less pred )
+        guarded_ptr extract_with( K const& key, Less pred )
         {
             CDS_UNUSED( pred );
-            return extract_at( head(), dest.guard(), key, typename maker::template less_wrapper<Less>::type() );
+            guarded_ptr gp;
+            extract_at( head(), gp.guard(), key, typename maker::template less_wrapper<Less>::type() );
+            return gp;
         }
 
         /// Finds the key \p key
@@ -633,12 +637,11 @@ namespace cds { namespace container {
         /// Finds the \p key and return the item found
         /** \anchor cds_nonintrusive_MichaelKVList_hp_get
             The function searches the item with key equal to \p key
-            and assigns the item found to guarded pointer \p ptr.
-            The function returns \p true if \p key is found, and \p false otherwise.
-            If \p key is not found the \p ptr parameter is not changed.
+            and returns it as \p guarded_ptr.
+            If \p key is not found the function returns an empty guarded pointer.
 
-            The \ref disposer specified in \p Traits class template parameter is called
-            by garbage collector \p GC automatically when returned \ref guarded_ptr object
+            The \p disposer specified in \p Traits class template parameter is called
+            by garbage collector \p GC automatically when returned \p guarded_ptr object
             will be destroyed or released.
             @note Each \p guarded_ptr object uses one GC's guard which can be limited resource.
 
@@ -648,8 +651,8 @@ namespace cds { namespace container {
             ord_list theList;
             // ...
             {
-                ord_list::guarded_ptr gp;
-                if ( theList.get( gp, 5 )) {
+                ord_list::guarded_ptr gp(theList.get( 5 ));
+                if ( gp ) {
                     // Deal with gp
                     //...
                 }
@@ -661,9 +664,11 @@ namespace cds { namespace container {
             should accept a parameter of type \p K that can be not the same as \p key_type.
         */
         template <typename K>
-        bool get( guarded_ptr& ptr, K const& key )
+        guarded_ptr get( K const& key )
         {
-            return get_at( head(), ptr.guard(), key, intrusive_key_comparator() );
+            guarded_ptr gp;
+            get_at( head(), gp.guard(), key, intrusive_key_comparator() );
+            return gp;
         }
 
         /// Finds the \p key and return the item found
@@ -676,10 +681,12 @@ namespace cds { namespace container {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename K, typename Less>
-        bool get_with( guarded_ptr& ptr, K const& key, Less pred )
+        guarded_ptr get_with( K const& key, Less pred )
         {
             CDS_UNUSED( pred );
-            return get_at( head(), ptr.guard(), key, typename maker::template less_wrapper<Less>::type() );
+            guarded_ptr gp;
+            get_at( head(), gp.guard(), key, typename maker::template less_wrapper<Less>::type() );
+            return gp;
         }
 
         /// Checks if the list is empty
@@ -775,9 +782,9 @@ namespace cds { namespace container {
             return base_class::erase_at( refHead, key, cmp, [&f]( node_type const & node ){ f( const_cast<value_type&>(node.m_Data)); });
         }
         template <typename K, typename Compare>
-        bool extract_at( head_type& refHead, typename gc::Guard& dest, K const& key, Compare cmp )
+        bool extract_at( head_type& refHead, typename guarded_ptr::native_guard& guard, K const& key, Compare cmp )
         {
-            return base_class::extract_at( refHead, dest, key, cmp );
+            return base_class::extract_at( refHead, guard, key, cmp );
         }
 
         template <typename K, typename Compare>
@@ -793,7 +800,7 @@ namespace cds { namespace container {
         }
 
         template <typename K, typename Compare>
-        bool get_at( head_type& refHead, typename gc::Guard& guard, K const& key, Compare cmp )
+        bool get_at( head_type& refHead, typename guarded_ptr::native_guard& guard, K const& key, Compare cmp )
         {
             return base_class::get_at( refHead, guard, key, cmp );
         }
index e4ac8e130b7a2a4bf9a828d0df23fbd8f41a78ae..2420a33424eff575b828055c7d89f94c244af1b9 100644 (file)
@@ -121,7 +121,7 @@ namespace cds { namespace container {
 
     public:
         /// Guarded pointer
-        typedef cds::gc::guarded_ptr< gc, node_type, value_type, details::guarded_ptr_cast_set<node_type, value_type> > guarded_ptr;
+        typedef typename gc::template guarded_ptr< node_type, value_type, details::guarded_ptr_cast_set<node_type, value_type> > guarded_ptr;
 
     private:
         //@cond
@@ -479,8 +479,8 @@ namespace cds { namespace container {
         /// Extracts the item from the list with specified \p key
         /** \anchor cds_nonintrusive_MichaelList_hp_extract
             The function searches an item with key equal to \p key,
-            unlinks it from the list, and returns it in \p dest parameter.
-            If the item with key equal to \p key is not found the function returns \p false.
+            unlinks it from the list, and returns it as \p guarded_ptr.
+            If \p key is not found the function returns an empty guarded pointer.
 
             Note the compare functor should accept a parameter of type \p Q that can be not the same as \p value_type.
 
@@ -492,24 +492,26 @@ namespace cds { namespace container {
             ord_list theList;
             // ...
             {
-                ord_list::guarded_ptr gp;
-                theList.extract( gp, 5 );
-                // Deal with gp
-                // ...
-
+                ord_list::guarded_ptr gp(theList.extract( 5 ));
+                if ( gp ) {
+                    // Deal with gp
+                    // ...
+                }
                 // Destructor of gp releases internal HP guard and frees the item
             }
             \endcode
         */
         template <typename Q>
-        bool extract( guarded_ptr& dest, Q const& key )
+        guarded_ptr extract( Q const& key )
         {
-            return extract_at( head(), dest.guard(), key, intrusive_key_comparator() );
+            guarded_ptr gp;
+            extract_at( head(), gp.guard(), key, intrusive_key_comparator() );
+            return gp;
         }
 
         /// Extracts the item from the list with comparing functor \p pred
         /**
-            The function is an analog of \ref cds_nonintrusive_MichaelList_hp_extract "extract(guarded_ptr&, Q const&)"
+            The function is an analog of \ref cds_nonintrusive_MichaelList_hp_extract "extract(Q const&)"
             but \p pred predicate is used for key comparing.
 
             \p Less functor has the semantics like \p std::less but it should accept arguments of type \p value_type and \p Q
@@ -517,10 +519,12 @@ namespace cds { namespace container {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename Q, typename Less>
-        bool extract_with( guarded_ptr& dest, Q const& key, Less pred )
+        guarded_ptr extract_with( Q const& key, Less pred )
         {
             CDS_UNUSED( pred );
-            return extract_at( head(), dest.guard(), key, typename maker::template less_wrapper<Less>::type() );
+            guarded_ptr gp;
+            extract_at( head(), gp.guard(), key, typename maker::template less_wrapper<Less>::type() );
+            return gp;
         }
 
         /// Finds \p key
@@ -604,9 +608,8 @@ namespace cds { namespace container {
         /// Finds \p key and return the item found
         /** \anchor cds_nonintrusive_MichaelList_hp_get
             The function searches the item with key equal to \p key
-            and assigns the item found to guarded pointer \p ptr.
-            The function returns \p true if \p key is found, and \p false otherwise.
-            If \p key is not found the \p ptr parameter is not changed.
+            and returns it as \p guarded_ptr.
+            If \p key is not found the function returns an empty guarded pointer.
 
             @note Each \p guarded_ptr object uses one GC's guard which can be limited resource.
 
@@ -616,8 +619,8 @@ namespace cds { namespace container {
             ord_list theList;
             // ...
             {
-                ord_list::guarded_ptr gp;
-                if ( theList.get( gp, 5 )) {
+                ord_list::guarded_ptr gp(theList.get( 5 ));
+                if ( gp ) {
                     // Deal with gp
                     //...
                 }
@@ -629,14 +632,16 @@ namespace cds { namespace container {
             should accept a parameter of type \p Q that can be not the same as \p value_type.
         */
         template <typename Q>
-        bool get( guarded_ptr& ptr, Q const& key )
+        guarded_ptr get( Q const& key )
         {
-            return get_at( head(), ptr.guard(), key, intrusive_key_comparator() );
+            guarded_ptr gp;
+            get_at( head(), gp.guard(), key, intrusive_key_comparator() );
+            return gp;
         }
 
         /// Finds \p key and return the item found
         /**
-            The function is an analog of \ref cds_nonintrusive_MichaelList_hp_get "get( guarded_ptr& ptr, Q const&)"
+            The function is an analog of \ref cds_nonintrusive_MichaelList_hp_get "get( Q const&)"
             but \p pred is used for comparing the keys.
 
             \p Less functor has the semantics like \p std::less but should accept arguments of type \p value_type and \p Q
@@ -644,10 +649,12 @@ namespace cds { namespace container {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename Q, typename Less>
-        bool get_with( guarded_ptr& ptr, Q const& key, Less pred )
+        guarded_ptr get_with( Q const& key, Less pred )
         {
             CDS_UNUSED( pred );
-            return get_at( head(), ptr.guard(), key, typename maker::template less_wrapper<Less>::type() );
+            guarded_ptr gp;
+            get_at( head(), gp.guard(), key, typename maker::template less_wrapper<Less>::type() );
+            return gp;
         }
 
         /// Check if the list is empty
@@ -720,9 +727,9 @@ namespace cds { namespace container {
         }
 
         template <typename Q, typename Compare>
-        bool extract_at( head_type& refHead, typename gc::Guard& dest, Q const& key, Compare cmp )
+        bool extract_at( head_type& refHead, typename guarded_ptr::native_guard& guard, Q const& key, Compare cmp )
         {
-            return base_class::extract_at( refHead, dest, key, cmp );
+            return base_class::extract_at( refHead, guard, key, cmp );
         }
 
         template <typename Q, typename Func>
@@ -751,7 +758,7 @@ namespace cds { namespace container {
         }
 
         template <typename Q, typename Compare>
-        bool get_at( head_type& refHead, typename gc::Guard& guard, Q const& key, Compare cmp )
+        bool get_at( head_type& refHead, typename guarded_ptr::native_guard& guard, Q const& key, Compare cmp )
         {
             return base_class::get_at( refHead, guard, key, cmp );
         }
index eda3714ec213719d6e0aa94a2a478a5963fa7f0a..f2c9eaf6a7a75927401c1afece810ca7035a4697 100644 (file)
@@ -177,7 +177,7 @@ namespace cds { namespace intrusive {
         typedef typename traits::item_counter item_counter ;   ///< Item counting policy used
         typedef typename traits::memory_model  memory_model;   ///< C++ memory ordering (see \p lazy_list::traits::memory_model)
 
-        typedef cds::gc::guarded_ptr< gc, value_type > guarded_ptr; ///< Guarded pointer
+        typedef typename gc::template guarded_ptr< value_type > guarded_ptr; ///< Guarded pointer
 
         //@cond
         // Rebind traits (split-list support)
@@ -634,13 +634,13 @@ namespace cds { namespace intrusive {
         /// Extracts the item from the list with specified \p key
         /** \anchor cds_intrusive_LazyList_hp_extract
             The function searches an item with key equal to \p key,
-            unlinks it from the list, and returns it in \p dest parameter.
-            If the item with key equal to \p key is not found the function returns \p false.
+            unlinks it from the list, and returns it as \p guarded_ptr.
+            If \p key is not found the function returns an empty guarded pointer.
 
             Note the compare functor should accept a parameter of type \p Q that can be not the same as \p value_type.
 
             The \ref disposer specified in \p Traits class template parameter is called automatically
-            by garbage collector \p GC specified in class' template parameters when returned \ref guarded_ptr object
+            by garbage collector \p GC specified in class' template parameters when returned \p guarded_ptr object
             will be destroyed or released.
             @note Each \p guarded_ptr object uses the GC's guard that can be limited resource.
 
@@ -650,8 +650,7 @@ namespace cds { namespace intrusive {
             ord_list theList;
             // ...
             {
-                ord_list::guarded_ptr gp;
-                theList.extract( gp, 5 );
+                ord_list::guarded_ptr gp( theList.extract( 5 ));
                 // Deal with gp
                 // ...
 
@@ -660,14 +659,16 @@ namespace cds { namespace intrusive {
             \endcode
         */
         template <typename Q>
-        bool extract( guarded_ptr& dest, Q const& key )
+        guarded_ptr extract( Q const& key )
         {
-            return extract_at( &m_Head, dest.guard(), key, key_comparator() );
+            guarded_ptr gp;
+            extract_at( &m_Head, gp.guard(), key, key_comparator() );
+            return gp;
         }
 
         /// Extracts the item from the list with comparing functor \p pred
         /**
-            The function is an analog of \ref cds_intrusive_LazyList_hp_extract "extract(guarded_ptr&, Q const&)"
+            The function is an analog of \ref cds_intrusive_LazyList_hp_extract "extract(Q const&)"
             but \p pred predicate is used for key comparing.
 
             \p Less functor has the semantics like \p std::less but should take arguments of type \ref value_type and \p Q
@@ -675,9 +676,11 @@ namespace cds { namespace intrusive {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename Q, typename Less>
-        bool extract_with( guarded_ptr& dest, Q const& key, Less pred )
+        guarded_ptr extract_with( Q const& key, Less pred )
         {
-            return extract_at( &m_Head, dest.guard(), key, cds::opt::details::make_comparator_from_less<Less>() );
+            guarded_ptr gp;
+            extract_at( &m_Head, gp.guard(), key, cds::opt::details::make_comparator_from_less<Less>() );
+            return gp;
         }
 
         /// Finds the key \p key
@@ -756,12 +759,11 @@ namespace cds { namespace intrusive {
         /// Finds \p key and return the item found
         /** \anchor cds_intrusive_LazyList_hp_get
             The function searches the item with key equal to \p key
-            and assigns the item found to guarded pointer \p ptr.
-            The function returns \p true if \p key is found, and \p false otherwise.
-            If \p key is not found the \p ptr parameter is not changed.
+            and returns an guarded pointer to it.
+            If \p key is not found the function returns an empty guarded pointer.
 
             The \ref disposer specified in \p Traits class template parameter is called
-            by garbage collector \p GC automatically when returned \ref guarded_ptr object
+            by garbage collector \p GC automatically when returned \p guarded_ptr object
             will be destroyed or released.
             @note Each \p guarded_ptr object uses one GC's guard which can be limited resource.
 
@@ -771,8 +773,8 @@ namespace cds { namespace intrusive {
             ord_list theList;
             // ...
             {
-                ord_list::guarded_ptr gp;
-                if ( theList.get( gp, 5 )) {
+                ord_list::guarded_ptr gp(theList.get( 5 ));
+                if ( gp ) {
                     // Deal with gp
                     //...
                 }
@@ -784,14 +786,16 @@ namespace cds { namespace intrusive {
             should accept a parameter of type \p Q that can be not the same as \p value_type.
         */
         template <typename Q>
-        bool get( guarded_ptr& ptr, Q const& key )
+        guarded_ptr get( Q const& key )
         {
-            return get_at( &m_Head, ptr.guard(), key, key_comparator() );
+            guarded_ptr gp;
+            get_at( &m_Head, gp.guard(), key, key_comparator() );
+            return gp;
         }
 
         /// Finds \p key and return the item found
         /**
-            The function is an analog of \ref cds_intrusive_LazyList_hp_get "get( guarded_ptr& ptr, Q const&)"
+            The function is an analog of \ref cds_intrusive_LazyList_hp_get "get( Q const&)"
             but \p pred is used for comparing the keys.
 
             \p Less functor has the semantics like \p std::less but should take arguments of type \ref value_type and \p Q
@@ -799,9 +803,11 @@ namespace cds { namespace intrusive {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename Q, typename Less>
-        bool get_with( guarded_ptr& ptr, Q const& key, Less pred )
+        guarded_ptr get_with( Q const& key, Less pred )
         {
-            return get_at( &m_Head, ptr.guard(), key, cds::opt::details::make_comparator_from_less<Less>() );
+            guarded_ptr gp;
+            get_at( &m_Head, gp.guard(), key, cds::opt::details::make_comparator_from_less<Less>() );
+            return gp;
         }
 
         /// Clears the list
@@ -1031,11 +1037,11 @@ namespace cds { namespace intrusive {
         }
 
         template <typename Q, typename Compare>
-        bool extract_at( node_type * pHead, typename gc::Guard& gp, const Q& val, Compare cmp )
+        bool extract_at( node_type * pHead, typename guarded_ptr::native_guard& gp, const Q& val, Compare cmp )
         {
             position pos;
             if ( erase_at( pHead, val, cmp, [](value_type const &){}, pos )) {
-                gp.assign( pos.guards.template get<value_type>(position::guard_current_item) );
+                gp.set( pos.guards.template get<value_type>(position::guard_current_item) );
                 return true;
             }
             return false;
@@ -1071,7 +1077,7 @@ namespace cds { namespace intrusive {
         }
 
         template <typename Q, typename Compare>
-        bool get_at( node_type * pHead, typename gc::Guard& gp, Q const& val, Compare cmp )
+        bool get_at( node_type * pHead, typename guarded_ptr::native_guard& gp, Q const& val, Compare cmp )
         {
             position pos;
 
@@ -1080,7 +1086,7 @@ namespace cds { namespace intrusive {
                 && !pos.pCur->is_marked()
                 && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 )
             {
-                gp.assign( pos.guards.template get<value_type>( position::guard_current_item ));
+                gp.set( pos.guards.template get<value_type>( position::guard_current_item ));
                 return true;
             }
             return false;
index 8c2eadf2942ac446e9b481cde643ab24a74de390..5f039362542fc715f6ef922e1cf960581963a789 100644 (file)
@@ -181,7 +181,7 @@ namespace cds { namespace intrusive {
         typedef typename traits::item_counter item_counter;   ///< Item counting policy used
         typedef typename traits::memory_model  memory_model;   ///< Memory ordering. See cds::opt::memory_model option
 
-        typedef cds::gc::guarded_ptr< gc, value_type > guarded_ptr; ///< Guarded pointer
+        typedef typename gc::template guarded_ptr< value_type > guarded_ptr; ///< Guarded pointer
 
         //@cond
         // Rebind traits (split-list support)
@@ -633,8 +633,8 @@ namespace cds { namespace intrusive {
         /// Extracts the item from the list with specified \p key
         /** \anchor cds_intrusive_MichaelList_hp_extract
             The function searches an item with key equal to \p key,
-            unlinks it from the list, and returns it in \p dest parameter.
-            If the item with key equal to \p key is not found the function returns \p false.
+            unlinks it from the list, and returns it as \p guarded_ptr.
+            If \p key is not found returns an empty guarded pointer.
 
             Note the compare functor should accept a parameter of type \p Q that can be not the same as \p value_type.
 
@@ -648,24 +648,26 @@ namespace cds { namespace intrusive {
             ord_list theList;
             // ...
             {
-                ord_list::guarded_ptr gp;
-                theList.extract( gp, 5 );
-                // Deal with gp
-                // ...
-
+                ord_list::guarded_ptr gp(theList.extract( 5 ));
+                if ( gp ) {
+                    // Deal with gp
+                    // ...
+                }
                 // Destructor of gp releases internal HP guard
             }
             \endcode
         */
         template <typename Q>
-        bool extract( guarded_ptr& dest, Q const& key )
+        guarded_ptr extract( Q const& key )
         {
-            return extract_at( m_pHead, dest.guard(), key, key_comparator() );
+            guarded_ptr gp;
+            extract_at( m_pHead, gp.guard(), key, key_comparator() );
+            return gp;
         }
 
         /// Extracts the item using compare functor \p pred
         /**
-            The function is an analog of \ref cds_intrusive_MichaelList_hp_extract "extract(guarded_ptr&, Q const&)"
+            The function is an analog of \ref cds_intrusive_MichaelList_hp_extract "extract(Q const&)"
             but \p pred predicate is used for key comparing.
 
             \p Less functor has the semantics like \p std::less but should take arguments of type \ref value_type and \p Q
@@ -673,9 +675,11 @@ namespace cds { namespace intrusive {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename Q, typename Less>
-        bool extract_with( guarded_ptr& dest, Q const& key, Less pred )
+        guarded_ptr extract_with( Q const& key, Less pred )
         {
-            return extract_at( m_pHead, dest.guard(), key, cds::opt::details::make_comparator_from_less<Less>() );
+            guarded_ptr gp;
+            extract_at( m_pHead, gp.guard(), key, cds::opt::details::make_comparator_from_less<Less>() );
+            return gp;
         }
 
         /// Finds \p key in the list
@@ -759,9 +763,8 @@ namespace cds { namespace intrusive {
         /// Finds the \p key and return the item found
         /** \anchor cds_intrusive_MichaelList_hp_get
             The function searches the item with key equal to \p key
-            and assigns the item found to guarded pointer \p ptr.
-            The function returns \p true if \p key is found, and \p false otherwise.
-            If \p key is not found the \p ptr parameter is not changed.
+            and returns it as \p guarded_ptr.
+            If \p key is not found the function returns an empty guarded pointer.
 
             The \ref disposer specified in \p Traits class template parameter is called
             by garbage collector \p GC automatically when returned \ref guarded_ptr object
@@ -774,8 +777,8 @@ namespace cds { namespace intrusive {
             ord_list theList;
             // ...
             {
-                ord_list::guarded_ptr gp;
-                if ( theList.get( gp, 5 )) {
+                ord_list::guarded_ptr gp(theList.get( 5 ));
+                if ( gp ) {
                     // Deal with gp
                     //...
                 }
@@ -787,14 +790,16 @@ namespace cds { namespace intrusive {
             should accept a parameter of type \p Q that can be not the same as \p value_type.
         */
         template <typename Q>
-        bool get( guarded_ptr& ptr, Q const& key )
+        guarded_ptr get( Q const& key )
         {
-            return get_at( m_pHead, ptr.guard(), key, key_comparator() );
+            guarded_ptr gp;
+            get_at( m_pHead, gp.guard(), key, key_comparator() );
+            return gp;
         }
 
         /// Finds the \p key and return the item found
         /**
-            The function is an analog of \ref cds_intrusive_MichaelList_hp_get "get( guarded_ptr& ptr, Q const&)"
+            The function is an analog of \ref cds_intrusive_MichaelList_hp_get "get( Q const&)"
             but \p pred is used for comparing the keys.
 
             \p Less functor has the semantics like \p std::less but should take arguments of type \ref value_type and \p Q
@@ -802,9 +807,11 @@ namespace cds { namespace intrusive {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename Q, typename Less>
-        bool get_with( guarded_ptr& ptr, Q const& key, Less pred )
+        guarded_ptr get_with( Q const& key, Less pred )
         {
-            return get_at( m_pHead, ptr.guard(), key, cds::opt::details::make_comparator_from_less<Less>() );
+            guarded_ptr gp;
+            get_at( m_pHead, gp.guard(), key, cds::opt::details::make_comparator_from_less<Less>() );
+            return gp;
         }
 
         /// Clears the list
@@ -992,13 +999,13 @@ namespace cds { namespace intrusive {
         }
 
         template <typename Q, typename Compare>
-        bool extract_at( atomic_node_ptr& refHead, typename gc::Guard& dest, Q const& val, Compare cmp )
+        bool extract_at( atomic_node_ptr& refHead, typename guarded_ptr::native_guard& dest, Q const& val, Compare cmp )
         {
             position pos;
             back_off bkoff;
             while ( search( refHead, val, pos, cmp )) {
                 if ( unlink_node( pos ) ) {
-                    dest.assign( pos.guards.template get<value_type>( position::guard_current_item ) );
+                    dest.set( pos.guards.template get<value_type>( position::guard_current_item ) );
                     --m_ItemCounter;
                     return true;
                 }
@@ -1027,11 +1034,11 @@ namespace cds { namespace intrusive {
         }
 
         template <typename Q, typename Compare>
-        bool get_at( atomic_node_ptr& refHead, typename gc::Guard& guard, Q const& val, Compare cmp )
+        bool get_at( atomic_node_ptr& refHead, typename guarded_ptr::native_guard& guard, Q const& val, Compare cmp )
         {
             position pos;
             if ( search( refHead, val, pos, cmp )) {
-                guard.assign( pos.guards.template get<value_type>( position::guard_current_item ));
+                guard.set( pos.guards.template get<value_type>( position::guard_current_item ));
                 return true;
             }
             return false;
index 4d9a3b3461665c4a174bc68ab7f93bf7ead8977d..a07c6b55127ec6a3c2c32f9ae3674f116fa7ba36 100644 (file)
@@ -439,7 +439,6 @@ namespace ordlist {
             static int const nLimit = 20;
             typename OrdList::value_type arrItem[nLimit];
 
-
             {
                 int a[nLimit];
                 for (int i = 0; i < nLimit; ++i)
@@ -456,28 +455,27 @@ namespace ordlist {
                     CPPUNIT_ASSERT( l.insert( arrItem[i] ) );
 
                 for ( int i=0; i < nLimit; ++i ) {
-                    CPPUNIT_ASSERT( l.get( gp, arrItem[i].nKey ));
+                    gp = l.get( arrItem[i].nKey );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_ASSERT( gp->nKey == arrItem[i].nKey );
                     CPPUNIT_ASSERT( gp->nVal == arrItem[i].nVal );
-                    gp.release();
 
-                    CPPUNIT_ASSERT( l.extract( gp, arrItem[i].nKey ));
+                    gp = l.extract( arrItem[i].nKey );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_ASSERT( gp->nKey == arrItem[i].nKey );
                     CPPUNIT_ASSERT( gp->nVal == arrItem[i].nVal );
-                    gp.release();
 
-                    CPPUNIT_ASSERT( !l.get( gp, arrItem[i].nKey ));
+                    gp = l.get( arrItem[i].nKey );
+                    CPPUNIT_ASSERT( !gp );
                     CPPUNIT_ASSERT( gp.empty());
-                    CPPUNIT_ASSERT( !l.extract( gp, arrItem[i].nKey ));
+                    CPPUNIT_ASSERT( !l.extract( arrItem[i].nKey ));
                     CPPUNIT_ASSERT( gp.empty());
                 }
                 CPPUNIT_ASSERT( l.empty() );
-                CPPUNIT_ASSERT( !l.get( gp, nLimit/2 ));
-                CPPUNIT_ASSERT( gp.empty());
-                CPPUNIT_ASSERT( !l.extract( gp, nLimit/2 ));
-                CPPUNIT_ASSERT( gp.empty());
+                CPPUNIT_ASSERT( !l.get( nLimit/2 ));
+                CPPUNIT_ASSERT( !l.extract( nLimit/2 ));
 
                 // Apply retired pointer
                 OrdList::gc::force_dispose();
@@ -488,27 +486,28 @@ namespace ordlist {
 
                 for ( int i=0; i < nLimit; ++i ) {
                     other_item itm( arrItem[i].nKey );
-                    CPPUNIT_ASSERT( l.get_with( gp, itm, other_less() ));
+                    gp = l.get_with( itm, other_less() );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_ASSERT( gp->nKey == arrItem[i].nKey );
                     CPPUNIT_ASSERT( gp->nVal == arrItem[i].nVal );
-                    gp.release();
 
-                    CPPUNIT_ASSERT( l.extract_with( gp, itm, other_less() ));
+                    gp = l.extract_with( itm, other_less() );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_ASSERT( gp->nKey == arrItem[i].nKey );
                     CPPUNIT_ASSERT( gp->nVal == arrItem[i].nVal );
-                    gp.release();
 
-                    CPPUNIT_ASSERT( !l.get_with( gp, itm, other_less() ));
+                    gp = l.get_with( itm, other_less() );
+                    CPPUNIT_ASSERT( !gp );
                     CPPUNIT_ASSERT( gp.empty());
-                    CPPUNIT_ASSERT( !l.extract_with( gp, itm, other_less() ));
+                    CPPUNIT_ASSERT( !l.extract_with( itm, other_less() ));
                     CPPUNIT_ASSERT( gp.empty());
                 }
                 CPPUNIT_ASSERT( l.empty() );
-                CPPUNIT_ASSERT( !l.get_with( gp, other_item(nLimit/2), other_less() ));
+                CPPUNIT_ASSERT( !l.get_with( other_item(nLimit/2), other_less() ));
                 CPPUNIT_ASSERT( gp.empty());
-                CPPUNIT_ASSERT( !l.extract_with( gp, other_item(nLimit/2), other_less() ));
+                CPPUNIT_ASSERT( !l.extract_with( other_item(nLimit/2), other_less() ));
                 CPPUNIT_ASSERT( gp.empty());
 
                 // Apply retired pointer
index bbf238566be66f0175e74d5f25fee703a13bcc4e..63ff419a2266e2e94e16f2a2a7d786d301c0c4b2 100644 (file)
@@ -457,7 +457,6 @@ namespace ordlist {
             static int const nLimit = 20;
             typename OrdList::value_type arrItem[nLimit];
 
-
             {
                 int a[nLimit];
                 for (int i = 0; i < nLimit; ++i)
@@ -474,27 +473,28 @@ namespace ordlist {
                     CPPUNIT_ASSERT( l.insert( arrItem[i] ) );
 
                 for ( int i=0; i < nLimit; ++i ) {
-                    CPPUNIT_ASSERT( l.get( gp, arrItem[i].nKey ));
+                    gp = l.get( arrItem[i].nKey );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_ASSERT( gp->nKey == arrItem[i].nKey );
                     CPPUNIT_ASSERT( gp->nVal == arrItem[i].nVal );
-                    gp.release();
 
-                    CPPUNIT_ASSERT( l.extract( gp, arrItem[i].nKey ));
+                    gp = l.extract( arrItem[i].nKey );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_ASSERT( gp->nKey == arrItem[i].nKey );
                     CPPUNIT_ASSERT( gp->nVal == arrItem[i].nVal );
-                    gp.release();
 
-                    CPPUNIT_ASSERT( !l.get( gp, arrItem[i].nKey ));
+                    gp = l.get( arrItem[i].nKey );
+                    CPPUNIT_ASSERT( !gp );
                     CPPUNIT_ASSERT( gp.empty());
-                    CPPUNIT_ASSERT( !l.extract( gp, arrItem[i].nKey ));
+                    CPPUNIT_ASSERT( !l.extract( arrItem[i].nKey ));
                     CPPUNIT_ASSERT( gp.empty());
                 }
                 CPPUNIT_ASSERT( l.empty() );
-                CPPUNIT_ASSERT( !l.get( gp, nLimit/2 ));
+                CPPUNIT_ASSERT( !l.get( nLimit/2 ));
                 CPPUNIT_ASSERT( gp.empty());
-                CPPUNIT_ASSERT( !l.extract( gp, nLimit/2 ));
+                CPPUNIT_ASSERT( !l.extract( nLimit/2 ));
                 CPPUNIT_ASSERT( gp.empty());
 
                 // Apply retired pointer
@@ -506,27 +506,28 @@ namespace ordlist {
 
                 for ( int i=0; i < nLimit; ++i ) {
                     other_item itm( arrItem[i].nKey );
-                    CPPUNIT_ASSERT( l.get_with( gp, itm, other_less() ));
+                    gp = l.get_with( itm, other_less() );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_ASSERT( gp->nKey == arrItem[i].nKey );
                     CPPUNIT_ASSERT( gp->nVal == arrItem[i].nVal );
-                    gp.release();
 
-                    CPPUNIT_ASSERT( l.extract_with( gp, itm, other_less() ));
+                    gp = l.extract_with( itm, other_less() );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_ASSERT( gp->nKey == arrItem[i].nKey );
                     CPPUNIT_ASSERT( gp->nVal == arrItem[i].nVal );
-                    gp.release();
 
-                    CPPUNIT_ASSERT( !l.get_with( gp, itm, other_less() ));
+                    gp = l.get_with( itm, other_less() );
+                    CPPUNIT_ASSERT( !gp );
                     CPPUNIT_ASSERT( gp.empty());
-                    CPPUNIT_ASSERT( !l.extract_with( gp, itm, other_less() ));
+                    CPPUNIT_ASSERT( !l.extract_with( itm, other_less() ));
                     CPPUNIT_ASSERT( gp.empty());
                 }
                 CPPUNIT_ASSERT( l.empty() );
-                CPPUNIT_ASSERT( !l.get_with( gp, other_item(nLimit/2), other_less() ));
+                CPPUNIT_ASSERT( !l.get_with( other_item(nLimit/2), other_less() ));
                 CPPUNIT_ASSERT( gp.empty());
-                CPPUNIT_ASSERT( !l.extract_with( gp, other_item(nLimit/2), other_less() ));
+                CPPUNIT_ASSERT( !l.extract_with( other_item(nLimit/2), other_less() ));
                 CPPUNIT_ASSERT( gp.empty());
 
                 // Apply retired pointer
index 9fc3d5d7ac273bc238568744e475e05df925a5bb..b472bdb69a8f638ed4cf657555c5dce5ae79bce4 100644 (file)
@@ -469,27 +469,28 @@ namespace ordlist {
                 for ( int i = 0; i < nLimit; ++i ) {
                     int nKey = arr[i];
 
-                    CPPUNIT_ASSERT( l.get(gp, nKey));
+                    gp = l.get( nKey );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->nKey == nKey );
                     CPPUNIT_CHECK( gp->nVal == nKey * 2 );
-                    gp.release();
 
-                    CPPUNIT_ASSERT( l.extract(gp, nKey));
+                    gp = l.extract( nKey );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->nKey == nKey );
                     CPPUNIT_CHECK( gp->nVal == nKey*2 );
-                    gp.release();
 
-                    CPPUNIT_CHECK( !l.get(gp, nKey));
+                    gp = l.get( nKey );
+                    CPPUNIT_CHECK( !gp );
                     CPPUNIT_CHECK( gp.empty());
-                    CPPUNIT_CHECK( !l.extract( gp, nKey));
+                    CPPUNIT_CHECK( !l.extract( nKey));
                     CPPUNIT_CHECK( gp.empty());
                 }
                 CPPUNIT_ASSERT( l.empty());
-                CPPUNIT_CHECK( !l.get(gp, arr[0]));
+                CPPUNIT_CHECK( !l.get(arr[0]));
                 CPPUNIT_CHECK( gp.empty());
-                CPPUNIT_CHECK( !l.extract( gp, arr[0]));
+                CPPUNIT_CHECK( !l.extract( arr[0]));
                 CPPUNIT_CHECK( gp.empty());
             }
 
@@ -502,27 +503,28 @@ namespace ordlist {
                     int nKey = arr[i];
                     other_item key( nKey );
 
-                    CPPUNIT_ASSERT( l.get_with(gp, key, other_less()));
+                    gp = l.get_with( key, other_less() );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->nKey == nKey );
                     CPPUNIT_CHECK( gp->nVal == nKey * 2 );
-                    gp.release();
 
-                    CPPUNIT_ASSERT( l.extract_with(gp, key, other_less()));
+                    gp = l.extract_with( key, other_less() );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->nKey == nKey );
                     CPPUNIT_CHECK( gp->nVal == nKey*2 );
-                    gp.release();
 
-                    CPPUNIT_CHECK( !l.get_with(gp, key, other_less()));
+                    gp = l.get_with( key, other_less() );
+                    CPPUNIT_CHECK( !gp );
                     CPPUNIT_CHECK( gp.empty());
-                    CPPUNIT_CHECK( !l.extract_with( gp, key, other_less()));
+                    CPPUNIT_CHECK( !l.extract_with( key, other_less()));
                     CPPUNIT_CHECK( gp.empty());
                 }
                 CPPUNIT_ASSERT( l.empty());
-                CPPUNIT_CHECK( !l.get_with(gp, other_item(arr[0]), other_less()));
+                CPPUNIT_CHECK( !l.get_with(other_item(arr[0]), other_less()));
                 CPPUNIT_CHECK( gp.empty());
-                CPPUNIT_CHECK( !l.extract_with( gp, other_item(arr[0]), other_less()));
+                CPPUNIT_CHECK( !l.extract_with( other_item(arr[0]), other_less()));
                 CPPUNIT_CHECK( gp.empty());
             }
 
index bbe85da175b1dd369f560955c1f6a58e45eef59c..27f63969b3352f0124ffc042d1a38cb202090f05 100644 (file)
@@ -297,27 +297,28 @@ namespace ordlist {
                 for ( int i = 0; i < nLimit; ++i ) {
                     int nKey = arr[i];
 
-                    CPPUNIT_ASSERT( l.get(gp, nKey));
+                    gp = l.get( nKey );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->first == nKey );
                     CPPUNIT_CHECK( gp->second.m_val == nKey * 2 );
-                    gp.release();
 
-                    CPPUNIT_ASSERT( l.extract(gp, nKey));
+                    gp = l.extract( nKey );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->first == nKey );
                     CPPUNIT_CHECK( gp->second.m_val == nKey*2 );
-                    gp.release();
 
-                    CPPUNIT_CHECK( !l.get(gp, nKey));
+                    gp = l.get( nKey );
+                    CPPUNIT_CHECK( !gp );
                     CPPUNIT_CHECK( gp.empty());
-                    CPPUNIT_CHECK( !l.extract( gp, nKey));
+                    CPPUNIT_CHECK( !l.extract( nKey));
                     CPPUNIT_CHECK( gp.empty());
                 }
                 CPPUNIT_ASSERT( l.empty());
-                CPPUNIT_CHECK( !l.get(gp, arr[0]));
+                CPPUNIT_CHECK( !l.get(arr[0]));
                 CPPUNIT_CHECK( gp.empty());
-                CPPUNIT_CHECK( !l.extract( gp, arr[0]));
+                CPPUNIT_CHECK( !l.extract( arr[0]));
                 CPPUNIT_CHECK( gp.empty());
             }
 
@@ -330,27 +331,28 @@ namespace ordlist {
                     int nKey = arr[i];
                     other_key key = float(nKey + 0.3);
 
-                    CPPUNIT_ASSERT( l.get_with(gp, key, other_less()));
+                    gp = l.get_with( key, other_less() );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->first == nKey );
                     CPPUNIT_CHECK( gp->second.m_val == nKey * 2 );
-                    gp.release();
 
-                    CPPUNIT_ASSERT( l.extract_with(gp, key, other_less()));
+                    gp = l.extract_with( key, other_less() );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->first == nKey );
                     CPPUNIT_CHECK( gp->second.m_val == nKey*2 );
-                    gp.release();
 
-                    CPPUNIT_CHECK( !l.get_with(gp, key, other_less()));
+                    gp = l.get_with( key, other_less() );
+                    CPPUNIT_CHECK( !gp );
                     CPPUNIT_CHECK( gp.empty());
-                    CPPUNIT_CHECK( !l.extract_with( gp, key, other_less()));
+                    CPPUNIT_CHECK( !l.extract_with( key, other_less()));
                     CPPUNIT_CHECK( gp.empty());
                 }
                 CPPUNIT_ASSERT( l.empty());
-                CPPUNIT_CHECK( !l.get_with(gp, 3.4f, other_less()));
+                CPPUNIT_CHECK( !l.get_with(3.4f, other_less()));
                 CPPUNIT_CHECK( gp.empty());
-                CPPUNIT_CHECK( !l.extract_with( gp, 3.4f, other_less()));
+                CPPUNIT_CHECK( !l.extract_with( 3.4f, other_less()));
                 CPPUNIT_CHECK( gp.empty());
             }
         }
index 5ce56fc060652cb743cb96a3afb3798a097fa23d..4f3665df7c58ad0c1dbf3caac7af4bfa6d7be67a 100644 (file)
@@ -470,27 +470,28 @@ namespace ordlist {
                 for ( int i = 0; i < nLimit; ++i ) {
                     int nKey = arr[i];
 
-                    CPPUNIT_ASSERT( l.get(gp, nKey));
+                    gp = l.get( nKey );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->nKey == nKey );
                     CPPUNIT_CHECK( gp->nVal == nKey * 2 );
-                    gp.release();
 
-                    CPPUNIT_ASSERT( l.extract(gp, nKey));
+                    gp = l.extract( nKey );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->nKey == nKey );
                     CPPUNIT_CHECK( gp->nVal == nKey*2 );
-                    gp.release();
 
-                    CPPUNIT_CHECK( !l.get(gp, nKey));
+                    gp = l.get( nKey );
+                    CPPUNIT_CHECK( !gp );
                     CPPUNIT_CHECK( gp.empty());
-                    CPPUNIT_CHECK( !l.extract( gp, nKey));
+                    CPPUNIT_CHECK( !l.extract( nKey));
                     CPPUNIT_CHECK( gp.empty());
                 }
                 CPPUNIT_ASSERT( l.empty());
-                CPPUNIT_CHECK( !l.get(gp, arr[0]));
+                CPPUNIT_CHECK( !l.get(arr[0]));
                 CPPUNIT_CHECK( gp.empty());
-                CPPUNIT_CHECK( !l.extract( gp, arr[0]));
+                CPPUNIT_CHECK( !l.extract( arr[0]));
                 CPPUNIT_CHECK( gp.empty());
             }
 
@@ -503,27 +504,28 @@ namespace ordlist {
                     int nKey = arr[i];
                     other_item key( nKey );
 
-                    CPPUNIT_ASSERT( l.get_with(gp, key, other_less()));
+                    gp = l.get_with( key, other_less() );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->nKey == nKey );
                     CPPUNIT_CHECK( gp->nVal == nKey * 2 );
-                    gp.release();
 
-                    CPPUNIT_ASSERT( l.extract_with(gp, key, other_less()));
+                    gp = l.extract_with( key, other_less() );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->nKey == nKey );
                     CPPUNIT_CHECK( gp->nVal == nKey*2 );
-                    gp.release();
 
-                    CPPUNIT_CHECK( !l.get_with(gp, key, other_less()));
+                    gp = l.get_with( key, other_less() );
+                    CPPUNIT_CHECK( !gp );
                     CPPUNIT_CHECK( gp.empty());
-                    CPPUNIT_CHECK( !l.extract_with( gp, key, other_less()));
+                    CPPUNIT_CHECK( !l.extract_with( key, other_less()));
                     CPPUNIT_CHECK( gp.empty());
                 }
                 CPPUNIT_ASSERT( l.empty());
-                CPPUNIT_CHECK( !l.get_with(gp, other_item(arr[0]), other_less()));
+                CPPUNIT_CHECK( !l.get_with(other_item(arr[0]), other_less()));
                 CPPUNIT_CHECK( gp.empty());
-                CPPUNIT_CHECK( !l.extract_with( gp, other_item(arr[0]), other_less()));
+                CPPUNIT_CHECK( !l.extract_with( other_item(arr[0]), other_less()));
                 CPPUNIT_CHECK( gp.empty());
             }
         }
index 68e9b921d1d40ef7a14d8a1297c1d2a71a78f113..c2b12e3378e9a5a3c95a47c4334ec87bc57713a6 100644 (file)
@@ -307,27 +307,28 @@ namespace ordlist {
                 for ( int i = 0; i < nLimit; ++i ) {
                     int nKey = arr[i];
 
-                    CPPUNIT_ASSERT( l.get(gp, nKey));
+                    gp = l.get( nKey );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->first == nKey );
                     CPPUNIT_CHECK( gp->second.m_val == nKey * 2 );
-                    gp.release();
 
-                    CPPUNIT_ASSERT( l.extract(gp, nKey));
+                    gp = l.extract( nKey );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->first == nKey );
                     CPPUNIT_CHECK( gp->second.m_val == nKey*2 );
-                    gp.release();
 
-                    CPPUNIT_CHECK( !l.get(gp, nKey));
+                    gp = l.get( nKey );
+                    CPPUNIT_CHECK( !gp );
                     CPPUNIT_CHECK( gp.empty());
-                    CPPUNIT_CHECK( !l.extract( gp, nKey));
+                    CPPUNIT_CHECK( !l.extract( nKey));
                     CPPUNIT_CHECK( gp.empty());
                 }
                 CPPUNIT_ASSERT( l.empty());
-                CPPUNIT_CHECK( !l.get(gp, arr[0]));
+                CPPUNIT_CHECK( !l.get(arr[0]));
                 CPPUNIT_CHECK( gp.empty());
-                CPPUNIT_CHECK( !l.extract( gp, arr[0]));
+                CPPUNIT_CHECK( !l.extract( arr[0]));
                 CPPUNIT_CHECK( gp.empty());
             }
 
@@ -340,27 +341,28 @@ namespace ordlist {
                     int nKey = arr[i];
                     other_key key = float(nKey + 0.3);
 
-                    CPPUNIT_ASSERT( l.get_with(gp, key, other_less()));
+                    gp = l.get_with( key, other_less() );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->first == nKey );
                     CPPUNIT_CHECK( gp->second.m_val == nKey * 2 );
-                    gp.release();
 
-                    CPPUNIT_ASSERT( l.extract_with(gp, key, other_less()));
+                    gp = l.extract_with( key, other_less() );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->first == nKey );
                     CPPUNIT_CHECK( gp->second.m_val == nKey*2 );
-                    gp.release();
 
-                    CPPUNIT_CHECK( !l.get_with(gp, key, other_less()));
+                    gp = l.get_with( key, other_less() );
+                    CPPUNIT_CHECK( !gp );
                     CPPUNIT_CHECK( gp.empty());
-                    CPPUNIT_CHECK( !l.extract_with( gp, key, other_less()));
+                    CPPUNIT_CHECK( !l.extract_with( key, other_less()));
                     CPPUNIT_CHECK( gp.empty());
                 }
                 CPPUNIT_ASSERT( l.empty());
-                CPPUNIT_CHECK( !l.get_with(gp, 3.4f, other_less()));
+                CPPUNIT_CHECK( !l.get_with( 3.4f, other_less()));
                 CPPUNIT_CHECK( gp.empty());
-                CPPUNIT_CHECK( !l.extract_with( gp, 3.4f, other_less()));
+                CPPUNIT_CHECK( !l.extract_with( 3.4f, other_less()));
                 CPPUNIT_CHECK( gp.empty());
             }
         }