Boost logo

Boost-Commit :

From: daniel_james_at_[hidden]
Date: 2007-12-18 17:58:13


Author: danieljames
Date: 2007-12-18 17:58:12 EST (Tue, 18 Dec 2007)
New Revision: 42155
URL: http://svn.boost.org/trac/boost/changeset/42155

Log:
Add a helper function for creating null pointers.
Text files modified:
   sandbox/unordered/boost/unordered/detail/allocator.hpp | 6 ++++++
   sandbox/unordered/boost/unordered/detail/hash_table_impl.hpp | 11 +++--------
   2 files changed, 9 insertions(+), 8 deletions(-)

Modified: sandbox/unordered/boost/unordered/detail/allocator.hpp
==============================================================================
--- sandbox/unordered/boost/unordered/detail/allocator.hpp (original)
+++ sandbox/unordered/boost/unordered/detail/allocator.hpp 2007-12-18 17:58:12 EST (Tue, 18 Dec 2007)
@@ -42,6 +42,9 @@
 #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
         template <class T>
         inline void reset(T& x) { x = T(); }
+
+ template <class Ptr>
+ inline Ptr null_ptr() { return Ptr(); }
 #else
         template <class T>
         inline void reset_impl(T& x, ...) { x = T(); }
@@ -49,6 +52,9 @@
         inline void reset_impl(T*& x, int) { x = 0; }
         template <class T>
         inline void reset(T& x) { reset_impl(x); }
+
+ template <class Ptr>
+ inline Ptr null_ptr() { Ptr x; reset(x); return x; }
 #endif
 
         // Work around for Microsoft's ETI bug.

Modified: sandbox/unordered/boost/unordered/detail/hash_table_impl.hpp
==============================================================================
--- sandbox/unordered/boost/unordered/detail/hash_table_impl.hpp (original)
+++ sandbox/unordered/boost/unordered/detail/hash_table_impl.hpp 2007-12-18 17:58:12 EST (Tue, 18 Dec 2007)
@@ -424,9 +424,7 @@
 
             link_ptr end(size_type) const
             {
- link_ptr ptr = link_ptr();
- BOOST_HASH_MSVC_RESET_PTR(ptr);
- return ptr;
+ return unordered_detail::null_ptr<link_ptr>();
             }
 
             link_ptr begin(bucket_ptr b) const
@@ -658,11 +656,8 @@
             {
                 // If split is at the beginning of the group then there's
                 // nothing to split.
- if(prev_in_group(split)->next_ != split) {
- link_ptr ptr = link_ptr();
- BOOST_HASH_MSVC_RESET_PTR(ptr);
- return ptr;
- }
+ if(prev_in_group(split)->next_ != split)
+ return unordered_detail::null_ptr<link_ptr>();
 
                 // Find the start of the group.
                 link_ptr start = split;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk