forked from boostorg/unordered
Merge in fix for the swap tests, and rename allocator.
Merged revisions 44512-44515,44517-44536 via svnmerge from https://svn.boost.org/svn/boost/branches/unordered/trunk ................ r44512 | danieljames | 2008-04-17 20:03:00 +0100 (Thu, 17 Apr 2008) | 11 lines Rename allocator.hpp. ................ r44536 | danieljames | 2008-04-18 11:27:50 +0100 (Fri, 18 Apr 2008) | 1 line Check that hash_table_impl::swap isn't swapping with itself - which is causing the buffered functions to be set with the same value twice, resulting in an assertion. ................ [SVN r44614]
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
#include <boost/limits.hpp>
|
#include <boost/limits.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/static_assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
#include <boost/unordered/detail/allocator.hpp>
|
#include <boost/unordered/detail/allocator_helpers.hpp>
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
#include <boost/mpl/if.hpp>
|
#include <boost/mpl/if.hpp>
|
||||||
#include <boost/mpl/and.hpp>
|
#include <boost/mpl/and.hpp>
|
||||||
|
@@ -694,7 +694,7 @@ namespace boost {
|
|||||||
BOOST_ASSERT(base == end.bucket_);
|
BOOST_ASSERT(base == end.bucket_);
|
||||||
|
|
||||||
split_group(end.node_);
|
split_group(end.node_);
|
||||||
|
|
||||||
link_ptr ptr(base->next_);
|
link_ptr ptr(base->next_);
|
||||||
base->next_ = end.node_;
|
base->next_ = end.node_;
|
||||||
|
|
||||||
@@ -1147,7 +1147,7 @@ namespace boost {
|
|||||||
//
|
//
|
||||||
// Swap's behaviour when allocators aren't equal is in dispute, for
|
// Swap's behaviour when allocators aren't equal is in dispute, for
|
||||||
// details see:
|
// details see:
|
||||||
//
|
//
|
||||||
// http://unordered.nfshost.com/doc/html/unordered/rationale.html#swapping_containers_with_unequal_allocators
|
// http://unordered.nfshost.com/doc/html/unordered/rationale.html#swapping_containers_with_unequal_allocators
|
||||||
//
|
//
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
@@ -1159,6 +1159,13 @@ namespace boost {
|
|||||||
|
|
||||||
void swap(BOOST_UNORDERED_TABLE& x)
|
void swap(BOOST_UNORDERED_TABLE& x)
|
||||||
{
|
{
|
||||||
|
// The swap code can work when swapping a container with itself
|
||||||
|
// but it triggers an assertion in buffered_functions.
|
||||||
|
// At the moment, I'd rather leave that assertion in and add a
|
||||||
|
// check here, rather than remove the assertion. I might change
|
||||||
|
// this at a later date.
|
||||||
|
if(this == &x) return;
|
||||||
|
|
||||||
// These can throw, but they only affect the function objects
|
// These can throw, but they only affect the function objects
|
||||||
// that aren't in use so it is strongly exception safe, via.
|
// that aren't in use so it is strongly exception safe, via.
|
||||||
// double buffering.
|
// double buffering.
|
||||||
@@ -1669,7 +1676,7 @@ namespace boost {
|
|||||||
size_type hash_value = hash_function()(k);
|
size_type hash_value = hash_function()(k);
|
||||||
bucket_ptr bucket = data_.bucket_from_hash(hash_value);
|
bucket_ptr bucket = data_.bucket_from_hash(hash_value);
|
||||||
link_ptr pos = find_iterator(bucket, k);
|
link_ptr pos = find_iterator(bucket, k);
|
||||||
|
|
||||||
if (BOOST_UNORDERED_BORLAND_BOOL(pos)) {
|
if (BOOST_UNORDERED_BORLAND_BOOL(pos)) {
|
||||||
// Found an existing key, return it (no throw).
|
// Found an existing key, return it (no throw).
|
||||||
return std::pair<iterator_base, bool>(
|
return std::pair<iterator_base, bool>(
|
||||||
@@ -1744,7 +1751,7 @@ namespace boost {
|
|||||||
size_type hash_value = hash_function()(extract_key(*i));
|
size_type hash_value = hash_function()(extract_key(*i));
|
||||||
bucket_ptr bucket = data_.bucket_from_hash(hash_value);
|
bucket_ptr bucket = data_.bucket_from_hash(hash_value);
|
||||||
link_ptr pos = find_iterator(bucket, extract_key(*i));
|
link_ptr pos = find_iterator(bucket, extract_key(*i));
|
||||||
|
|
||||||
if (!BOOST_UNORDERED_BORLAND_BOOL(pos)) {
|
if (!BOOST_UNORDERED_BORLAND_BOOL(pos)) {
|
||||||
// Doesn't already exist, add to bucket.
|
// Doesn't already exist, add to bucket.
|
||||||
// Side effects only in this block.
|
// Side effects only in this block.
|
||||||
@@ -1871,7 +1878,7 @@ namespace boost {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Iterators
|
// Iterators
|
||||||
|
|
||||||
template <typename Alloc> class BOOST_UNORDERED_ITERATOR;
|
template <typename Alloc> class BOOST_UNORDERED_ITERATOR;
|
||||||
template <typename Alloc> class BOOST_UNORDERED_CONST_ITERATOR;
|
template <typename Alloc> class BOOST_UNORDERED_CONST_ITERATOR;
|
||||||
template <typename Alloc> class BOOST_UNORDERED_LOCAL_ITERATOR;
|
template <typename Alloc> class BOOST_UNORDERED_LOCAL_ITERATOR;
|
||||||
|
Reference in New Issue
Block a user