|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r66557 - in trunk: boost/unordered/detail libs/unordered/test/objects
From: dnljms_at_[hidden]
Date: 2010-11-13 07:31:56
Author: danieljames
Date: 2010-11-13 07:31:54 EST (Sat, 13 Nov 2010)
New Revision: 66557
URL: http://svn.boost.org/trac/boost/changeset/66557
Log:
Less use of the ampersand operator in unordered.
Text files modified:
trunk/boost/unordered/detail/buckets.hpp | 2 +-
trunk/boost/unordered/detail/fwd.hpp | 10 ++++++++--
trunk/boost/unordered/detail/util.hpp | 4 ++--
trunk/libs/unordered/test/objects/minimal.hpp | 20 ++++++++++++++++++++
4 files changed, 31 insertions(+), 5 deletions(-)
Modified: trunk/boost/unordered/detail/buckets.hpp
==============================================================================
--- trunk/boost/unordered/detail/buckets.hpp (original)
+++ trunk/boost/unordered/detail/buckets.hpp 2010-11-13 07:31:54 EST (Sat, 13 Nov 2010)
@@ -64,7 +64,7 @@
inline void hash_buckets<A, G>::delete_node(node_ptr b)
{
node* raw_ptr = static_cast<node*>(&*b);
- boost::unordered_detail::destroy(&raw_ptr->value());
+ boost::unordered_detail::destroy(raw_ptr->value_ptr());
real_node_ptr n(node_alloc().address(*raw_ptr));
node_alloc().destroy(n);
node_alloc().deallocate(n, 1);
Modified: trunk/boost/unordered/detail/fwd.hpp
==============================================================================
--- trunk/boost/unordered/detail/fwd.hpp (original)
+++ trunk/boost/unordered/detail/fwd.hpp 2010-11-13 07:31:54 EST (Sat, 13 Nov 2010)
@@ -231,6 +231,9 @@
value_type& value() {
return *(ValueType*) this;
}
+ value_type* value_ptr() {
+ return (ValueType*) this;
+ }
private:
value_base& operator=(value_base const&);
};
@@ -249,6 +252,9 @@
static value_type& get_value(node_ptr p) {
return static_cast<hash_node&>(*p).value();
}
+ static value_type* get_value_ptr(node_ptr p) {
+ return static_cast<hash_node&>(*p).value_ptr();
+ }
private:
hash_node& operator=(hash_node const&);
};
@@ -719,7 +725,7 @@
return node::get_value(ptr_);
}
value_type* operator->() const {
- return &node::get_value(ptr_);
+ return node::get_value_ptr(ptr_);
}
hash_local_iterator& operator++() {
ptr_ = ptr_->next_; return *this;
@@ -769,7 +775,7 @@
return node::get_value(ptr_);
}
value_type const* operator->() const {
- return &node::get_value(ptr_);
+ return node::get_value_ptr(ptr_);
}
hash_const_local_iterator& operator++() {
ptr_ = ptr_->next_; return *this;
Modified: trunk/boost/unordered/detail/util.hpp
==============================================================================
--- trunk/boost/unordered/detail/util.hpp (original)
+++ trunk/boost/unordered/detail/util.hpp 2010-11-13 07:31:54 EST (Sat, 13 Nov 2010)
@@ -299,7 +299,7 @@
#if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
struct dummy { hash_node<Alloc, Grouped> x; };
#endif
- boost::unordered_detail::destroy(&node_->value());
+ boost::unordered_detail::destroy(node_->value_ptr());
}
if (node_constructed_)
@@ -322,7 +322,7 @@
}
else {
BOOST_ASSERT(node_constructed_ && value_constructed_);
- boost::unordered_detail::destroy(&node_->value());
+ boost::unordered_detail::destroy(node_->value_ptr());
value_constructed_ = false;
}
}
Modified: trunk/libs/unordered/test/objects/minimal.hpp
==============================================================================
--- trunk/libs/unordered/test/objects/minimal.hpp (original)
+++ trunk/libs/unordered/test/objects/minimal.hpp 2010-11-13 07:31:54 EST (Sat, 13 Nov 2010)
@@ -26,6 +26,8 @@
class default_copy_constructible;
class assignable;
+ struct ampersand_operator_used {};
+
template <class T> class hash;
template <class T> class equal_to;
template <class T> class ptr;
@@ -63,6 +65,7 @@
copy_constructible_equality_comparable& operator=(
copy_constructible_equality_comparable const&);
copy_constructible_equality_comparable() {}
+ ampersand_operator_used operator&() const { return ampersand_operator_used(); }
};
bool operator==(
@@ -98,9 +101,11 @@
~default_copy_constructible()
{
}
+
private:
default_copy_constructible& operator=(
default_copy_constructible const&);
+ ampersand_operator_used operator&() const { return ampersand_operator_used(); }
};
class assignable
@@ -110,8 +115,11 @@
assignable(assignable const&) {}
assignable& operator=(assignable const&) { return *this; }
~assignable() {}
+
private:
assignable() {}
+ // TODO: This messes up a concept check in the tests.
+ //ampersand_operator_used operator&() const { return ampersand_operator_used(); }
};
template <class T>
@@ -125,6 +133,8 @@
~hash() {}
std::size_t operator()(T const&) const { return 0; }
+ private:
+ ampersand_operator_used operator&() const { return ampersand_operator_used(); }
};
template <class T>
@@ -138,6 +148,8 @@
~equal_to() {}
bool operator()(T const&, T const&) const { return true; }
+ private:
+ ampersand_operator_used operator&() const { return ampersand_operator_used(); }
};
template <class T> class ptr;
@@ -182,6 +194,9 @@
bool operator>(const_ptr<T> const& x) const { return ptr_ > x.ptr_; }
bool operator<=(const_ptr<T> const& x) const { return ptr_ <= x.ptr_; }
bool operator>=(const_ptr<T> const& x) const { return ptr_ >= x.ptr_; }
+ private:
+ // TODO:
+ //ampersand_operator_used operator&() const { return ampersand_operator_used(); }
};
template <class T>
@@ -221,6 +236,9 @@
bool operator>(const_ptr const& x) const { return ptr_ > x.ptr_; }
bool operator<=(const_ptr const& x) const { return ptr_ <= x.ptr_; }
bool operator>=(const_ptr const& x) const { return ptr_ >= x.ptr_; }
+ private:
+ // TODO:
+ //ampersand_operator_used operator&() const { return ampersand_operator_used(); }
};
template <class T>
@@ -278,6 +296,8 @@
#else
private: allocator& operator=(allocator const&);
#endif
+ private:
+ ampersand_operator_used operator&() const { return ampersand_operator_used(); }
};
template <class T>
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