Less use of the ampersand operator in unordered.

[SVN r66557]
This commit is contained in:
Daniel James
2010-11-13 12:31:54 +00:00
parent 2c1a8894cb
commit 14e0e1afc2
4 changed files with 31 additions and 5 deletions

View File

@ -64,7 +64,7 @@ namespace boost { namespace unordered_detail {
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);

View File

@ -231,6 +231,9 @@ namespace boost { namespace unordered_detail {
value_type& value() {
return *(ValueType*) this;
}
value_type* value_ptr() {
return (ValueType*) this;
}
private:
value_base& operator=(value_base const&);
};
@ -249,6 +252,9 @@ namespace boost { namespace unordered_detail {
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 @@ namespace boost { namespace unordered_detail {
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 @@ namespace boost { namespace unordered_detail {
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;

View File

@ -299,7 +299,7 @@ namespace boost { namespace unordered_detail {
#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 @@ namespace boost { namespace unordered_detail {
}
else {
BOOST_ASSERT(node_constructed_ && value_constructed_);
boost::unordered_detail::destroy(&node_->value());
boost::unordered_detail::destroy(node_->value_ptr());
value_constructed_ = false;
}
}

View File

@ -26,6 +26,8 @@ namespace minimal
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 @@ namespace minimal
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 @@ namespace minimal
~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 @@ namespace minimal
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 @@ namespace minimal
~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 @@ namespace minimal
~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 @@ namespace minimal
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 @@ namespace minimal
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 @@ namespace minimal
#else
private: allocator& operator=(allocator const&);
#endif
private:
ampersand_operator_used operator&() const { return ampersand_operator_used(); }
};
template <class T>