diff --git a/include/boost/unordered/detail/hash_table_impl.hpp b/include/boost/unordered/detail/hash_table_impl.hpp index 4eee2693..61c1da8e 100644 --- a/include/boost/unordered/detail/hash_table_impl.hpp +++ b/include/boost/unordered/detail/hash_table_impl.hpp @@ -1677,10 +1677,10 @@ namespace boost { // if hash function throws, or inserting > 1 element, basic exception safety // strong otherwise - template - void insert(InputIterator i, InputIterator j) + template + void insert(I i, I j) { - BOOST_DEDUCED_TYPENAME boost::iterator_traversal::type + BOOST_DEDUCED_TYPENAME boost::iterator_traversal::type iterator_traversal_tag; insert_for_range(i, j, iterator_traversal_tag); } @@ -1789,6 +1789,14 @@ namespace boost { return 1; } + template + std::size_t insert_size(I i, I j) + { + BOOST_DEDUCED_TYPENAME boost::iterator_traversal::type + iterator_traversal_tag; + return insert_size(i, j, iterator_traversal_tag); + }; + // if hash function throws, or inserting > 1 element, basic exception safety // strong otherwise template @@ -1817,10 +1825,7 @@ namespace boost { // reserve has basic exception safety if the hash function // throws, strong otherwise. if(size() + 1 >= max_load_) { - BOOST_DEDUCED_TYPENAME boost::iterator_traversal::type - iterator_traversal_tag; - - reserve(size() + insert_size(i, j, iterator_traversal_tag)); + reserve(size() + insert_size(i, j)); bucket = this->buckets_ + this->index_from_hash(hash_value); } diff --git a/test/helpers/equivalent.hpp b/test/helpers/equivalent.hpp index 924c79f6..1b9339aa 100644 --- a/test/helpers/equivalent.hpp +++ b/test/helpers/equivalent.hpp @@ -11,12 +11,10 @@ #include #include #include "./metafunctions.hpp" +#include "./fwd.hpp" namespace test { - struct base_type {} base; - struct derived_type : base_type {} derived; - template bool equivalent_impl(T1 const& x, T2 const& y, base_type) { return x == y; diff --git a/test/helpers/fwd.hpp b/test/helpers/fwd.hpp index 99c84721..95b4ef5a 100644 --- a/test/helpers/fwd.hpp +++ b/test/helpers/fwd.hpp @@ -16,6 +16,9 @@ namespace test float generate(float const*); template std::pair generate(std::pair*); + + struct base_type {} base; + struct derived_type : base_type {} derived; } #endif diff --git a/test/objects/test.hpp b/test/objects/test.hpp index 6fda7bbb..6777a1d5 100644 --- a/test/objects/test.hpp +++ b/test/objects/test.hpp @@ -339,26 +339,21 @@ namespace test return (std::numeric_limits::max)(); } - friend bool operator==(allocator const& x, allocator const& y); - - friend bool operator!=(allocator const& x, allocator const& y) + bool operator==(allocator const& x) const { - return x.tag_ != y.tag_; + return tag_ == x.tag_; + } + + bool operator!=(allocator const& x) const + { + return tag_ != x.tag_; } }; -} - -#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) -namespace test -{ -#endif + template - bool operator==(test::allocator const& x, test::allocator const& y) - { - return x.tag_ == y.tag_; + bool equivalent_impl(allocator const& x, allocator const& y, test::derived_type) { + return x == y; } -#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) } -#endif #endif diff --git a/test/unordered/compile_tests.cpp b/test/unordered/compile_tests.cpp index b9e9c3ad..f52324a9 100644 --- a/test/unordered/compile_tests.cpp +++ b/test/unordered/compile_tests.cpp @@ -20,17 +20,18 @@ template void sink(T const&) {} template void unordered_set_test(X& r, Key const& k) { - BOOST_MPL_ASSERT((boost::is_same< - typename X::value_type, - typename X::key_type>)); + typedef typename X::value_type value_type; + typedef typename X::key_type key_type; + + BOOST_MPL_ASSERT((boost::is_same)); } template void unordered_map_test(X& r, Key const& k, T const& t) { - BOOST_MPL_ASSERT((boost::is_same< - typename X::value_type, - std::pair >)); + typedef typename X::value_type value_type; + typedef typename X::key_type key_type; + BOOST_MPL_ASSERT((boost::is_same >)); } template @@ -50,14 +51,35 @@ void unordered_equivalent_test(X& r, T const& t) template void unordered_test(X& ref, Key& k, T& t, Hash& hf, Pred& eq) { + typedef typename X::key_type key_type; + typedef typename X::hasher hasher; + typedef typename X::key_equal key_equal; + typedef typename X::size_type size_type; + typedef typename X::iterator iterator; typedef typename X::const_iterator const_iterator; typedef typename X::local_iterator local_iterator; typedef typename X::const_local_iterator const_local_iterator; - - typedef typename X::key_type key_type; - typedef typename X::hasher hasher; - typedef typename X::key_equal key_equal; + + typedef typename boost::BOOST_ITERATOR_CATEGORY::type iterator_category; + typedef typename boost::iterator_difference::type iterator_difference; + typedef typename boost::iterator_pointer::type iterator_pointer; + typedef typename boost::iterator_reference::type iterator_reference; + + typedef typename boost::BOOST_ITERATOR_CATEGORY::type local_iterator_category; + typedef typename boost::iterator_difference::type local_iterator_difference; + typedef typename boost::iterator_pointer::type local_iterator_pointer; + typedef typename boost::iterator_reference::type local_iterator_reference; + + typedef typename boost::BOOST_ITERATOR_CATEGORY::type const_iterator_category; + typedef typename boost::iterator_difference::type const_iterator_difference; + typedef typename boost::iterator_pointer::type const_iterator_pointer; + typedef typename boost::iterator_reference::type const_iterator_reference; + + typedef typename boost::BOOST_ITERATOR_CATEGORY::type const_local_iterator_category; + typedef typename boost::iterator_difference::type const_local_iterator_difference; + typedef typename boost::iterator_pointer::type const_local_iterator_pointer; + typedef typename boost::iterator_reference::type const_local_iterator_reference; BOOST_MPL_ASSERT((boost::is_same)); boost::function_requires >(); @@ -72,32 +94,16 @@ void unordered_test(X& ref, Key& k, T& t, Hash& hf, Pred& eq) // tests. boost::function_requires >(); - BOOST_MPL_ASSERT((boost::is_same< - typename boost::BOOST_ITERATOR_CATEGORY::type, - typename boost::BOOST_ITERATOR_CATEGORY::type >)); - BOOST_MPL_ASSERT((boost::is_same< - typename boost::iterator_difference::type, - typename boost::iterator_difference::type >)); - BOOST_MPL_ASSERT((boost::is_same< - typename boost::iterator_pointer::type, - typename boost::iterator_pointer::type >)); - BOOST_MPL_ASSERT((boost::is_same< - typename boost::iterator_reference::type, - typename boost::iterator_reference::type >)); + BOOST_MPL_ASSERT((boost::is_same)); + BOOST_MPL_ASSERT((boost::is_same)); + BOOST_MPL_ASSERT((boost::is_same)); + BOOST_MPL_ASSERT((boost::is_same)); boost::function_requires >(); - BOOST_MPL_ASSERT((boost::is_same< - typename boost::BOOST_ITERATOR_CATEGORY::type, - typename boost::BOOST_ITERATOR_CATEGORY::type >)); - BOOST_MPL_ASSERT((boost::is_same< - typename boost::iterator_difference::type, - typename boost::iterator_difference::type >)); - BOOST_MPL_ASSERT((boost::is_same< - typename boost::iterator_pointer::type, - typename boost::iterator_pointer::type >)); - BOOST_MPL_ASSERT((boost::is_same< - typename boost::iterator_reference::type, - typename boost::iterator_reference::type >)); + BOOST_MPL_ASSERT((boost::is_same)); + BOOST_MPL_ASSERT((boost::is_same)); + BOOST_MPL_ASSERT((boost::is_same)); + BOOST_MPL_ASSERT((boost::is_same)); X(10, hf, eq); X a(10, hf, eq); @@ -135,7 +141,7 @@ void unordered_test(X& ref, Key& k, T& t, Hash& hf, Pred& eq) // TODO: void return? a.insert(i, j); - test::check_return_type::equals(a.erase(k)); + test::check_return_type::equals(a.erase(k)); BOOST_TEST(a.empty()); if(a.empty()) { @@ -162,15 +168,15 @@ void unordered_test(X& ref, Key& k, T& t, Hash& hf, Pred& eq) test::check_return_type::equals(a.find(k)); test::check_return_type::equals(b.find(k)); - test::check_return_type::equals(b.count(k)); + test::check_return_type::equals(b.count(k)); test::check_return_type >::equals( a.equal_range(k)); test::check_return_type >::equals( b.equal_range(k)); - test::check_return_type::equals(b.bucket_count()); - test::check_return_type::equals(b.max_bucket_count()); - test::check_return_type::equals(b.bucket(k)); - test::check_return_type::equals(b.bucket_size(0)); + test::check_return_type::equals(b.bucket_count()); + test::check_return_type::equals(b.max_bucket_count()); + test::check_return_type::equals(b.bucket(k)); + test::check_return_type::equals(b.bucket_size(0)); test::check_return_type::equals(a.begin(0)); test::check_return_type::equals(b.begin(0));