Merge latest hash and unordered developments, and add support for initialiser

lists to config.

Merged revisions 49338,49924-49927,49955,50029,50118 via svnmerge from 
https://svn.boost.org/svn/boost/trunk

........
  r49338 | danieljames | 2008-10-15 10:44:41 +0100 (Wed, 15 Oct 2008) | 2 lines
  
  Revert [49229], it fixes the same problem as [48674].
........
  r49924 | danieljames | 2008-11-24 22:55:14 +0000 (Mon, 24 Nov 2008) | 1 line
  
  Extra tests for equality with different hash functions.
........
  r49925 | danieljames | 2008-11-24 22:55:47 +0000 (Mon, 24 Nov 2008) | 1 line
  
  Document operator==/operator!= as undefined if the equality predicates aren't equivalent.
........
  r49926 | danieljames | 2008-11-24 22:56:04 +0000 (Mon, 24 Nov 2008) | 1 line
  
  Use a larger prime number list.
........
  r49927 | danieljames | 2008-11-24 23:15:55 +0000 (Mon, 24 Nov 2008) | 1 line
  
  Use aligned storage for the value.
........
  r49955 | danieljames | 2008-11-27 11:42:13 +0000 (Thu, 27 Nov 2008) | 1 line
  
  Wild stab at getting destruction working on more compilers.
........
  r50029 | danieljames | 2008-11-29 21:47:55 +0000 (Sat, 29 Nov 2008) | 1 line
  
  Workaround another in-place destruction.
........
  r50118 | danieljames | 2008-12-04 21:30:19 +0000 (Thu, 04 Dec 2008) | 1 line
  
  Add support for initializer lists to config and the unordered containers.
........


[SVN r50451]
This commit is contained in:
Daniel James
2009-01-03 23:18:33 +00:00
parent 07e715fceb
commit b8e8ffa242
10 changed files with 240 additions and 152 deletions

View File

@@ -13,6 +13,10 @@ namespace equality_tests
{
struct mod_compare
{
bool alt_hash_;
explicit mod_compare(bool alt_hash = false) : alt_hash_(alt_hash) {}
bool operator()(int x, int y) const
{
return x % 1000 == y % 1000;
@@ -20,7 +24,7 @@ namespace equality_tests
int operator()(int x) const
{
return x % 250;
return alt_hash_ ? x % 250 : (x + 5) % 250;
}
};
@@ -138,6 +142,25 @@ namespace equality_tests
((1)(2))((1001)(1)), ==, ((1001)(2))((1)(1)));
}
// Test that equality still works when the two containers have
// different hash functions but the same equality predicate.
UNORDERED_AUTO_TEST(equality_different_hash_test)
{
typedef boost::unordered_set<int, mod_compare, mod_compare> set;
set set1(0, mod_compare(false), mod_compare(false));
set set2(0, mod_compare(true), mod_compare(true));
BOOST_CHECK(set1 == set2);
set1.insert(1); set2.insert(2);
BOOST_CHECK(set1 != set2);
set1.insert(2); set2.insert(1);
BOOST_CHECK(set1 == set2);
set1.insert(10); set2.insert(20);
BOOST_CHECK(set1 != set2);
set1.insert(20); set2.insert(10);
BOOST_CHECK(set1 == set2);
}
}
RUN_TESTS()