movable quarded_ptr: SplitList
authorkhizmax <khizmax@gmail.com>
Tue, 18 Nov 2014 17:27:19 +0000 (20:27 +0300)
committerkhizmax <khizmax@gmail.com>
Tue, 18 Nov 2014 17:27:19 +0000 (20:27 +0300)
cds/container/split_list_map.h
cds/container/split_list_set.h
cds/gc/impl/dhp_decl.h
cds/gc/impl/hp_decl.h
cds/intrusive/split_list.h
tests/test-hdr/map/hdr_map.h
tests/test-hdr/set/hdr_intrusive_set.h
tests/test-hdr/set/hdr_set.h

index d9af00eb83f1aca845f4a39591d037994d12be47..de219d16253c6ae3f61c0c3d8176e256ca880228 100644 (file)
@@ -145,7 +145,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;
 
     public:
         /// Forward iterator (see \p SplitListSet::iterator)
@@ -412,12 +412,12 @@ namespace cds { namespace container {
         /// Extracts the item with specified \p key
         /** \anchor cds_nonintrusive_SplitListMap_hp_extract
             The function searches an item with key equal to \p key,
-            unlinks it from the map, 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 map, 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 may be not the same as \p value_type.
 
-            The extracted item is freed automatically when returned \ref guarded_ptr object will be destroyed or released.
+            The extracted item is freed automatically 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.
 
             Usage:
@@ -426,24 +426,26 @@ namespace cds { namespace container {
             splitlist_map theMap;
             // ...
             {
-                splitlist_map::guarded_ptr gp;
-                theMap.extract( gp, 5 );
-                // Deal with gp
-                // ...
-
+                splitlist_map::guarded_ptr gp(theMap.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 base_class::extract_( dest.guard(), key );
+            guarded_ptr gp;
+            base_class::extract_( gp.guard(), key );
+            return gp;
         }
 
         /// Extracts the item using compare functor \p pred
         /**
-            The function is an analog of \ref cds_nonintrusive_SplitListMap_hp_extract "extract(guarded_ptr&, K const&)"
+            The function is an analog of \ref cds_nonintrusive_SplitListMap_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 value_type and \p K
@@ -451,10 +453,12 @@ namespace cds { namespace container {
             \p pred must imply the same element order as the comparator used for building the map.
         */
         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 base_class::extract_with_( dest.guard(), key, cds::details::predicate_wrapper<value_type, Less, key_accessor>() );
+            guarded_ptr gp;
+            base_class::extract_with_( gp.guard(), key, cds::details::predicate_wrapper<value_type, Less, key_accessor>() );
+            return gp;
         }
 
         /// Finds the key \p key
@@ -527,9 +531,8 @@ namespace cds { namespace container {
         /// Finds \p key and return the item found
         /** \anchor cds_nonintrusive_SplitListMap_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 function returns an empty guarded pointer.
 
             @note Each \p guarded_ptr object uses one GC's guard which can be limited resource.
 
@@ -539,8 +542,8 @@ namespace cds { namespace container {
             splitlist_map theMap;
             // ...
             {
-                splitlist_map::guarded_ptr gp;
-                if ( theMap.get( gp, 5 )) {
+                splitlist_map::guarded_ptr gp(theMap.get( 5 ));
+                if ( gp ) {
                     // Deal with gp
                     //...
                 }
@@ -552,14 +555,16 @@ namespace cds { namespace container {
             should accept a parameter of type \p K that can be not the same as \p value_type.
         */
         template <typename K>
-        bool get( guarded_ptr& ptr, K const& key )
+        guarded_ptr get( K const& key )
         {
-            return base_class::get_( ptr.guard(), key );
+            guarded_ptr gp;
+            base_class::get_( gp.guard(), key );
+            return gp;
         }
 
         /// Finds \p key and return the item found
         /**
-            The function is an analog of \ref cds_nonintrusive_SplitListMap_hp_get "get( guarded_ptr&, K const&)"
+            The function is an analog of \ref cds_nonintrusive_SplitListMap_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 value_type and \p K
@@ -567,10 +572,12 @@ namespace cds { namespace container {
             \p pred must imply the same element order as the comparator used for building the map.
         */
         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 base_class::get_with_( ptr.guard(), key, cds::details::predicate_wrapper<value_type, Less, key_accessor>() );
+            guarded_ptr gp;
+            base_class::get_with_( gp.guard(), key, cds::details::predicate_wrapper<value_type, Less, key_accessor>() );
+            return gp;
         }
 
         /// Clears the map (not atomic)
index 0f79c3a55b95a7c129756d748d313235d385742c..ba83b95c6c65f2ee72f8eabcabec4cf09ef7b5f8 100644 (file)
@@ -160,7 +160,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;
 
     protected:
         //@cond
@@ -549,12 +549,12 @@ namespace cds { namespace container {
         /// Extracts the item with specified \p key
         /** \anchor cds_nonintrusive_SplitListSet_hp_extract
             The function searches an item with key equal to \p key,
-            unlinks it from the set, 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 set, 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 may be not the same as \p value_type.
 
-            The extracted item is freed automatically when returned \ref guarded_ptr object will be destroyed or released.
+            The extracted item is freed automatically 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.
 
             Usage:
@@ -563,24 +563,26 @@ namespace cds { namespace container {
             splitlist_set theSet;
             // ...
             {
-                splitlist_set::guarded_ptr gp;
-                theSet.extract( gp, 5 );
-                // Deal with gp
-                // ...
-
+                splitlist_set::guarded_ptr gp(theSet.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_( dest.guard(), key );
+            guarded_ptr gp;
+            extract_( gp.guard(), key );
+            return gp;
         }
 
         /// Extracts the item using compare functor \p pred
         /**
-            The function is an analog of \ref cds_nonintrusive_SplitListSet_hp_extract "extract(guarded_ptr&, Q const&)"
+            The function is an analog of \ref cds_nonintrusive_SplitListSet_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
@@ -588,9 +590,11 @@ namespace cds { namespace container {
             \p pred must imply the same element order as the comparator used for building the set.
         */
         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_with_( dest.guard(), key, pred );
+            guarded_ptr gp;
+            extract_with_( gp.guard(), key, pred );
+            return gp;
         }
 
         /// Finds the key \p key
@@ -683,9 +687,8 @@ namespace cds { namespace container {
         /// Finds the key \p key and return the item found
         /** \anchor cds_nonintrusive_SplitListSet_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.
 
@@ -695,8 +698,8 @@ namespace cds { namespace container {
             splitlist_set theSet;
             // ...
             {
-                splitlist_set::guarded_ptr gp;
-                if ( theSet.get( gp, 5 )) {
+                splitlist_set::guarded_ptr gp(theSet.get( 5 ));
+                if ( gp ) {
                     // Deal with gp
                     //...
                 }
@@ -708,14 +711,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_( ptr.guard(), key );
+            guarded_ptr gp;
+            get_( gp.guard(), key );
+            return gp;
         }
 
         /// Finds \p key and return the item found
         /**
-            The function is an analog of \ref cds_nonintrusive_SplitListSet_hp_get "get( guarded_ptr&, Q const&)"
+            The function is an analog of \ref cds_nonintrusive_SplitListSet_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
@@ -723,9 +728,11 @@ namespace cds { namespace container {
             \p pred must imply the same element order as the comparator used for building the set.
         */
         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_with_( ptr.guard(), key, pred );
+            guarded_ptr gp;
+            get_with_( gp.guard(), key, pred );
+            return gp;
         }
 
         /// Clears the set (not atomic)
@@ -762,14 +769,14 @@ namespace cds { namespace container {
         using base_class::get_;
 
         template <typename Q, typename Less>
-        bool extract_with_( typename gc::Guard& guard, Q const& key, Less pred )
+        bool extract_with_( typename guarded_ptr::native_guard& guard, Q const& key, Less pred )
         {
             CDS_UNUSED( pred );
             return base_class::extract_with_( guard, key, typename maker::template predicate_wrapper<Less>::type() );
         }
 
         template <typename Q, typename Less>
-        bool get_with_( typename gc::Guard& guard, Q const& key, Less pred )
+        bool get_with_( typename guarded_ptr::native_guard& guard, Q const& key, Less pred )
         {
             CDS_UNUSED( pred );
             return base_class::get_with_( guard, key, typename maker::template predicate_wrapper<Less>::type() );
index a0e4d4af55e28d23c49289de2721192823d266d8..333c6d7985544e54b22ce823414d227181b65b9c 100644 (file)
@@ -450,13 +450,13 @@ namespace cds { namespace gc {
 
             //@cond
             /// Initializes guarded pointer with \p p
-            guarded_ptr( guarded_type * p ) CDS_NOEXCEPT
+            explicit guarded_ptr( guarded_type * p ) CDS_NOEXCEPT
             {
                 alloc_guard();
                 assert( m_guard.is_initialized() );
                 m_guard.set( p );
             }
-            guarded_ptr( std::nullptr_t ) CDS_NOEXCEPT
+            explicit guarded_ptr( std::nullptr_t ) CDS_NOEXCEPT
             {}
             //@endcond
 
index 72de7d0e78a6338fe861913fcb83feaa3d2115d6..56c1db6ffa53b62791ab2098aac71b90b525397f 100644 (file)
@@ -444,13 +444,13 @@ namespace cds { namespace gc {
 
             //@cond
             /// Initializes guarded pointer with \p p
-            guarded_ptr( guarded_type * p ) CDS_NOEXCEPT
+            explicit guarded_ptr( guarded_type * p ) CDS_NOEXCEPT
             {
                 alloc_guard();
                 assert( m_pGuard );
                 m_pGuard->set(p);
             }
-            guarded_ptr( std::nullptr_t ) CDS_NOEXCEPT
+            explicit guarded_ptr( std::nullptr_t ) CDS_NOEXCEPT
                 : m_pGuard( nullptr )
             {}
             //@endcond
index 119e10dd88cdce9b9c7257c2af93d99c4a7de7f3..4f7125fc56da808d598d5014a43d4132a9d3f22d 100644 (file)
@@ -298,7 +298,7 @@ namespace cds { namespace intrusive {
             }
 
             template <typename Q, typename Compare>
-            bool extract_at( dummy_node_type * pHead, typename gc::Guard& guard, split_list::details::search_value_type<Q> const& val, Compare cmp )
+            bool extract_at( dummy_node_type * pHead, typename guarded_ptr::native_guard& guard, split_list::details::search_value_type<Q> const& val, Compare cmp )
             {
                 assert( pHead != nullptr );
                 bucket_head_type h(pHead);
@@ -322,7 +322,7 @@ namespace cds { namespace intrusive {
             }
 
             template <typename Q, typename Compare>
-            bool get_at( dummy_node_type * pHead, typename gc::Guard& guard, split_list::details::search_value_type<Q> const& val, Compare cmp )
+            bool get_at( dummy_node_type * pHead, typename guarded_ptr::native_guard& guard, split_list::details::search_value_type<Q> const& val, Compare cmp )
             {
                 assert( pHead != nullptr );
                 bucket_head_type h(pHead);
@@ -489,7 +489,7 @@ namespace cds { namespace intrusive {
         }
 
         template <typename Q, typename Compare>
-        bool get_( typename gc::Guard& guard, Q const& val, Compare cmp )
+        bool get_( typename guarded_ptr::native_guard& guard, Q const& val, Compare cmp )
         {
             size_t nHash = hash_value( val );
             split_list::details::search_value_type<Q const>  sv( val, split_list::regular_hash( nHash ));
@@ -500,13 +500,13 @@ namespace cds { namespace intrusive {
         }
 
         template <typename Q>
-        bool get_( typename gc::Guard& guard, Q const& key)
+        bool get_( typename guarded_ptr::native_guard& guard, Q const& key )
         {
             return get_( guard, key, key_comparator());
         }
 
         template <typename Q, typename Less>
-        bool get_with_( typename gc::Guard& guard, Q const& key, Less )
+        bool get_with_( typename guarded_ptr::native_guard& guard, Q const& key, Less )
         {
             return get_( guard, key, typename wrapped_ordered_list::template make_compare_from_less<Less>());
         }
@@ -546,10 +546,10 @@ namespace cds { namespace intrusive {
         }
 
         template <typename Q, typename Compare>
-        bool extract_( typename gc::Guard& guard, Q const& val, Compare cmp )
+        bool extract_( typename guarded_ptr::native_guard& guard, Q const& val, Compare cmp )
         {
             size_t nHash = hash_value( val );
-            split_list::details::search_value_type<Q const>  sv( val, split_list::regular_hash( nHash ));
+            split_list::details::search_value_type<Q const> sv( val, split_list::regular_hash( nHash ));
             dummy_node_type * pHead = get_bucket( nHash );
             assert( pHead != nullptr );
 
@@ -563,17 +563,16 @@ namespace cds { namespace intrusive {
         }
 
         template <typename Q>
-        bool extract_( typename gc::Guard& guard, Q const& key)
+        bool extract_( typename guarded_ptr::native_guard& guard, Q const& key )
         {
             return extract_( guard, key, key_comparator());
         }
 
         template <typename Q, typename Less>
-        bool extract_with_( typename gc::Guard& guard, Q const& key, Less )
+        bool extract_with_( typename guarded_ptr::native_guard& guard, Q const& key, Less )
         {
             return extract_( guard, key, typename wrapped_ordered_list::template make_compare_from_less<Less>() );
         }
-
         //@endcond
 
     public:
@@ -811,13 +810,13 @@ namespace cds { namespace intrusive {
         /// Extracts the item with specified \p key
         /** \anchor cds_intrusive_SplitListSet_hp_extract
             The function searches an item with key equal to \p key,
-            unlinks it from the set, 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 set, 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 may be not the same as \p value_type.
 
-            The \ref disposer specified in \p OrderedList class' template parameter is called automatically
-            by garbage collector \p GC when returned \ref guarded_ptr object will be destroyed or released.
+            The \p disposer specified in \p OrderedList class' template parameter is called automatically
+            by garbage collector \p GC 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.
 
             Usage:
@@ -826,24 +825,26 @@ namespace cds { namespace intrusive {
             splitlist_set theSet;
             // ...
             {
-                splitlist_set::guarded_ptr gp;
-                theSet.extract( gp, 5 );
-                // Deal with gp
-                // ...
-
+                splitlist_set::guarded_ptr gp( theSet.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_( dest.guard(), key );
+            guarded_ptr gp;
+            extract_( gp.guard(), key );
+            return gp;
         }
 
         /// Extracts the item using compare functor \p pred
         /**
-            The function is an analog of \ref cds_intrusive_SplitListSet_hp_extract "extract(guarded_ptr&, Q const&)"
+            The function is an analog of \ref cds_intrusive_SplitListSet_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
@@ -851,9 +852,11 @@ namespace cds { namespace intrusive {
             \p pred must imply the same element order as the comparator used for building the set.
         */
         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_with_( dest.guard(), key, pred );
+            guarded_ptr gp;
+            extract_with_( gp.guard(), key, pred );
+            return gp;
         }
 
         /// Finds the key \p key
@@ -944,12 +947,11 @@ namespace cds { namespace intrusive {
         /// Finds the key \p key and return the item found
         /** \anchor cds_intrusive_SplitListSet_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.
 
-            The \ref disposer specified in \p OrderedList class' template parameter is called
-            by garbage collector \p GC automatically when returned \ref guarded_ptr object
+            The \p disposer specified in \p OrderedList 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.
 
@@ -959,8 +961,8 @@ namespace cds { namespace intrusive {
             splitlist_set theSet;
             // ...
             {
-                splitlist_set::guarded_ptr gp;
-                if ( theSet.get( gp, 5 )) {
+                splitlist_set::guarded_ptr gp = theSet.get( 5 );
+                if ( gp ) {
                     // Deal with gp
                     //...
                 }
@@ -972,14 +974,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_( ptr.guard(), key );
+            guarded_ptr gp;
+            get_( gp.guard(), key );
+            return gp;
         }
 
         /// Finds the key \p key and return the item found
         /**
-            The function is an analog of \ref cds_intrusive_SplitListSet_hp_get "get( guarded_ptr& ptr, Q const&)"
+            The function is an analog of \ref cds_intrusive_SplitListSet_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
@@ -987,9 +991,11 @@ namespace cds { namespace intrusive {
             \p pred must imply the same element order as the comparator used for building the set.
         */
         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_with_( ptr.guard(), key, pred );
+            guarded_ptr gp;
+            get_with_( gp.guard(), key, pred );
+            return gp;
         }
 
         /// Returns item count in the set
index 7cdfb1a407d22cc3e7672a03f33a217f86b6d691..81462dd4e13b8a3f836a939a8f7fa5fd16ac77c1 100644 (file)
@@ -209,19 +209,21 @@ namespace map {
 
                 for ( int i = 0; i < nLimit; ++i ) {
                     int nKey = arrRandom[i];
-                    CPPUNIT_ASSERT( m.get(gp, nKey ));
+                    gp = m.get( nKey );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->first == nKey );
                     CPPUNIT_CHECK( gp->second.m_val == nKey );
 
-                    CPPUNIT_ASSERT( m.extract(gp, nKey));
+                    gp = m.extract( nKey );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->first == nKey );
                     CPPUNIT_CHECK( gp->second.m_val == nKey );
-                    CPPUNIT_CHECK( !m.get(gp, nKey));
-                    gp.release();
+                    gp = m.get( nKey );
+                    CPPUNIT_CHECK( !gp );
 
-                    CPPUNIT_CHECK( !m.extract(gp, nKey));
+                    CPPUNIT_CHECK( !m.extract(nKey));
                     CPPUNIT_CHECK( gp.empty());
                 }
                 CPPUNIT_ASSERT( m.empty() );
@@ -231,19 +233,21 @@ namespace map {
 
                 for ( int i = 0; i < nLimit; ++i ) {
                     int nKey = arrRandom[i];
-                    CPPUNIT_ASSERT( m.get_with(gp, other_item(nKey), other_less() ));
+                    gp = m.get_with( other_item( nKey ), other_less() );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->first == nKey );
                     CPPUNIT_CHECK( gp->second.m_val == nKey );
 
-                    CPPUNIT_ASSERT( m.extract_with(gp, other_item(nKey), other_less() ));
+                    gp = m.extract_with( other_item( nKey ), other_less() );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->first == nKey );
                     CPPUNIT_CHECK( gp->second.m_val == nKey );
-                    CPPUNIT_CHECK( !m.get_with(gp, other_item(nKey), other_less() ));
-                    gp.release();
+                    gp = m.get_with( other_item( nKey ), other_less() );
+                    CPPUNIT_CHECK( !gp );
 
-                    CPPUNIT_CHECK( !m.extract_with(gp, other_item(nKey), other_less() ));
+                    CPPUNIT_CHECK( !m.extract_with(other_item(nKey), other_less() ));
                     CPPUNIT_CHECK( gp.empty());
                 }
                 CPPUNIT_ASSERT( m.empty() );
index fa06ddbb7dd7eabb7a888b2ce92c563877072d8f..5c69aff28c318f5382e08db580fb364e5fa60759 100644 (file)
@@ -503,43 +503,47 @@ namespace set {
                 guarded_ptr gp;
                 for ( size_t i = 0; i < nLimit; i += 2 ) {
                     int nKey = arr[i];
-                    CPPUNIT_ASSERT( s.get( gp, nKey ));
+                    gp = s.get( nKey );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->nKey == nKey );
                     CPPUNIT_CHECK( gp->nVal == nKey * 2 );
 
-                    CPPUNIT_ASSERT( s.extract( gp, nKey ));
+                    gp = s.extract( nKey );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty() );
                     CPPUNIT_CHECK( gp->nKey == nKey );
                     CPPUNIT_CHECK( gp->nVal == nKey * 2 );
-                    gp.release();
 
-                    CPPUNIT_CHECK( !s.get( gp, nKey ));
+                    gp = s.get( nKey );
+                    CPPUNIT_CHECK( !gp );
                     CPPUNIT_ASSERT( gp.empty() );
-                    CPPUNIT_CHECK( !s.extract( gp, nKey ));
+                    CPPUNIT_CHECK( !s.extract( nKey ));
                     CPPUNIT_CHECK( gp.empty() );
 
                     nKey = arr[i+1];
-                    CPPUNIT_ASSERT( s.get_with( gp, nKey, less<value_type>() ));
+                    gp = s.get_with( nKey, less<value_type>() );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_CHECK( gp->nKey == nKey );
                     CPPUNIT_CHECK( gp->nVal == nKey * 2 );
 
-                    CPPUNIT_ASSERT( s.extract_with( gp, nKey, less<value_type>() ));
+                    gp = s.extract_with( nKey, less<value_type>() );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty() );
                     CPPUNIT_CHECK( gp->nKey == nKey );
                     CPPUNIT_CHECK( gp->nVal == nKey * 2 );
-                    gp.release();
 
-                    CPPUNIT_CHECK( !s.get_with( gp, nKey, less<value_type>() ));
+                    gp = s.get_with( nKey, less<value_type>() );
+                    CPPUNIT_CHECK( !gp );
                     CPPUNIT_CHECK( gp.empty());
-                    CPPUNIT_CHECK( !s.extract_with( gp, nKey, less<value_type>() ));
+                    CPPUNIT_CHECK( !s.extract_with( nKey, less<value_type>() ));
                     CPPUNIT_CHECK( gp.empty());
                 }
                 CPPUNIT_CHECK( s.empty() );
                 CPPUNIT_CHECK( check_size( s, 0 ));
 
-                CPPUNIT_CHECK( !s.get( gp, 100 ));
-                CPPUNIT_CHECK( !s.extract( gp, 100 ));
+                CPPUNIT_CHECK( !s.get( 100 ));
+                CPPUNIT_CHECK( !s.extract( 100 ));
                 CPPUNIT_CHECK( gp.empty() );
 
                 Set::gc::force_dispose();
index d08ce90be61db5d65a758eedfdbd7286840d1bd7..261f1bf4bb584c56e3b6c0f1a037026f5fbfb8c5 100644 (file)
@@ -360,19 +360,21 @@ namespace set {
 
                 for ( int i = 0; i < nLimit; ++i ) {
                     int nKey = arrRandom[i];
-                    CPPUNIT_ASSERT( s.get(gp, nKey ));
+                    gp = s.get( nKey );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->nKey == nKey );
                     CPPUNIT_CHECK( gp->nVal == nKey );
 
-                    CPPUNIT_ASSERT( s.extract(gp, nKey));
+                    gp = s.extract( nKey );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->nKey == nKey );
                     CPPUNIT_CHECK( gp->nVal == nKey );
-                    CPPUNIT_CHECK( !s.get(gp, nKey));
-                    gp.release();
+                    CPPUNIT_CHECK( !s.get(nKey));
 
-                    CPPUNIT_CHECK( !s.extract(gp, nKey));
+                    gp = s.extract( nKey );
+                    CPPUNIT_CHECK( !gp );
                     CPPUNIT_CHECK( gp.empty());
                 }
                 CPPUNIT_ASSERT( s.empty() );
@@ -383,19 +385,21 @@ namespace set {
 
                 for ( int i = 0; i < nLimit; ++i ) {
                     int nKey = arrRandom[i];
-                    CPPUNIT_ASSERT( s.get_with(gp, other_item(nKey), other_less() ));
+                    gp = s.get_with( other_item( nKey ), other_less() );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->nKey == nKey );
                     CPPUNIT_CHECK( gp->nVal == nKey );
 
-                    CPPUNIT_ASSERT( s.extract_with(gp, other_item(nKey), other_less() ));
+                    gp = s.extract_with( other_item( nKey ), other_less() );
+                    CPPUNIT_ASSERT( gp );
                     CPPUNIT_ASSERT( !gp.empty());
                     CPPUNIT_CHECK( gp->nKey == nKey );
                     CPPUNIT_CHECK( gp->nVal == nKey );
-                    CPPUNIT_CHECK( !s.get_with(gp, other_item(nKey), other_less() ));
-                    gp.release();
+                    gp = s.get_with( other_item( nKey ), other_less() );
+                    CPPUNIT_CHECK( !gp );
 
-                    CPPUNIT_CHECK( !s.extract_with(gp, other_item(nKey), other_less() ));
+                    CPPUNIT_CHECK( !s.extract_with(other_item(nKey), other_less() ));
                     CPPUNIT_CHECK( gp.empty());
                 }
                 CPPUNIT_ASSERT( s.empty() );