diff --git a/include/boost/unordered/detail/hash_table.hpp b/include/boost/unordered/detail/hash_table.hpp index aabe0586..59c7f072 100644 --- a/include/boost/unordered/detail/hash_table.hpp +++ b/include/boost/unordered/detail/hash_table.hpp @@ -35,10 +35,6 @@ #include -#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) -#include -#endif - // See hash_table::swap() for details about this. #if !defined(BOOST_UNORDERED_SWAP_METHOD) #define BOOST_UNORDERED_SWAP_METHOD 3 @@ -65,6 +61,7 @@ namespace boost { template struct type_wrapper {}; const static std::size_t default_initial_bucket_count = 50; + const static float minimum_max_load_factor = 1e-3; inline std::size_t next_prime(std::size_t n); template @@ -73,7 +70,7 @@ namespace boost { #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) std::swap(x,y); #else - using namespace std; + using std::swap; swap(x, y); #endif } diff --git a/include/boost/unordered/detail/hash_table_impl.hpp b/include/boost/unordered/detail/hash_table_impl.hpp index 62c3c22f..7d52c9f6 100644 --- a/include/boost/unordered/detail/hash_table_impl.hpp +++ b/include/boost/unordered/detail/hash_table_impl.hpp @@ -1056,25 +1056,9 @@ namespace boost { private: - // From the compressed functions docs: - // - // "Finally, a word of caution for Visual C++ 6 users: if either - // argument is an empty type, then assigning to that member will - // produce memory corruption, unless the empty type has a "do - // nothing" assignment operator defined. This is due to a bug in - // the way VC6 generates implicit assignment operators." - // - // Nice. - // - // So use std::pair for Visual C++. - class functions { -#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) - boost::compressed_pair functions_; -#else std::pair functions_; -#endif public: @@ -1083,20 +1067,12 @@ namespace boost { hasher const& hash_function() const { -#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) - return functions_.first(); -#else return functions_.first; -#endif } key_equal const& key_eq() const { -#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) - return functions_.second(); -#else return functions_.second; -#endif } }; @@ -1429,8 +1405,9 @@ namespace boost { { bool need_to_reserve = n >= max_load_; // throws - basic: - if (need_to_reserve) rehash_impl(min_buckets_for_size(n)); - BOOST_ASSERT(n < max_load_); + if (need_to_reserve) rehash_impl(min_buckets_for_size(n)); + // TODO: Deal with this special case better: + BOOST_ASSERT(n < max_load_ || this->bucket_count_ == max_bucket_count()); return need_to_reserve; } @@ -1443,13 +1420,10 @@ namespace boost { } // no throw - // - // TODO: the argument is a hint. So don't use it if it's - // unreasonably small. void max_load_factor(float z) { BOOST_ASSERT(z > 0); - mlf_ = z; + mlf_ = (std::max)(z, minimum_max_load_factor); calculate_max_load(); }