|
Boost-Commit : |
From: daniel_james_at_[hidden]
Date: 2007-12-18 18:14:50
Author: danieljames
Date: 2007-12-18 18:14:49 EST (Tue, 18 Dec 2007)
New Revision: 42156
URL: http://svn.boost.org/trac/boost/changeset/42156
Log:
Check that I'm using link_ptr & bucket_ptr correctly (they should be distinct
types with an explicit conversion from bucket_ptr to link_ptr).
Text files modified:
sandbox/unordered/boost/unordered/detail/hash_table_impl.hpp | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
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 18:14:49 EST (Tue, 18 Dec 2007)
@@ -53,8 +53,28 @@
typedef BOOST_DEDUCED_TYPENAME allocator_pointer<node_allocator>::type node_ptr;
typedef BOOST_DEDUCED_TYPENAME allocator_pointer<bucket_allocator>::type bucket_ptr;
typedef BOOST_DEDUCED_TYPENAME allocator_reference<value_allocator>::type reference;
+ typedef BOOST_DEDUCED_TYPENAME allocator_reference<bucket_allocator>::type bucket_reference;
+
+#if 1
typedef bucket_ptr link_ptr;
+#else
+ // This alternative version of link_ptr is used to check that the
+ // implementation is type safe wrt bucket_ptr and link_ptr.
+ //
+ // It's a sort of strict typedef.
+ struct link_ptr {
+ link_ptr() : ptr_() { BOOST_HASH_MSVC_RESET_PTR(ptr_); }
+ explicit link_ptr(bucket_ptr p) : ptr_(p) {}
+ bucket_reference operator*() const { return *ptr_; }
+ bucket* operator->() const { return &*ptr_; }
+ operator bool() const { return ptr_; }
+ bool operator==(link_ptr const& x) const { return ptr_ == x.ptr_; }
+ bool operator!=(link_ptr const& x) const { return ptr_ != x.ptr_; }
+ private:
+ bucket_ptr ptr_;
+ };
+#endif
// Hash Bucket
//
// all no throw
@@ -207,7 +227,7 @@
{
node_ptr p = node_;
unordered_detail::reset(node_);
- return allocators_.bucket_alloc_.address(*p);
+ return link_ptr(allocators_.bucket_alloc_.address(*p));
}
private:
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