|
Boost-Commit : |
From: daniel_james_at_[hidden]
Date: 2008-05-28 19:30:10
Author: danieljames
Date: 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
New Revision: 45892
URL: http://svn.boost.org/trac/boost/changeset/45892
Log:
Merge latest changes from unordered.
Added:
branches/doc/boost/unordered/detail/allocator.hpp
- copied unchanged from r45891, /branches/unordered/trunk/boost/unordered/detail/allocator.hpp
branches/doc/libs/unordered/doc/changes.qbk
- copied unchanged from r45891, /branches/unordered/trunk/libs/unordered/doc/changes.qbk
branches/doc/libs/unordered/doc/diagrams/buckets.svg
- copied unchanged from r45891, /branches/unordered/trunk/libs/unordered/doc/diagrams/buckets.svg
branches/doc/libs/unordered/test/helpers/count.hpp
- copied unchanged from r45891, /branches/unordered/trunk/libs/unordered/test/helpers/count.hpp
branches/doc/libs/unordered/test/helpers/list.hpp
- copied unchanged from r45891, /branches/unordered/trunk/libs/unordered/test/helpers/list.hpp
branches/doc/libs/unordered/test/unordered/equality_tests.cpp
- copied unchanged from r45891, /branches/unordered/trunk/libs/unordered/test/unordered/equality_tests.cpp
Removed:
branches/doc/libs/unordered/doc/diagrams/buckets.dia
Properties modified:
branches/doc/ (props changed)
Binary files modified:
branches/doc/libs/unordered/doc/diagrams/buckets.png
Text files modified:
branches/doc/boost/unordered/detail/config.hpp | 4
branches/doc/boost/unordered/detail/hash_table.hpp | 30 ++
branches/doc/boost/unordered/detail/hash_table_impl.hpp | 147 ++++++++++++++---
branches/doc/boost/unordered_map.hpp | 46 ++++
branches/doc/boost/unordered_set.hpp | 46 ++++
branches/doc/libs/functional/hash/doc/changes.qbk | 44 ++++
branches/doc/libs/unordered/doc/Jamfile.v2 | 29 +++
branches/doc/libs/unordered/doc/ref.xml | 328 ++++++++++++++++++++++++++++++++++++---
branches/doc/libs/unordered/doc/unordered.qbk | 1
branches/doc/libs/unordered/test/exception/Jamfile.v2 | 2
branches/doc/libs/unordered/test/helpers/equivalent.hpp | 23 +-
branches/doc/libs/unordered/test/helpers/exception_test.hpp | 2
branches/doc/libs/unordered/test/helpers/metafunctions.hpp | 29 ---
branches/doc/libs/unordered/test/helpers/random_values.hpp | 4
branches/doc/libs/unordered/test/helpers/strong.hpp | 12
branches/doc/libs/unordered/test/helpers/test.hpp | 16 +
branches/doc/libs/unordered/test/helpers/tracker.hpp | 31 +--
branches/doc/libs/unordered/test/objects/memory.hpp | 4
branches/doc/libs/unordered/test/objects/minimal.hpp | 36 ++++
branches/doc/libs/unordered/test/objects/test.hpp | 5
branches/doc/libs/unordered/test/unordered/Jamfile.v2 | 5
branches/doc/libs/unordered/test/unordered/bucket_tests.cpp | 6
branches/doc/libs/unordered/test/unordered/compile_map.cpp | 37 ++++
branches/doc/libs/unordered/test/unordered/compile_set.cpp | 30 +++
branches/doc/libs/unordered/test/unordered/compile_tests.hpp | 20 ++
branches/doc/libs/unordered/test/unordered/constructor_tests.cpp | 10
branches/doc/libs/unordered/test/unordered/copy_tests.cpp | 8
branches/doc/libs/unordered/test/unordered/equivalent_keys_tests.cpp | 4
branches/doc/libs/unordered/test/unordered/erase_equiv_tests.cpp | 16 -
branches/doc/libs/unordered/test/unordered/find_tests.cpp | 4
branches/doc/libs/unordered/test/unordered/insert_tests.cpp | 5
branches/doc/libs/unordered/test/unordered/load_factor_tests.cpp | 8
branches/doc/libs/unordered/test/unordered/move_tests.cpp | 58 +++---
branches/doc/libs/unordered/test/unordered/rehash_tests.cpp | 16 -
branches/doc/libs/unordered/test/unordered/swap_tests.cpp | 18 +-
branches/doc/libs/unordered/test/unordered/unnecessary_copy_tests.cpp | 14 +
36 files changed, 843 insertions(+), 255 deletions(-)
Modified: branches/doc/boost/unordered/detail/config.hpp
==============================================================================
--- branches/doc/boost/unordered/detail/config.hpp (original)
+++ branches/doc/boost/unordered/detail/config.hpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -13,6 +13,10 @@
#elif defined(__GNUC__) && \
(__GNUC__ < 3 || __GNUC__ == 3 && __GNUC_MINOR__ <= 3)
# define BOOST_UNORDERED_NO_HAS_MOVE_ASSIGN
+#elif BOOST_WORKAROUND(BOOST_INTEL, < 900) || \
+ BOOST_WORKAROUND(__EDG_VERSION__, < 304) || \
+ BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0593))
+# define BOOST_UNORDERED_NO_HAS_MOVE_ASSIGN
#endif
#endif
Modified: branches/doc/boost/unordered/detail/hash_table.hpp
==============================================================================
--- branches/doc/boost/unordered/detail/hash_table.hpp (original)
+++ branches/doc/boost/unordered/detail/hash_table.hpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -78,7 +78,14 @@
// prime number list, accessor
- static const std::size_t prime_list[] = {
+ template<typename T> struct prime_list_template
+ {
+ static std::size_t const value[];
+ static std::ptrdiff_t const length;
+ };
+
+ template<typename T>
+ std::size_t const prime_list_template<T>::value[] = {
53ul, 97ul, 193ul, 389ul, 769ul,
1543ul, 3079ul, 6151ul, 12289ul, 24593ul,
49157ul, 98317ul, 196613ul, 393241ul, 786433ul,
@@ -86,12 +93,18 @@
50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul,
1610612741ul, 3221225473ul, 4294967291ul };
+ template<typename T>
+ std::ptrdiff_t const prime_list_template<T>::length = 28;
+
+ typedef prime_list_template<std::size_t> prime_list;
+
// no throw
inline std::size_t next_prime(std::size_t n) {
- std::size_t const* const prime_list_end = prime_list +
- sizeof(prime_list) / sizeof(*prime_list);
+ std::size_t const* const prime_list_begin = prime_list::value;
+ std::size_t const* const prime_list_end = prime_list_begin +
+ prime_list::length;
std::size_t const* bound =
- std::lower_bound(prime_list,prime_list_end, n);
+ std::lower_bound(prime_list_begin, prime_list_end, n);
if(bound == prime_list_end)
bound--;
return *bound;
@@ -99,11 +112,12 @@
// no throw
inline std::size_t prev_prime(std::size_t n) {
- std::size_t const* const prime_list_end = prime_list +
- sizeof(prime_list) / sizeof(*prime_list);
+ std::size_t const* const prime_list_begin = prime_list::value;
+ std::size_t const* const prime_list_end = prime_list_begin +
+ prime_list::length;
std::size_t const* bound =
- std::upper_bound(prime_list,prime_list_end, n);
- if(bound != prime_list)
+ std::upper_bound(prime_list_begin,prime_list_end, n);
+ if(bound != prime_list_begin)
bound--;
return *bound;
}
Modified: branches/doc/boost/unordered/detail/hash_table_impl.hpp
==============================================================================
--- branches/doc/boost/unordered/detail/hash_table_impl.hpp (original)
+++ branches/doc/boost/unordered/detail/hash_table_impl.hpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -304,27 +304,6 @@
value_constructed_ = true;
}
-#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL)
- template <typename... Args>
- void construct(Args&&... args)
- {
- BOOST_ASSERT(!node_);
- value_constructed_ = false;
- node_base_constructed_ = false;
-
- node_ = allocators_.node_alloc_.allocate(1);
-
- allocators_.node_base_alloc_.construct(
- allocators_.node_base_alloc_.address(*node_),
- node_base());
- node_base_constructed_ = true;
-
- allocators_.value_alloc_.construct(
- allocators_.value_alloc_.address(node_->value_), std::forward<Args>(args)...);
- value_constructed_ = true;
- }
-#endif
-
node_ptr get() const
{
BOOST_ASSERT(node_);
@@ -1128,11 +1107,13 @@
private:
- typedef boost::unordered_detail::buffered_functions<Hash, Pred> buffered_functions;
- typedef BOOST_DEDUCED_TYPENAME buffered_functions::functions functions;
- typedef BOOST_DEDUCED_TYPENAME buffered_functions::functions_ptr functions_ptr;
+ typedef boost::unordered_detail::buffered_functions<Hash, Pred>
+ function_store;
+ typedef BOOST_DEDUCED_TYPENAME function_store::functions functions;
+ typedef BOOST_DEDUCED_TYPENAME function_store::functions_ptr
+ functions_ptr;
- buffered_functions functions_;
+ function_store functions_;
float mlf_;
size_type max_load_;
@@ -1376,10 +1357,17 @@
// accessors
// no throw
+#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL)
node_allocator get_allocator() const
{
return data_.allocators_.node_alloc_;
}
+#else
+ value_allocator get_allocator() const
+ {
+ return data_.allocators_.value_alloc_;
+ }
+#endif
// no throw
hasher const& hash_function() const
@@ -1660,6 +1648,7 @@
#if BOOST_UNORDERED_EQUIVALENT_KEYS
+#if !(defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL))
// Insert (equivalent key containers)
// if hash function throws, basic exception safety
@@ -1688,7 +1677,8 @@
return insert_hint_impl(it, a);
}
-#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL)
+#else
+
// Insert (equivalent key containers)
// (I'm using an overloaded insert for both 'insert' and 'emplace')
@@ -1862,6 +1852,8 @@
}
}
+#if !(defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL))
+
// Insert (unique keys)
// if hash function throws, basic exception safety
@@ -1914,7 +1906,8 @@
return insert(v).first;
}
-#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL)
+#else
+
// Insert (unique keys)
// (I'm using an overloaded insert for both 'insert' and 'emplace')
//
@@ -1961,10 +1954,8 @@
// Nothing after this point can throw.
- link_ptr n = data_.link_node_in_bucket(a, bucket);
-
- return std::pair<iterator_base, bool>(
- iterator_base(bucket, n), true);
+ return std::pair<iterator_base, bool>(iterator_base(bucket,
+ data_.link_node_in_bucket(a, bucket)), true);
}
}
@@ -2005,7 +1996,7 @@
// if hash function throws, basic exception safety
// strong otherwise
template<typename... Args>
- iterator_base insert_hint(iterator_base const& it, Args&&... args)
+ iterator_base insert_hint(iterator_base const&, Args&&... args)
{
// Life is complicated - just call the normal implementation.
return insert(std::forward<Args>(args)...).first;
@@ -2136,6 +2127,98 @@
}
}
+ //
+ // equals
+ //
+
+private:
+#if BOOST_UNORDERED_EQUIVALENT_KEYS
+ static inline bool group_equals(link_ptr it1, link_ptr it2,
+ type_wrapper<key_type>*)
+ {
+ return data::group_count(it1) == data::group_count(it2);
+ }
+
+ static inline bool group_equals(link_ptr it1, link_ptr it2, void*)
+ {
+ link_ptr end1 = data::next_group(it1);
+ link_ptr end2 = data::next_group(it2);
+ do {
+ if(data::get_value(it1).second != data::get_value(it2).second) return false;
+ it1 = it1->next_;
+ it2 = it2->next_;
+ } while(it1 != end1 && it2 != end2);
+ return it1 == end1 && it2 == end2;
+ }
+#else
+ static inline bool group_equals(link_ptr, link_ptr,
+ type_wrapper<key_type>*)
+ {
+ return true;
+ }
+
+ static inline bool group_equals(link_ptr it1, link_ptr it2, void*)
+ {
+ return data::get_value(it1).second == data::get_value(it2).second;
+ }
+#endif
+
+public:
+ bool equals(BOOST_UNORDERED_TABLE const& other) const
+ {
+ if(size() != other.size()) return false;
+
+ for(bucket_ptr i = data_.cached_begin_bucket_,
+ j = data_.buckets_end(); i != j; ++i)
+ {
+ for(link_ptr it(i->next_); BOOST_UNORDERED_BORLAND_BOOL(it); it = data::next_group(it))
+ {
+ link_ptr other_pos = other.find_iterator(other.extract_key(data::get_value(it)));
+ if(!BOOST_UNORDERED_BORLAND_BOOL(other_pos) ||
+ !group_equals(it, other_pos, (type_wrapper<value_type>*)0))
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ inline std::size_t group_hash(link_ptr it, type_wrapper<key_type>*) const
+ {
+ std::size_t seed = data::group_count(it);
+ std::size_t hashed_key = hash_function()(data::get_value(it));
+ boost::hash_combine(seed, hashed_key);
+ return seed;
+ }
+
+ inline std::size_t group_hash(link_ptr it, void*) const
+ {
+ std::size_t seed = hash_function()(data::get_value(it).first);
+
+ link_ptr end = data::next_group(it);
+
+ do {
+ boost::hash_combine(seed, data::get_value(it).second);
+ it = it->next_;
+ } while(it != end);
+
+ return seed;
+ }
+
+ std::size_t hash_value() const
+ {
+ std::size_t seed = 0;
+
+ for(bucket_ptr i = data_.cached_begin_bucket_,
+ j = data_.buckets_end(); i != j; ++i)
+ {
+ for(link_ptr it(i->next_); BOOST_UNORDERED_BORLAND_BOOL(it); it = data::next_group(it))
+ seed ^= group_hash(it, (type_wrapper<value_type>*)0);
+ }
+
+ return seed;
+ }
+
private:
// strong exception safety, no side effects
Modified: branches/doc/boost/unordered_map.hpp
==============================================================================
--- branches/doc/boost/unordered_map.hpp (original)
+++ branches/doc/boost/unordered_map.hpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -16,10 +16,10 @@
#include <boost/config.hpp>
#include <functional>
-#include <memory>
-#include <boost/unordered/detail/hash_table.hpp>
#include <boost/functional/hash.hpp>
+#include <boost/unordered/detail/hash_table.hpp>
+#include <boost/unordered/detail/allocator.hpp>
#if !defined(BOOST_HAS_RVALUE_REFS)
#include <boost/unordered/detail/move.hpp>
@@ -31,7 +31,7 @@
class T,
class Hash = hash<Key>,
class Pred = std::equal_to<Key>,
- class Alloc = std::allocator<std::pair<const Key, T> > >
+ class Alloc = boost::unordered_detail::allocator<std::pair<const Key, T> > >
class unordered_map
{
typedef boost::unordered_detail::hash_types_unique_keys<
@@ -121,17 +121,19 @@
return *this;
}
#else
- unordered_map(boost::unordered_detail::move_from<unordered_map> other)
+ unordered_map(boost::unordered_detail::move_from<unordered_map<Key, T, Hash, Pred, Alloc> > other)
: base(other.base, boost::unordered_detail::move_tag())
{
}
+#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0593)
unordered_map& operator=(unordered_map x)
{
base.move(x.base);
return *this;
}
#endif
+#endif
private:
@@ -387,6 +389,21 @@
{
base.rehash(n);
}
+
+ friend bool operator==(unordered_map const& m1, unordered_map const& m2)
+ {
+ return m1.base.equals(m2.base);
+ }
+
+ friend bool operator!=(unordered_map const& m1, unordered_map const& m2)
+ {
+ return !m1.base.equals(m2.base);
+ }
+
+ friend std::size_t hash_value(unordered_map const& m)
+ {
+ return m.base.hash_value();
+ }
}; // class template unordered_map
template <class K, class T, class H, class P, class A>
@@ -400,7 +417,7 @@
class T,
class Hash = hash<Key>,
class Pred = std::equal_to<Key>,
- class Alloc = std::allocator<std::pair<const Key, T> > >
+ class Alloc = boost::unordered_detail::allocator<std::pair<const Key, T> > >
class unordered_multimap
{
typedef boost::unordered_detail::hash_types_equivalent_keys<
@@ -489,17 +506,19 @@
return *this;
}
#else
- unordered_multimap(boost::unordered_detail::move_from<unordered_multimap> other)
+ unordered_multimap(boost::unordered_detail::move_from<unordered_multimap<Key, T, Hash, Pred, Alloc> > other)
: base(other.base, boost::unordered_detail::move_tag())
{
}
+#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0593)
unordered_multimap& operator=(unordered_multimap x)
{
base.move(x.base);
return *this;
}
#endif
+#endif
private:
@@ -739,6 +758,21 @@
{
base.rehash(n);
}
+
+ friend bool operator==(unordered_multimap const& m1, unordered_multimap const& m2)
+ {
+ return m1.base.equals(m2.base);
+ }
+
+ friend bool operator!=(unordered_multimap const& m1, unordered_multimap const& m2)
+ {
+ return !m1.base.equals(m2.base);
+ }
+
+ friend std::size_t hash_value(unordered_multimap const& m)
+ {
+ return m.base.hash_value();
+ }
}; // class template unordered_multimap
template <class K, class T, class H, class P, class A>
Modified: branches/doc/boost/unordered_set.hpp
==============================================================================
--- branches/doc/boost/unordered_set.hpp (original)
+++ branches/doc/boost/unordered_set.hpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -16,10 +16,10 @@
#include <boost/config.hpp>
#include <functional>
-#include <memory>
-#include <boost/unordered/detail/hash_table.hpp>
#include <boost/functional/hash.hpp>
+#include <boost/unordered/detail/hash_table.hpp>
+#include <boost/unordered/detail/allocator.hpp>
#if !defined(BOOST_HAS_RVALUE_REFS)
#include <boost/unordered/detail/move.hpp>
@@ -30,7 +30,7 @@
template <class Value,
class Hash = hash<Value>,
class Pred = std::equal_to<Value>,
- class Alloc = std::allocator<Value> >
+ class Alloc = boost::unordered_detail::allocator<Value> >
class unordered_set
{
typedef boost::unordered_detail::hash_types_unique_keys<
@@ -118,17 +118,19 @@
return *this;
}
#else
- unordered_set(boost::unordered_detail::move_from<unordered_set> other)
+ unordered_set(boost::unordered_detail::move_from<unordered_set<Value, Hash, Pred, Alloc> > other)
: base(other.base, boost::unordered_detail::move_tag())
{
}
+#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0593)
unordered_set& operator=(unordered_set x)
{
base.move(x.base);
return *this;
}
#endif
+#endif
private:
@@ -358,6 +360,21 @@
{
base.rehash(n);
}
+
+ friend bool operator==(unordered_set const& m1, unordered_set const& m2)
+ {
+ return m1.base.equals(m2.base);
+ }
+
+ friend bool operator!=(unordered_set const& m1, unordered_set const& m2)
+ {
+ return !m1.base.equals(m2.base);
+ }
+
+ friend std::size_t hash_value(unordered_set const& m)
+ {
+ return m.base.hash_value();
+ }
}; // class template unordered_set
template <class T, class H, class P, class A>
@@ -370,7 +387,7 @@
template <class Value,
class Hash = hash<Value>,
class Pred = std::equal_to<Value>,
- class Alloc = std::allocator<Value> >
+ class Alloc = boost::unordered_detail::allocator<Value> >
class unordered_multiset
{
typedef boost::unordered_detail::hash_types_equivalent_keys<
@@ -458,17 +475,19 @@
return *this;
}
#else
- unordered_multiset(boost::unordered_detail::move_from<unordered_multiset> other)
+ unordered_multiset(boost::unordered_detail::move_from<unordered_multiset<Value, Hash, Pred, Alloc> > other)
: base(other.base, boost::unordered_detail::move_tag())
{
}
+#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0593)
unordered_multiset& operator=(unordered_multiset x)
{
base.move(x.base);
return *this;
}
#endif
+#endif
private:
@@ -695,6 +714,21 @@
{
base.rehash(n);
}
+
+ friend bool operator==(unordered_multiset const& m1, unordered_multiset const& m2)
+ {
+ return m1.base.equals(m2.base);
+ }
+
+ friend bool operator!=(unordered_multiset const& m1, unordered_multiset const& m2)
+ {
+ return !m1.base.equals(m2.base);
+ }
+
+ friend std::size_t hash_value(unordered_multiset const& m)
+ {
+ return m.base.hash_value();
+ }
}; // class template unordered_multiset
template <class T, class H, class P, class A>
Modified: branches/doc/libs/functional/hash/doc/changes.qbk
==============================================================================
--- branches/doc/libs/functional/hash/doc/changes.qbk (original)
+++ branches/doc/libs/functional/hash/doc/changes.qbk 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -9,24 +9,54 @@
* Initial Release
-[h2 Changes in Boost 1.33.1]
+[h2 Boost 1.33.1]
* Fixed the points example, as pointed out by æ²æ
§å³°.
-[h2 Changes in Boost 1.34.0]
+[h2 Boost 1.34.0]
* Use declarations for standard classes, so that the library
doesn't need to include all of their headers
* Deprecated the `<boost/functional/hash/*.hpp>` headers. Now a single header,
<[headerref boost/functional/hash.hpp]> is used.
* Add support for the `BOOST_HASH_NO_EXTENSIONS` macro, which
- disables the extensions to TR1
+ disables the extensions to TR1.
+
* Minor improvements to the hash functions for floating point numbers.
+* Update the portable example to hopefully be more generally portable.
+
+[h2 Boost 1.34.1]
+
+* [@http://svn.boost.org/trac/boost/ticket/952 Ticket 952]:
+ Suppress incorrect 64-bit warning on Visual C++.
-[h2 Future Developments]
+[h2 Boost 1.35.0]
-* A more portable hash function, as described by Daniel Krügler in
- [@http://lists.boost.org/boost-users/2005/08/13418.php a post to the boost users list].
-* Implement `hash_value` for more classes, including `std::complex`.
+* Support for `long long`, `std::complex`.
+* Improved algorithm for hashing floating point numbers:
+ * Improved portablity, as described by Daniel Krügler in
+ [@http://lists.boost.org/boost-users/2005/08/13418.php
+ a post to the boost users list].
+ * Fits more information into each combine loop, which can reduce the
+ the number of times combine is called and hopefully give a better
+ quality hash function.
+ * Improved the algorithm for hashing floating point numbers.
+ * On Cygwin use a binary hash function for floating point numbers, as
+ Cygwin doesn't have decent floating point functions for `long double`.
+ * Never uses `fpclass` which doesn't support `long double`.
+ * [@http://svn.boost.org/trac/boost/ticket/1064 Ticket 1064]:
+ Removed unnecessary use of `errno`.
+* Explicitly overload for more built in types.
+* Minor improvements to the documentation.
+* A few bug and warning fixes:
+ * [@http://svn.boost.org/trac/boost/ticket/1509 Ticket 1509]:
+ Suppress another Visual C++ warning.
+ * Some workarounds for the Sun compilers.
+
+[h2 Boost 1.36.0]
+
+* Stop using OpenBSD's dodgy `std::numeric_limits`.
+* Using the boost typedefs for `long long` and `unsigned long long`.
+* Move the extensions into their own header.
[endsect]
Modified: branches/doc/libs/unordered/doc/Jamfile.v2
==============================================================================
--- branches/doc/libs/unordered/doc/Jamfile.v2 (original)
+++ branches/doc/libs/unordered/doc/Jamfile.v2 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -3,6 +3,9 @@
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+path-constant images_location : ../ ;
+path-constant admonishment_location : ../../../../doc/src/images ;
+
xml unordered : unordered.qbk ;
boostbook standalone : unordered :
<xsl:param>admon.graphics.path=images/
@@ -18,6 +21,32 @@
<dependency>css
<dependency>images
+
+ # PDF Options:
+ # TOC Generation: this is needed for FOP-0.9 and later:
+ <xsl:param>fop1.extensions=0
+ <format>pdf:<xsl:param>xep.extensions=1
+ # TOC generation: this is needed for FOP 0.2, but must not be set to zero for FOP-0.9!
+ <format>pdf:<xsl:param>fop.extensions=0
+ # No indent on body text:
+ <format>pdf:<xsl:param>body.start.indent=0pt
+ # Margin size:
+ <format>pdf:<xsl:param>page.margin.inner=0.5in
+ # Margin size:
+ <format>pdf:<xsl:param>page.margin.outer=0.5in
+ # Paper type = A4
+ <format>pdf:<xsl:param>paper.type=A4
+ # Yes, we want graphics for admonishments:
+ <xsl:param>admon.graphics=1
+ # Set this one for PDF generation *only*:
+ # default png graphics are awful in PDF form,
+ # better use SVG's instead:
+ <format>pdf:<xsl:param>admon.graphics.extension=".svg"
+ <format>pdf:<xsl:param>use.role.for.mediaobject=1
+ <format>pdf:<xsl:param>preferred.mediaobject.role=print
+ <format>pdf:<xsl:param>img.src.path=$(images_location)/
+ #<format>pdf:<xsl:param>admon.graphics.path=$(admonishment_location)
+ <format>pdf:<xsl:param>draft.mode="no"
;
install css : [ glob $(BOOST_ROOT)/doc/src/*.css ]
Deleted: branches/doc/libs/unordered/doc/diagrams/buckets.dia
==============================================================================
Binary file. No diff available.
Modified: branches/doc/libs/unordered/doc/diagrams/buckets.png
==============================================================================
Binary files. No diff available.
Modified: branches/doc/libs/unordered/doc/ref.xml
==============================================================================
--- branches/doc/libs/unordered/doc/ref.xml (original)
+++ branches/doc/libs/unordered/doc/ref.xml 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -264,12 +264,11 @@
<method-group name="modifiers">
<method name="emplace">
<template>
- <template-type-parameter name="Args">
+ <template-type-parameter name="Args" pack="1">
</template-type-parameter>
- <template-varargs></template-varargs>
</template>
- <parameter name="args">
- <paramtype>Args&&...</paramtype>
+ <parameter name="args" pack="1">
+ <paramtype>Args&&</paramtype>
</parameter>
<type>std::pair<iterator, bool></type>
<description>
@@ -289,15 +288,14 @@
</method>
<method name="emplace">
<template>
- <template-type-parameter name="Args">
+ <template-type-parameter name="Args" pack="1">
</template-type-parameter>
- <template-varargs></template-varargs>
</template>
<parameter name="hint">
<paramtype>const_iterator</paramtype>
</parameter>
- <parameter name="args">
- <paramtype>Args&&...</paramtype>
+ <parameter name="args" pack="1">
+ <paramtype>Args&&</paramtype>
</parameter>
<type>iterator</type>
<description>
@@ -657,6 +655,71 @@
</throws>
</method>
</method-group>
+ <free-function-group name="Equality Comparisons">
+ <function name="operator==">
+ <template>
+ <template-type-parameter name="Value">
+ </template-type-parameter>
+ <template-type-parameter name="Hash">
+ </template-type-parameter>
+ <template-type-parameter name="Pred">
+ </template-type-parameter>
+ <template-type-parameter name="Alloc">
+ </template-type-parameter>
+ </template>
+ <parameter name="x">
+ <paramtype>unordered_set<Value, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>unordered_set<Value, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <type>bool</type>
+ <notes>
+ <para>This is a boost extension.</para>
+ </notes>
+ </function>
+ <function name="operator!=">
+ <template>
+ <template-type-parameter name="Value">
+ </template-type-parameter>
+ <template-type-parameter name="Hash">
+ </template-type-parameter>
+ <template-type-parameter name="Pred">
+ </template-type-parameter>
+ <template-type-parameter name="Alloc">
+ </template-type-parameter>
+ </template>
+ <parameter name="x">
+ <paramtype>unordered_set<Value, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>unordered_set<Value, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <type>bool</type>
+ <notes>
+ <para>This is a boost extension.</para>
+ </notes>
+ </function>
+ <function name="hash_value">
+ <template>
+ <template-type-parameter name="Value">
+ </template-type-parameter>
+ <template-type-parameter name="Hash">
+ </template-type-parameter>
+ <template-type-parameter name="Pred">
+ </template-type-parameter>
+ <template-type-parameter name="Alloc">
+ </template-type-parameter>
+ </template>
+ <parameter name="x">
+ <paramtype>unordered_set<Value, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <type>std::size_t</type>
+ <notes>
+ <para>This is a boost extension.</para>
+ </notes>
+ </function>
+ </free-function-group>
<free-function-group name="swap">
<function name="swap">
<template>
@@ -948,12 +1011,11 @@
<method-group name="modifiers">
<method name="emplace">
<template>
- <template-type-parameter name="Args">
+ <template-type-parameter name="Args" pack="1">
</template-type-parameter>
- <template-varargs></template-varargs>
</template>
- <parameter name="args">
- <paramtype>Args&&...</paramtype>
+ <parameter name="args" pack="1">
+ <paramtype>Args&&</paramtype>
</parameter>
<type>iterator</type>
<description>
@@ -972,15 +1034,14 @@
</method>
<method name="emplace">
<template>
- <template-type-parameter name="Args">
+ <template-type-parameter name="Args" pack="1">
</template-type-parameter>
- <template-varargs></template-varargs>
</template>
<parameter name="hint">
<paramtype>const_iterator</paramtype>
</parameter>
- <parameter name="args">
- <paramtype>Args&&...</paramtype>
+ <parameter name="args" pack="1">
+ <paramtype>Args&&</paramtype>
</parameter>
<type>iterator</type>
<description>
@@ -1339,6 +1400,71 @@
</throws>
</method>
</method-group>
+ <free-function-group name="Equality Comparisons">
+ <function name="operator==">
+ <template>
+ <template-type-parameter name="Value">
+ </template-type-parameter>
+ <template-type-parameter name="Hash">
+ </template-type-parameter>
+ <template-type-parameter name="Pred">
+ </template-type-parameter>
+ <template-type-parameter name="Alloc">
+ </template-type-parameter>
+ </template>
+ <parameter name="x">
+ <paramtype>unordered_multiset<Value, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>unordered_multiset<Value, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <type>bool</type>
+ <notes>
+ <para>This is a boost extension.</para>
+ </notes>
+ </function>
+ <function name="operator!=">
+ <template>
+ <template-type-parameter name="Value">
+ </template-type-parameter>
+ <template-type-parameter name="Hash">
+ </template-type-parameter>
+ <template-type-parameter name="Pred">
+ </template-type-parameter>
+ <template-type-parameter name="Alloc">
+ </template-type-parameter>
+ </template>
+ <parameter name="x">
+ <paramtype>unordered_multiset<Value, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>unordered_multiset<Value, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <type>bool</type>
+ <notes>
+ <para>This is a boost extension.</para>
+ </notes>
+ </function>
+ <function name="hash_value">
+ <template>
+ <template-type-parameter name="Value">
+ </template-type-parameter>
+ <template-type-parameter name="Hash">
+ </template-type-parameter>
+ <template-type-parameter name="Pred">
+ </template-type-parameter>
+ <template-type-parameter name="Alloc">
+ </template-type-parameter>
+ </template>
+ <parameter name="x">
+ <paramtype>unordered_multiset<Value, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <type>std::size_t</type>
+ <notes>
+ <para>This is a boost extension.</para>
+ </notes>
+ </function>
+ </free-function-group>
<free-function-group name="swap">
<function name="swap">
<template>
@@ -1642,12 +1768,11 @@
<method-group name="modifiers">
<method name="emplace">
<template>
- <template-type-parameter name="Args">
+ <template-type-parameter name="Args" pack="1">
</template-type-parameter>
- <template-varargs></template-varargs>
</template>
- <parameter name="args">
- <paramtype>Args&&...</paramtype>
+ <parameter name="args" pack="1">
+ <paramtype>Args&&</paramtype>
</parameter>
<type>std::pair<iterator, bool></type>
<description>
@@ -1667,15 +1792,14 @@
</method>
<method name="emplace">
<template>
- <template-type-parameter name="Args">
+ <template-type-parameter name="Args" pack="1">
</template-type-parameter>
- <template-varargs></template-varargs>
</template>
<parameter name="hint">
<paramtype>const_iterator</paramtype>
</parameter>
- <parameter name="args">
- <paramtype>Args&&...</paramtype>
+ <parameter name="args" pack="1">
+ <paramtype>Args&&</paramtype>
</parameter>
<type>iterator</type>
<description>
@@ -2070,6 +2194,77 @@
</throws>
</method>
</method-group>
+ <free-function-group name="Equality Comparisons">
+ <function name="operator==">
+ <template>
+ <template-type-parameter name="Key">
+ </template-type-parameter>
+ <template-type-parameter name="Mapped">
+ </template-type-parameter>
+ <template-type-parameter name="Hash">
+ </template-type-parameter>
+ <template-type-parameter name="Pred">
+ </template-type-parameter>
+ <template-type-parameter name="Alloc">
+ </template-type-parameter>
+ </template>
+ <parameter name="x">
+ <paramtype>unordered_map<Key, Mapped, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>unordered_map<Key, Mapped, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <type>bool</type>
+ <notes>
+ <para>This is a boost extension.</para>
+ </notes>
+ </function>
+ <function name="operator!=">
+ <template>
+ <template-type-parameter name="Key">
+ </template-type-parameter>
+ <template-type-parameter name="Mapped">
+ </template-type-parameter>
+ <template-type-parameter name="Hash">
+ </template-type-parameter>
+ <template-type-parameter name="Pred">
+ </template-type-parameter>
+ <template-type-parameter name="Alloc">
+ </template-type-parameter>
+ </template>
+ <parameter name="x">
+ <paramtype>unordered_map<Key, Mapped, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>unordered_map<Key, Mapped, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <type>bool</type>
+ <notes>
+ <para>This is a boost extension.</para>
+ </notes>
+ </function>
+ <function name="hash_value">
+ <template>
+ <template-type-parameter name="Key">
+ </template-type-parameter>
+ <template-type-parameter name="Mapped">
+ </template-type-parameter>
+ <template-type-parameter name="Hash">
+ </template-type-parameter>
+ <template-type-parameter name="Pred">
+ </template-type-parameter>
+ <template-type-parameter name="Alloc">
+ </template-type-parameter>
+ </template>
+ <parameter name="x">
+ <paramtype>unordered_map<Key, Mapped, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <type>std::size_t</type>
+ <notes>
+ <para>This is a boost extension.</para>
+ </notes>
+ </function>
+ </free-function-group>
<free-function-group name="swap">
<function name="swap">
<template>
@@ -2371,12 +2566,11 @@
<method-group name="modifiers">
<method name="emplace">
<template>
- <template-type-parameter name="Args">
+ <template-type-parameter name="Args" pack="1">
</template-type-parameter>
- <template-varargs></template-varargs>
</template>
- <parameter name="args">
- <paramtype>Args&&...</paramtype>
+ <parameter name="args" pack="1">
+ <paramtype>Args&&</paramtype>
</parameter>
<type>iterator</type>
<description>
@@ -2395,15 +2589,14 @@
</method>
<method name="emplace">
<template>
- <template-type-parameter name="Args">
+ <template-type-parameter name="Args" pack="1">
</template-type-parameter>
- <template-varargs></template-varargs>
</template>
<parameter name="hint">
<paramtype>const_iterator</paramtype>
</parameter>
- <parameter name="args">
- <paramtype>Args&&...</paramtype>
+ <parameter name="args" pack="1">
+ <paramtype>Args&&</paramtype>
</parameter>
<type>iterator</type>
<description>
@@ -2762,6 +2955,77 @@
</throws>
</method>
</method-group>
+ <free-function-group name="Equality Comparisons">
+ <function name="operator==">
+ <template>
+ <template-type-parameter name="Key">
+ </template-type-parameter>
+ <template-type-parameter name="Mapped">
+ </template-type-parameter>
+ <template-type-parameter name="Hash">
+ </template-type-parameter>
+ <template-type-parameter name="Pred">
+ </template-type-parameter>
+ <template-type-parameter name="Alloc">
+ </template-type-parameter>
+ </template>
+ <parameter name="x">
+ <paramtype>unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <type>bool</type>
+ <notes>
+ <para>This is a boost extension.</para>
+ </notes>
+ </function>
+ <function name="operator!=">
+ <template>
+ <template-type-parameter name="Key">
+ </template-type-parameter>
+ <template-type-parameter name="Mapped">
+ </template-type-parameter>
+ <template-type-parameter name="Hash">
+ </template-type-parameter>
+ <template-type-parameter name="Pred">
+ </template-type-parameter>
+ <template-type-parameter name="Alloc">
+ </template-type-parameter>
+ </template>
+ <parameter name="x">
+ <paramtype>unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <type>bool</type>
+ <notes>
+ <para>This is a boost extension.</para>
+ </notes>
+ </function>
+ <function name="hash_value">
+ <template>
+ <template-type-parameter name="Key">
+ </template-type-parameter>
+ <template-type-parameter name="Mapped">
+ </template-type-parameter>
+ <template-type-parameter name="Hash">
+ </template-type-parameter>
+ <template-type-parameter name="Pred">
+ </template-type-parameter>
+ <template-type-parameter name="Alloc">
+ </template-type-parameter>
+ </template>
+ <parameter name="x">
+ <paramtype>unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&</paramtype>
+ </parameter>
+ <type>std::size_t</type>
+ <notes>
+ <para>This is a boost extension.</para>
+ </notes>
+ </function>
+ </free-function-group>
<free-function-group name="swap">
<function name="swap">
<template>
Modified: branches/doc/libs/unordered/doc/unordered.qbk
==============================================================================
--- branches/doc/libs/unordered/doc/unordered.qbk (original)
+++ branches/doc/libs/unordered/doc/unordered.qbk 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -22,5 +22,6 @@
[include:unordered hash_equality.qbk]
[include:unordered comparison.qbk]
[include:unordered rationale.qbk]
+[include:unordered changes.qbk]
[xinclude ref.xml]
[xinclude bibliography.xml]
Modified: branches/doc/libs/unordered/test/exception/Jamfile.v2
==============================================================================
--- branches/doc/libs/unordered/test/exception/Jamfile.v2 (original)
+++ branches/doc/libs/unordered/test/exception/Jamfile.v2 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -11,7 +11,7 @@
project unordered-test/exception-tests
: requirements
<toolset>intel-linux:"<cxxflags>-strict_ansi -cxxlib-icc"
- <toolset>gcc:<cxxflags>-Wsign-promo
+ <toolset>gcc:<cxxflags>"-Wsign-promo -Wunused-parameter"
;
test-suite unordered-exception
Modified: branches/doc/libs/unordered/test/helpers/equivalent.hpp
==============================================================================
--- branches/doc/libs/unordered/test/helpers/equivalent.hpp (original)
+++ branches/doc/libs/unordered/test/helpers/equivalent.hpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -8,10 +8,10 @@
#include <boost/unordered_map.hpp>
#include <boost/unordered_set.hpp>
-#include <vector>
#include <algorithm>
#include "./metafunctions.hpp"
#include "./fwd.hpp"
+#include "./list.hpp"
namespace test
{
@@ -56,20 +56,17 @@
BOOST_DEDUCED_TYPENAME Container::key_equal key_equal_;
float max_load_factor_;
- typedef BOOST_DEDUCED_TYPENAME non_const_value_type<Container>::type value_type;
- std::vector<value_type> values_;
+ typedef test::list<BOOST_DEDUCED_TYPENAME Container::value_type>
+ value_list;
+ value_list values_;
public:
unordered_equivalence_tester(Container const &x)
: size_(x.size()),
hasher_(x.hash_function()), key_equal_(x.key_eq()),
max_load_factor_(x.max_load_factor()),
- values_()
+ values_(x.begin(), x.end())
{
- // Can't initialise values_ straight from x because of Visual C++ 6
- values_.reserve(x.size());
- std::copy(x.begin(), x.end(), std::back_inserter(values_));
-
- std::sort(values_.begin(), values_.end());
+ values_.sort();
}
bool operator()(Container const& x) const
@@ -80,11 +77,9 @@
(max_load_factor_ == x.max_load_factor()) &&
(values_.size() == x.size()))) return false;
- std::vector<value_type> copy;
- copy.reserve(x.size());
- std::copy(x.begin(), x.end(), std::back_inserter(copy));
- std::sort(copy.begin(), copy.end());
- return(std::equal(values_.begin(), values_.end(), copy.begin()));
+ value_list copy(x.begin(), x.end());
+ copy.sort();
+ return values_ == copy;
}
private:
unordered_equivalence_tester();
Modified: branches/doc/libs/unordered/test/helpers/exception_test.hpp
==============================================================================
--- branches/doc/libs/unordered/test/helpers/exception_test.hpp (original)
+++ branches/doc/libs/unordered/test/helpers/exception_test.hpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -210,7 +210,7 @@
}
template <class Test>
- void exception_safety(Test const& f, char const* name) {
+ void exception_safety(Test const& f, char const* /*name*/) {
test_runner<Test> runner(f);
iteration = 0;
Modified: branches/doc/libs/unordered/test/helpers/metafunctions.hpp
==============================================================================
--- branches/doc/libs/unordered/test/helpers/metafunctions.hpp (original)
+++ branches/doc/libs/unordered/test/helpers/metafunctions.hpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -75,35 +75,6 @@
sizeof(has_unique_key_impl((Container const*)0))
== sizeof(no_type));
};
-
- // Non Const Value Type
-
- template <bool IsMap>
- struct non_const_value_type_impl
- {
- template <class Container>
- struct apply {
- typedef std::pair<
- BOOST_DEDUCED_TYPENAME Container::key_type,
- BOOST_DEDUCED_TYPENAME Container::mapped_type> type;
- };
- };
-
- template<>
- struct non_const_value_type_impl<false>
- {
- template <class Container>
- struct apply {
- typedef BOOST_DEDUCED_TYPENAME Container::value_type type;
- };
- };
-
- template <class Container>
- struct non_const_value_type
- : non_const_value_type_impl< ::test::is_map<Container>::value>::
- BOOST_NESTED_TEMPLATE apply<Container>
- {
- };
}
#endif
Modified: branches/doc/libs/unordered/test/helpers/random_values.hpp
==============================================================================
--- branches/doc/libs/unordered/test/helpers/random_values.hpp (original)
+++ branches/doc/libs/unordered/test/helpers/random_values.hpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -6,7 +6,7 @@
#if !defined(BOOST_UNORDERED_TEST_HELPERS_RANDOM_VALUES_HEADER)
#define BOOST_UNORDERED_TEST_HELPERS_RANDOM_VALUES_HEADER
-#include <list>
+#include "./list.hpp"
#include <algorithm>
#include <boost/mpl/if.hpp>
#include "./generators.hpp"
@@ -97,7 +97,7 @@
template <class X>
struct random_values
- : public std::list<BOOST_DEDUCED_TYPENAME X::value_type>
+ : public test::list<BOOST_DEDUCED_TYPENAME X::value_type>
{
random_values(int count, test::random_generator const& generator =
test::default_generator)
Modified: branches/doc/libs/unordered/test/helpers/strong.hpp
==============================================================================
--- branches/doc/libs/unordered/test/helpers/strong.hpp (original)
+++ branches/doc/libs/unordered/test/helpers/strong.hpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -7,30 +7,30 @@
#define BOOST_UNORDERED_TEST_HELPERS_STRONG_HEADER
#include <boost/config.hpp>
-#include <vector>
#include <iterator>
#include "./metafunctions.hpp"
#include "./equivalent.hpp"
-#include "../objects/exception.hpp"
+#include "./list.hpp"
+#include "./exception_test.hpp"
namespace test
{
template <class X>
class strong
{
- typedef std::vector<BOOST_DEDUCED_TYPENAME non_const_value_type<X>::type> values_type;
+ typedef test::list<BOOST_DEDUCED_TYPENAME X::value_type> values_type;
values_type values_;
public:
void store(X const& x) {
DISABLE_EXCEPTIONS;
values_.clear();
- values_.reserve(x.size());
- std::copy(x.cbegin(), x.cend(), std::back_inserter(values_));
+ values_.insert(x.cbegin(), x.cend());
}
void test(X const& x) const {
if(!(x.size() == values_.size() &&
- std::equal(x.cbegin(), x.cend(), values_.begin(), test::equivalent)))
+ std::equal(x.cbegin(), x.cend(), values_.begin(),
+ test::equivalent)))
BOOST_ERROR("Strong exception safety failure.");
}
};
Modified: branches/doc/libs/unordered/test/helpers/test.hpp
==============================================================================
--- branches/doc/libs/unordered/test/helpers/test.hpp (original)
+++ branches/doc/libs/unordered/test/helpers/test.hpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -16,10 +16,14 @@
#include <boost/test/minimal.hpp>
#include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/stringize.hpp>
+#include <iostream>
#define UNORDERED_AUTO_TEST(x) \
struct BOOST_PP_CAT(x, _type) : public ::test::registered_test_base { \
- BOOST_PP_CAT(x, _type)() { \
+ BOOST_PP_CAT(x, _type)() \
+ : ::test::registered_test_base(BOOST_PP_STRINGIZE(x)) \
+ { \
::test::test_list::add_test(this); \
} \
void run(); \
@@ -31,6 +35,8 @@
namespace test {
struct registered_test_base {
registered_test_base* next;
+ char const* name;
+ explicit registered_test_base(char const* n) : name(n) {}
virtual void run() = 0;
virtual ~registered_test_base() {}
};
@@ -58,10 +64,14 @@
}
static inline void run_tests() {
- for(registered_test_base* i = first(); i; i = i->next)
+ for(registered_test_base* i = first(); i; i = i->next) {
+ std::cout<<"Running "<<i->name<<"\n"<<std::flush;
i->run();
+ std::cerr<<std::flush;
+ std::cout<<std::flush;
+ }
}
- };
+ }
}
#endif
Modified: branches/doc/libs/unordered/test/helpers/tracker.hpp
==============================================================================
--- branches/doc/libs/unordered/test/helpers/tracker.hpp (original)
+++ branches/doc/libs/unordered/test/helpers/tracker.hpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -11,7 +11,6 @@
#include <set>
#include <map>
-#include <vector>
#include <iterator>
#include <algorithm>
#include <boost/mpl/if.hpp>
@@ -22,6 +21,7 @@
#include "./metafunctions.hpp"
#include "./helpers.hpp"
#include "./equivalent.hpp"
+#include "./list.hpp"
namespace test
{
@@ -44,27 +44,23 @@
template <class X1, class X2>
void compare_range(X1 const& x1, X2 const& x2)
{
- std::vector<BOOST_DEDUCED_TYPENAME non_const_value_type<X1>::type> values1, values2;
- values1.reserve(x1.size());
- values2.reserve(x2.size());
- std::copy(x1.begin(), x1.end(), std::back_inserter(values1));
- std::copy(x2.begin(), x2.end(), std::back_inserter(values2));
- std::sort(values1.begin(), values1.end());
- std::sort(values2.begin(), values2.end());
+ typedef test::list<BOOST_DEDUCED_TYPENAME X1::value_type> value_list;
+ value_list values1(x1.begin(), x1.end());
+ value_list values2(x2.begin(), x2.end());
+ values1.sort();
+ values2.sort();
BOOST_CHECK(values1.size() == values2.size() &&
- std::equal(values1.begin(), values1.end(), values2.begin(), test::equivalent));
+ std::equal(values1.begin(), values1.end(), values2.begin(),
+ test::equivalent));
}
template <class X1, class X2, class T>
void compare_pairs(X1 const& x1, X2 const& x2, T*)
{
- std::vector<T> values1, values2;
- values1.reserve(std::distance(x1.first, x1.second));
- values2.reserve(std::distance(x2.first, x2.second));
- std::copy(x1.first, x1.second, std::back_inserter(values1));
- std::copy(x2.first, x2.second, std::back_inserter(values2));
- std::sort(values1.begin(), values1.end());
- std::sort(values2.begin(), values2.end());
+ test::list<T> values1(x1.first, x1.second);
+ test::list<T> values2(x2.first, x2.second);
+ values1.sort();
+ values2.sort();
BOOST_CHECK(values1.size() == values2.size() &&
std::equal(values1.begin(), values1.end(), values2.begin(), test::equivalent));
}
@@ -123,8 +119,7 @@
compare_pairs(
x.equal_range(get_key<X>(val)),
this->equal_range(get_key<X>(val)),
- (BOOST_DEDUCED_TYPENAME non_const_value_type<X>::type*) 0
- );
+ (BOOST_DEDUCED_TYPENAME X::value_type*) 0);
}
template <class It>
Modified: branches/doc/libs/unordered/test/objects/memory.hpp
==============================================================================
--- branches/doc/libs/unordered/test/objects/memory.hpp (original)
+++ branches/doc/libs/unordered/test/objects/memory.hpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -153,12 +153,12 @@
if(count_allocations > 0) --count_allocations;
}
- void track_construct(void* ptr, std::size_t /*size*/, int tag)
+ void track_construct(void* /*ptr*/, std::size_t /*size*/, int /*tag*/)
{
++count_constructions;
}
- void track_destroy(void* ptr, std::size_t /*size*/, int tag)
+ void track_destroy(void* /*ptr*/, std::size_t /*size*/, int /*tag*/)
{
BOOST_CHECK(count_constructions > 0);
if(count_constructions > 0) --count_constructions;
Modified: branches/doc/libs/unordered/test/objects/minimal.hpp
==============================================================================
--- branches/doc/libs/unordered/test/objects/minimal.hpp (original)
+++ branches/doc/libs/unordered/test/objects/minimal.hpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -22,6 +22,7 @@
namespace minimal
{
class copy_constructible;
+ class copy_constructible_equality_comparable;
class default_copy_constructible;
class assignable;
@@ -42,6 +43,25 @@
copy_constructible() {}
};
+ class copy_constructible_equality_comparable
+ {
+ public:
+ static copy_constructible_equality_comparable create() { return copy_constructible_equality_comparable(); }
+ copy_constructible_equality_comparable(copy_constructible_equality_comparable const&) {}
+ ~copy_constructible_equality_comparable() {}
+ private:
+ copy_constructible_equality_comparable& operator=(copy_constructible_equality_comparable const&);
+ copy_constructible_equality_comparable() {}
+ };
+
+ bool operator==(copy_constructible_equality_comparable, copy_constructible_equality_comparable) {
+ return true;
+ }
+
+ bool operator!=(copy_constructible_equality_comparable, copy_constructible_equality_comparable) {
+ return false;
+ }
+
class default_copy_constructible
{
public:
@@ -246,6 +266,22 @@
}
}
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+namespace boost {
+#else
+namespace test {
+namespace minimal {
+#endif
+ std::size_t hash_value(test::minimal::copy_constructible_equality_comparable) {
+ return 1;
+ }
+#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+}}
+#else
+}
+#endif
+
+
#if defined(BOOST_MSVC)
#pragma warning(pop)
#endif
Modified: branches/doc/libs/unordered/test/objects/test.hpp
==============================================================================
--- branches/doc/libs/unordered/test/objects/test.hpp (original)
+++ branches/doc/libs/unordered/test/objects/test.hpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -11,7 +11,8 @@
#include <cstddef>
#include <iostream>
#include "../helpers/fwd.hpp"
-#include "memory.hpp"
+#include "../helpers/count.hpp"
+#include "./memory.hpp"
#include <map>
namespace test
@@ -25,7 +26,7 @@
template <class T> class allocator;
object generate(object const*);
- class object
+ class object : globally_counted_object
{
friend class hash;
friend class equal_to;
Modified: branches/doc/libs/unordered/test/unordered/Jamfile.v2
==============================================================================
--- branches/doc/libs/unordered/test/unordered/Jamfile.v2 (original)
+++ branches/doc/libs/unordered/test/unordered/Jamfile.v2 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -8,7 +8,7 @@
project unordered-test/unordered
: requirements
<toolset>intel-linux:"<cxxflags>-strict_ansi -cxxlib-icc"
- <toolset>gcc:<cxxflags>-Wsign-promo
+ <toolset>gcc:<cxxflags>"-Wsign-promo -Wunused-parameter"
#<toolset>msvc:<cxxflags>/W4
;
@@ -21,7 +21,7 @@
[ run equivalent_keys_tests.cpp ]
[ run constructor_tests.cpp ]
[ run copy_tests.cpp ]
- [ run move_tests.cpp ]
+ [ run move_tests.cpp : : : <test-info>always_show_run_output ]
[ run assign_tests.cpp ]
[ run insert_tests.cpp ]
[ run insert_stable_tests.cpp ]
@@ -33,5 +33,6 @@
[ run bucket_tests.cpp ]
[ run load_factor_tests.cpp ]
[ run rehash_tests.cpp ]
+ [ run equality_tests.cpp ]
[ run swap_tests.cpp : : : <define>BOOST_UNORDERED_SWAP_METHOD=2 ]
;
Modified: branches/doc/libs/unordered/test/unordered/bucket_tests.cpp
==============================================================================
--- branches/doc/libs/unordered/test/unordered/bucket_tests.cpp (original)
+++ branches/doc/libs/unordered/test/unordered/bucket_tests.cpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -16,11 +16,11 @@
test::seed_t seed(54635);
template <class X>
-void bucket_tests(X* = 0)
+void tests(X* = 0, test::random_generator generator = test::default_generator)
{
typedef BOOST_DEDUCED_TYPENAME X::size_type size_type;
typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator;
- test::random_values<X> v(1000);
+ test::random_values<X> v(1000, generator);
X x(v.begin(), v.end());
@@ -55,7 +55,7 @@
boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_map;
boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multimap;
-UNORDERED_TEST(bucket_tests, ((test_set)(test_multiset)(test_map)(test_multimap)))
+UNORDERED_TEST(tests, ((test_set)(test_multiset)(test_map)(test_multimap)))
}
Modified: branches/doc/libs/unordered/test/unordered/compile_map.cpp
==============================================================================
--- branches/doc/libs/unordered/test/unordered/compile_map.cpp (original)
+++ branches/doc/libs/unordered/test/unordered/compile_map.cpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -22,6 +22,9 @@
test::minimal::copy_constructible::create());
std::cout<<"Test unordered_map.\n";
+
+ boost::unordered_map<int, int> int_map;
+
boost::unordered_map<
test::minimal::assignable,
test::minimal::copy_constructible,
@@ -29,9 +32,13 @@
test::minimal::equal_to<test::minimal::assignable>,
test::minimal::allocator<value_type> > map;
+ container_test(int_map, std::pair<int const, int>(0, 0));
container_test(map, value);
std::cout<<"Test unordered_multimap.\n";
+
+ boost::unordered_multimap<int, int> int_multimap;
+
boost::unordered_multimap<
test::minimal::assignable,
test::minimal::copy_constructible,
@@ -39,9 +46,39 @@
test::minimal::equal_to<test::minimal::assignable>,
test::minimal::allocator<value_type> > multimap;
+ container_test(int_multimap, std::pair<int const, int>(0, 0));
container_test(multimap, value);
}
+UNORDERED_AUTO_TEST(equality_tests) {
+ typedef std::pair<test::minimal::assignable const,
+ test::minimal::copy_constructible> value_type;
+
+ boost::unordered_map<int, int> int_map;
+
+ boost::unordered_map<
+ test::minimal::assignable,
+ test::minimal::copy_constructible_equality_comparable,
+ test::minimal::hash<test::minimal::assignable>,
+ test::minimal::equal_to<test::minimal::assignable>,
+ test::minimal::allocator<value_type> > map;
+
+ equality_test(int_map);
+ equality_test(map);
+
+ boost::unordered_multimap<int, int> int_multimap;
+
+ boost::unordered_multimap<
+ test::minimal::assignable,
+ test::minimal::copy_constructible_equality_comparable,
+ test::minimal::hash<test::minimal::assignable>,
+ test::minimal::equal_to<test::minimal::assignable>,
+ test::minimal::allocator<value_type> > multimap;
+
+ equality_test(int_multimap);
+ equality_test(multimap);
+}
+
UNORDERED_AUTO_TEST(test1) {
boost::hash<int> hash;
std::equal_to<int> equal_to;
Modified: branches/doc/libs/unordered/test/unordered/compile_set.cpp
==============================================================================
--- branches/doc/libs/unordered/test/unordered/compile_set.cpp (original)
+++ branches/doc/libs/unordered/test/unordered/compile_set.cpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -18,24 +18,54 @@
test::minimal::assignable assignable = test::minimal::assignable::create();
std::cout<<"Test unordered_set.\n";
+ boost::unordered_set<int> int_set;
boost::unordered_set<
test::minimal::assignable,
test::minimal::hash<test::minimal::assignable>,
test::minimal::equal_to<test::minimal::assignable>,
test::minimal::allocator<test::minimal::assignable> > set;
+ container_test(int_set, 0);
container_test(set, assignable);
std::cout<<"Test unordered_multiset.\n";
+ boost::unordered_multiset<int> int_multiset;
boost::unordered_multiset<
test::minimal::assignable,
test::minimal::hash<test::minimal::assignable>,
test::minimal::equal_to<test::minimal::assignable>,
test::minimal::allocator<test::minimal::assignable> > multiset;
+ container_test(int_multiset, 0);
container_test(multiset, assignable);
}
+UNORDERED_AUTO_TEST(equality_tests) {
+ typedef test::minimal::assignable value_type;
+
+ boost::unordered_set<int> int_set;
+
+ boost::unordered_set<
+ test::minimal::assignable,
+ test::minimal::hash<test::minimal::assignable>,
+ test::minimal::equal_to<test::minimal::assignable>,
+ test::minimal::allocator<value_type> > set;
+
+ equality_test(int_set);
+ equality_test(set);
+
+ boost::unordered_multiset<int> int_multiset;
+
+ boost::unordered_multiset<
+ test::minimal::assignable,
+ test::minimal::hash<test::minimal::assignable>,
+ test::minimal::equal_to<test::minimal::assignable>,
+ test::minimal::allocator<value_type> > multiset;
+
+ equality_test(int_multiset);
+ equality_test(multiset);
+}
+
UNORDERED_AUTO_TEST(test1)
{
boost::hash<int> hash;
Modified: branches/doc/libs/unordered/test/unordered/compile_tests.hpp
==============================================================================
--- branches/doc/libs/unordered/test/unordered/compile_tests.hpp (original)
+++ branches/doc/libs/unordered/test/unordered/compile_tests.hpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -28,7 +28,7 @@
template <class T> T rvalue(T const& v) { return v; }
template <class X, class T>
-void container_test(X& r, T&)
+void container_test(X& r, T const&)
{
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
@@ -121,8 +121,6 @@
test::check_return_type<const_iterator>::equals(a.cend());
test::check_return_type<const_iterator>::equals(a_const.cend());
- // No tests for ==, != since they're not required for unordered containers.
-
a.swap(b);
test::check_return_type<X>::equals_ref(r = a);
test::check_return_type<size_type>::equals(a.size());
@@ -151,6 +149,8 @@
typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
BOOST_MPL_ASSERT((boost::is_same<value_type, std::pair<key_type const, T> >));
+ r.insert(std::pair<Key const, T>(k, v));
+
#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL)
Key k_lvalue(k);
T v_lvalue(v);
@@ -161,6 +161,20 @@
#endif
}
+template <class X>
+void equality_test(X& r)
+{
+ X const a = r, b = r;
+
+ test::check_return_type<bool>::equals(a == b);
+ test::check_return_type<bool>::equals(a != b);
+#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
+ test::check_return_type<std::size_t>::equals(boost::hash_value(a));
+#else
+ test::check_return_type<std::size_t>::equals(hash_value(a));
+#endif
+}
+
template <class X, class T>
void unordered_unique_test(X& r, T const& t)
{
Modified: branches/doc/libs/unordered/test/unordered/constructor_tests.cpp
==============================================================================
--- branches/doc/libs/unordered/test/unordered/constructor_tests.cpp (original)
+++ branches/doc/libs/unordered/test/unordered/constructor_tests.cpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -253,15 +253,13 @@
}
template <class T>
-void map_constructor_test(T* = 0)
+void map_constructor_test(T* = 0, test::random_generator const& generator = test::default_generator)
{
std::cerr<<"map_constructor_test\n";
- typedef std::list<std::pair<BOOST_DEDUCED_TYPENAME T::key_type, BOOST_DEDUCED_TYPENAME T::mapped_type> > list;
- test::random_values<T> v(1000);
- list l;
- std::copy(v.begin(), v.end(), std::back_inserter(l));
-
+ typedef test::list<std::pair<BOOST_DEDUCED_TYPENAME T::key_type, BOOST_DEDUCED_TYPENAME T::mapped_type> > list;
+ test::random_values<T> v(1000, generator);
+ list l(v.begin(), v.end());
T x(l.begin(), l.end());
test::check_container(x, v);
Modified: branches/doc/libs/unordered/test/unordered/copy_tests.cpp
==============================================================================
--- branches/doc/libs/unordered/test/unordered/copy_tests.cpp (original)
+++ branches/doc/libs/unordered/test/unordered/copy_tests.cpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -36,7 +36,7 @@
}
{
- test::random_values<T> v(1000);
+ test::random_values<T> v(1000, generator);
T x(v.begin(), v.end());
T y(x);
@@ -50,7 +50,7 @@
// is much lower than the load factor. The hash table is not allowed
// to rehash, but the destination container should probably allocate
// enough buckets to decrease the load factor appropriately.
- test::random_values<T> v(1000);
+ test::random_values<T> v(1000, generator);
T x(v.begin(), v.end());
x.max_load_factor(x.load_factor() / 4);
T y(x);
@@ -95,7 +95,7 @@
}
{
- test::random_values<T> v(1000);
+ test::random_values<T> v(1000, generator);
T x(v.begin(), v.end(), 0, hf, eq, al);
T y(x);
@@ -106,7 +106,7 @@
}
{
- test::random_values<T> v(500);
+ test::random_values<T> v(500, generator);
T x(v.begin(), v.end(), 0, hf, eq, al);
T y(x, al2);
Modified: branches/doc/libs/unordered/test/unordered/equivalent_keys_tests.cpp
==============================================================================
--- branches/doc/libs/unordered/test/unordered/equivalent_keys_tests.cpp (original)
+++ branches/doc/libs/unordered/test/unordered/equivalent_keys_tests.cpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -8,7 +8,7 @@
#include "../helpers/test.hpp"
#include <algorithm>
#include <map>
-#include <list>
+#include "../helpers/list.hpp"
#include "../helpers/tracker.hpp"
#include "../helpers/invariants.hpp"
@@ -57,7 +57,7 @@
UNORDERED_AUTO_TEST(map_tests)
{
- typedef std::list<std::pair<int const, int> > values_type;
+ typedef test::list<std::pair<int const, int> > values_type;
values_type v[5];
v[0].push_back(std::pair<int const, int>(1,1));
v[1].push_back(std::pair<int const, int>(28,34));
Modified: branches/doc/libs/unordered/test/unordered/erase_equiv_tests.cpp
==============================================================================
--- branches/doc/libs/unordered/test/unordered/erase_equiv_tests.cpp (original)
+++ branches/doc/libs/unordered/test/unordered/erase_equiv_tests.cpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -8,7 +8,7 @@
#include <boost/unordered_map.hpp>
#include "../helpers/test.hpp"
-#include <list>
+#include "../helpers/list.hpp"
#include <set>
#include <iostream>
#include <iterator>
@@ -50,7 +50,7 @@
collision2_hash, std::equal_to<int>,
test::allocator<std::pair<int const, int> > > collide_map2;
typedef collide_map::value_type collide_value;
-typedef std::list<collide_value> collide_list;
+typedef test::list<collide_value> collide_list;
UNORDERED_AUTO_TEST(empty_range_tests)
{
@@ -108,10 +108,8 @@
template<class Range1, class Range2>
bool compare(Range1 const& x, Range2 const& y)
{
- collide_list a;
- collide_list b;
- std::copy(x.begin(), x.end(), std::back_inserter(a));
- std::copy(y.begin(), y.end(), std::back_inserter(b));
+ collide_list a(x.begin(), x.end());
+ collide_list b(y.begin(), y.end());
a.sort();
b.sort();
return a == b;
@@ -120,8 +118,7 @@
template <class Container>
bool general_erase_range_test(Container& x, int start, int end)
{
- collide_list l;
- std::copy(x.begin(), x.end(), std::back_inserter(l));
+ collide_list l(x.begin(), x.end());
l.erase(boost::next(l.begin(), start), boost::next(l.begin(), end));
x.erase(boost::next(x.begin(), start), boost::next(x.begin(), end));
return compare(l, x);
@@ -133,8 +130,7 @@
for(std::size_t length = 0; length < x.size(); ++length) {
for(std::size_t position = 0; position < x.size() - length; ++position) {
Container y(x);
- collide_list init;
- std::copy(y.begin(), y.end(), std::back_inserter(init));
+ collide_list init(y.begin(), y.end());
if(!general_erase_range_test(y, position, position + length)) {
BOOST_ERROR("general_erase_range_test failed.");
std::cout<<"Erase: ["<<position<<","<<position + length<<")\n";
Modified: branches/doc/libs/unordered/test/unordered/find_tests.cpp
==============================================================================
--- branches/doc/libs/unordered/test/unordered/find_tests.cpp (original)
+++ branches/doc/libs/unordered/test/unordered/find_tests.cpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -43,10 +43,10 @@
test::compare_pairs(x.equal_range(key),
tracker.equal_range(key),
- (BOOST_DEDUCED_TYPENAME test::non_const_value_type<X>::type*) 0);
+ (BOOST_DEDUCED_TYPENAME X::value_type*) 0);
test::compare_pairs(x_const.equal_range(key),
tracker.equal_range(key),
- (BOOST_DEDUCED_TYPENAME test::non_const_value_type<X>::type*) 0);
+ (BOOST_DEDUCED_TYPENAME X::value_type*) 0);
}
test::random_values<X> v2(500, generator);
Modified: branches/doc/libs/unordered/test/unordered/insert_tests.cpp
==============================================================================
--- branches/doc/libs/unordered/test/unordered/insert_tests.cpp (original)
+++ branches/doc/libs/unordered/test/unordered/insert_tests.cpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -318,10 +318,9 @@
{
std::cerr<<"associative_insert_range_test\n";
- typedef std::list<std::pair<BOOST_DEDUCED_TYPENAME X::key_type, BOOST_DEDUCED_TYPENAME X::mapped_type> > list;
+ typedef test::list<std::pair<BOOST_DEDUCED_TYPENAME X::key_type, BOOST_DEDUCED_TYPENAME X::mapped_type> > list;
test::random_values<X> v(1000, generator);
- list l;
- std::copy(v.begin(), v.end(), std::back_inserter(l));
+ list l(v.begin(), v.end());
X x; x.insert(l.begin(), l.end());
Modified: branches/doc/libs/unordered/test/unordered/load_factor_tests.cpp
==============================================================================
--- branches/doc/libs/unordered/test/unordered/load_factor_tests.cpp (original)
+++ branches/doc/libs/unordered/test/unordered/load_factor_tests.cpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -20,7 +20,7 @@
test::seed_t seed(783656);
template <class X>
-void load_factor_tests(X* = 0)
+void set_load_factor_tests(X* = 0)
{
X x;
@@ -34,13 +34,13 @@
}
template <class X>
-void insert_test(X*, float mlf)
+void insert_test(X*, float mlf, test::random_generator generator = test::default_generator)
{
X x;
x.max_load_factor(mlf);
float b = x.max_load_factor();
- test::random_values<X> values(1000);
+ test::random_values<X> values(1000, generator);
for(BOOST_DEDUCED_TYPENAME test::random_values<X>::const_iterator
it = values.begin(), end = values.end(); it != end; ++it)
@@ -71,7 +71,7 @@
boost::unordered_map<int, int>* int_map_ptr;
boost::unordered_multimap<int, int>* int_multimap_ptr;
-UNORDERED_TEST(load_factor_tests,
+UNORDERED_TEST(set_load_factor_tests,
((int_set_ptr)(int_multiset_ptr)(int_map_ptr)(int_multimap_ptr))
)
Modified: branches/doc/libs/unordered/test/unordered/move_tests.cpp
==============================================================================
--- branches/doc/libs/unordered/test/unordered/move_tests.cpp (original)
+++ branches/doc/libs/unordered/test/unordered/move_tests.cpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -17,21 +17,21 @@
test::seed_t seed(98624);
template<class T>
- T empty(T* ptr) {
+ T empty(T*) {
return T();
}
template<class T>
T create(test::random_values<T> const& v,
- BOOST_DEDUCED_TYPENAME T::value_type const*& first) {
+ test::object_count& count) {
T x(v.begin(), v.end());
- first = &*x.begin();
+ count = test::global_object_count;
return x;
}
template<class T>
T create(test::random_values<T> const& v,
- BOOST_DEDUCED_TYPENAME T::value_type const*& first,
+ test::object_count& count,
BOOST_DEDUCED_TYPENAME T::hasher hf,
BOOST_DEDUCED_TYPENAME T::key_equal eq,
BOOST_DEDUCED_TYPENAME T::allocator_type al,
@@ -39,7 +39,7 @@
T x(0, hf, eq, al);
x.max_load_factor(mlf);
x.insert(v.begin(), v.end());
- first = &*x.begin();
+ count = test::global_object_count;
return x;
}
@@ -61,46 +61,44 @@
}
{
- test::random_values<T> v(1000);
- BOOST_DEDUCED_TYPENAME T::value_type const* first = 0;
- T y(create(v, first));
- BOOST_CHECK(first == &*y.begin());
+ test::random_values<T> v(1000, generator);
+ test::object_count count;
+ T y(create(v, count));
+ BOOST_CHECK(count == test::global_object_count);
test::check_container(y, v);
test::check_equivalent_keys(y);
}
}
template <class T>
- void move_assign_tests1(T* ptr, test::random_generator const& generator = test::default_generator)
+ void move_assign_tests1(T*, test::random_generator const& generator = test::default_generator)
{
{
- test::random_values<T> v(500);
- BOOST_DEDUCED_TYPENAME T::value_type const* first = 0;
+ test::random_values<T> v(500, generator);
+ test::object_count count;
T y;
- y = create(v, first);
- BOOST_CHECK(first == &*y.begin());
+ y = create(v, count);
+ BOOST_CHECK(count == test::global_object_count);
test::check_container(y, v);
test::check_equivalent_keys(y);
}
}
template <class T>
- void move_construct_tests2(T* ptr,
+ void move_construct_tests2(T*,
test::random_generator const& generator = test::default_generator)
{
- move_construct_tests1(ptr);
-
BOOST_DEDUCED_TYPENAME T::hasher hf(1);
BOOST_DEDUCED_TYPENAME T::key_equal eq(1);
BOOST_DEDUCED_TYPENAME T::allocator_type al(1);
BOOST_DEDUCED_TYPENAME T::allocator_type al2(2);
- BOOST_DEDUCED_TYPENAME T::value_type const* first;
+ test::object_count count;
{
- test::random_values<T> v(500);
- T y(create(v, first, hf, eq, al, 0.5));
- BOOST_CHECK(first == &*y.begin());
+ test::random_values<T> v(500, generator);
+ T y(create(v, count, hf, eq, al, 0.5));
+ BOOST_CHECK(count == test::global_object_count);
test::check_container(y, v);
BOOST_CHECK(test::equivalent(y.hash_function(), hf));
BOOST_CHECK(test::equivalent(y.key_eq(), eq));
@@ -111,9 +109,9 @@
{
// TODO: To do this correctly requires the fancy new allocator stuff.
- test::random_values<T> v(500);
- T y(create(v, first, hf, eq, al, 2.0), al2);
- BOOST_CHECK(first != &*y.begin());
+ test::random_values<T> v(500, generator);
+ T y(create(v, count, hf, eq, al, 2.0), al2);
+ BOOST_CHECK(count != test::global_object_count);
test::check_container(y, v);
BOOST_CHECK(test::equivalent(y.hash_function(), hf));
BOOST_CHECK(test::equivalent(y.key_eq(), eq));
@@ -123,9 +121,15 @@
}
{
- test::random_values<T> v(25);
- T y(create(v, first, hf, eq, al, 1.0), al);
- BOOST_CHECK(first == &*y.begin());
+ test::random_values<T> v(25, generator);
+ T y(create(v, count, hf, eq, al, 1.0), al);
+#if defined(BOOST_HAS_RVALUE_REFS)
+ BOOST_CHECK(count == test::global_object_count);
+#else
+ BOOST_CHECK(test::global_object_count.constructions - count.constructions <=
+ (test::is_map<T>::value ? 50 : 25));
+ BOOST_CHECK(count.instances == test::global_object_count.instances);
+#endif
test::check_container(y, v);
BOOST_CHECK(test::equivalent(y.hash_function(), hf));
BOOST_CHECK(test::equivalent(y.key_eq(), eq));
Modified: branches/doc/libs/unordered/test/unordered/rehash_tests.cpp
==============================================================================
--- branches/doc/libs/unordered/test/unordered/rehash_tests.cpp (original)
+++ branches/doc/libs/unordered/test/unordered/rehash_tests.cpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -33,9 +33,9 @@
}
template <class X>
-void rehash_test1(X* = 0)
+void rehash_test1(X* = 0, test::random_generator generator = test::default_generator)
{
- test::random_values<X> v(1000);
+ test::random_values<X> v(1000, generator);
test::ordered<X> tracker;
tracker.insert_range(v.begin(), v.end());
X x(v.begin(), v.end());
@@ -55,19 +55,15 @@
tracker.compare(x);
}
-template <class X>
-void rehash_tests(X* ptr = 0)
-{
- rehash_empty_test1(ptr);
- rehash_test1(ptr);
-}
-
boost::unordered_set<int>* int_set_ptr;
boost::unordered_multiset<int>* int_multiset_ptr;
boost::unordered_map<int, int>* int_map_ptr;
boost::unordered_multimap<int, int>* int_multimap_ptr;
-UNORDERED_TEST(rehash_tests,
+UNORDERED_TEST(rehash_empty_test1,
+ ((int_set_ptr)(int_multiset_ptr)(int_map_ptr)(int_multimap_ptr))
+)
+UNORDERED_TEST(rehash_test1,
((int_set_ptr)(int_multiset_ptr)(int_map_ptr)(int_multimap_ptr))
)
Modified: branches/doc/libs/unordered/test/unordered/swap_tests.cpp
==============================================================================
--- branches/doc/libs/unordered/test/unordered/swap_tests.cpp (original)
+++ branches/doc/libs/unordered/test/unordered/swap_tests.cpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -32,7 +32,7 @@
}
template <class X>
-void swap_tests1(X* = 0)
+void swap_tests1(X*, test::random_generator generator = test::default_generator)
{
{
X x;
@@ -45,14 +45,14 @@
}
{
- test::random_values<X> v(1000);
+ test::random_values<X> v(1000, generator);
X x, y(v.begin(), v.end());
swap_test_impl(x, y);
swap_test_impl(x, y);
}
{
- test::random_values<X> vx(1000), vy(1000);
+ test::random_values<X> vx(1000, generator), vy(1000, generator);
X x(vx.begin(), vx.end()), y(vy.begin(), vy.end());
swap_test_impl(x, y);
swap_test_impl(x, y);
@@ -60,7 +60,7 @@
}
template <class X>
-void swap_tests2(X* ptr = 0)
+void swap_tests2(X* ptr = 0, test::random_generator generator = test::default_generator)
{
swap_tests1(ptr);
@@ -75,14 +75,14 @@
}
{
- test::random_values<X> v(1000);
+ test::random_values<X> v(1000, generator);
X x(v.begin(), v.end(), 0, hasher(1), key_equal(1));
X y(0, hasher(2), key_equal(2));
swap_test_impl(x, y);
}
{
- test::random_values<X> vx(100), vy(50);
+ test::random_values<X> vx(100, generator), vy(50, generator);
X x(vx.begin(), vx.end(), 0, hasher(1), key_equal(1));
X y(vy.begin(), vy.end(), 0, hasher(2), key_equal(2));
swap_test_impl(x, y);
@@ -91,7 +91,7 @@
#if BOOST_UNORDERED_SWAP_METHOD == 1
{
- test::random_values<X> vx(100), vy(50);
+ test::random_values<X> vx(100, generator), vy(50, generator);
X x(vx.begin(), vx.end(), 0, hasher(), key_equal(), allocator_type(1));
X y(vy.begin(), vy.end(), 0, hasher(), key_equal(), allocator_type(2));
try {
@@ -101,14 +101,14 @@
}
#else
{
- test::random_values<X> vx(50), vy(100);
+ test::random_values<X> vx(50, generator), vy(100, generator);
X x(vx.begin(), vx.end(), 0, hasher(), key_equal(), allocator_type(1));
X y(vy.begin(), vy.end(), 0, hasher(), key_equal(), allocator_type(2));
swap_test_impl(x, y);
}
{
- test::random_values<X> vx(100), vy(100);
+ test::random_values<X> vx(100, generator), vy(100, generator);
X x(vx.begin(), vx.end(), 0, hasher(1), key_equal(1), allocator_type(1));
X y(vy.begin(), vy.end(), 0, hasher(2), key_equal(2), allocator_type(2));
swap_test_impl(x, y);
Modified: branches/doc/libs/unordered/test/unordered/unnecessary_copy_tests.cpp
==============================================================================
--- branches/doc/libs/unordered/test/unordered/unnecessary_copy_tests.cpp (original)
+++ branches/doc/libs/unordered/test/unordered/unnecessary_copy_tests.cpp 2008-05-28 19:30:07 EDT (Wed, 28 May 2008)
@@ -15,7 +15,19 @@
static int moves;
count_copies() : tag_(0) { ++copies; }
explicit count_copies(int tag) : tag_(tag) { ++copies; }
- count_copies(count_copies const&, count_copies const& x) : tag_(x.tag_) { ++copies; }
+
+ // This bizarre constructor is an attempt to confuse emplace.
+ //
+ // unordered_map<count_copies, count_copies> x:
+ // x.emplace(count_copies(1), count_copies(2));
+ // x.emplace(count_copies(1), count_copies(2), count_copies(3));
+ //
+ // The first emplace should use the single argument constructor twice.
+ // The second emplace should use the single argument contructor for
+ // the key, and this constructor for the value.
+ count_copies(count_copies const&, count_copies const& x)
+ : tag_(x.tag_) { ++copies; }
+
count_copies(count_copies const& x) : tag_(x.tag_) { ++copies; }
#if defined(BOOST_HAS_RVALUE_REFS)
count_copies(count_copies&& x) : tag_(x.tag_) {
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