Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55189 - in branches/release: . boost/unordered boost/unordered/detail libs/unordered/doc libs/unordered/test/exception libs/unordered/test/helpers
From: daniel_james_at_[hidden]
Date: 2009-07-30 14:43:02


Author: danieljames
Date: 2009-07-26 16:22:48 EDT (Sun, 26 Jul 2009)
New Revision: 55189
URL: http://svn.boost.org/trac/boost/changeset/55189

Log:
Merge unordered changes, including fixes for Boost.TR1.

Merged revisions 55099-55100,55132,55138,55184-55185 via svnmerge from
https://svn.boost.org/svn/boost/trunk

........
  r55099 | danieljames | 2009-07-22 23:37:52 +0100 (Wed, 22 Jul 2009) | 1 line
  
  Fix the insert tests when there is a small number of buckets.
........
  r55100 | danieljames | 2009-07-22 23:38:08 +0100 (Wed, 22 Jul 2009) | 1 line
  
  Adjust the unordered defaults so that emplace takes more parameters and less buckets are created by default.
........
  r55132 | danieljames | 2009-07-23 18:53:59 +0100 (Thu, 23 Jul 2009) | 1 line
  
  Remove the emulation of single argument C++0x std::pair constructor.
........
  r55138 | danieljames | 2009-07-23 23:17:20 +0100 (Thu, 23 Jul 2009) | 1 line
  
  Try to work around an odd Visual C++ 8 bug.
........
  r55184 | danieljames | 2009-07-26 19:59:33 +0100 (Sun, 26 Jul 2009) | 1 line
  
  Some extra changelog notes.
........
  r55185 | danieljames | 2009-07-26 20:00:40 +0100 (Sun, 26 Jul 2009) | 1 line
  
  Update the reference documentation to mention that emplace is now emulated.
........

Properties modified:
   branches/release/ (props changed)
Text files modified:
   branches/release/boost/unordered/detail/hash_table.hpp | 4 +-
   branches/release/boost/unordered/detail/hash_table_impl.hpp | 64 +++++-----------------------------------
   branches/release/boost/unordered/unordered_map.hpp | 26 +++++++++++++--
   branches/release/boost/unordered/unordered_set.hpp | 24 ++++++++++++--
   branches/release/libs/unordered/doc/changes.qbk | 9 ++++-
   branches/release/libs/unordered/doc/ref.xml | 32 +++++++++++++++-----
   branches/release/libs/unordered/test/exception/insert_exception_tests.cpp | 2
   branches/release/libs/unordered/test/helpers/input_iterator.hpp | 19 ++++++++++-
   8 files changed, 101 insertions(+), 79 deletions(-)

Modified: branches/release/boost/unordered/detail/hash_table.hpp
==============================================================================
--- branches/release/boost/unordered/detail/hash_table.hpp (original)
+++ branches/release/boost/unordered/detail/hash_table.hpp 2009-07-26 16:22:48 EDT (Sun, 26 Jul 2009)
@@ -15,7 +15,7 @@
 #include <boost/unordered/detail/config.hpp>
 
 #if !defined(BOOST_UNORDERED_EMPLACE_LIMIT)
-#define BOOST_UNORDERED_EMPLACE_LIMIT 5
+#define BOOST_UNORDERED_EMPLACE_LIMIT 10
 #endif
 
 #include <cstddef>
@@ -85,7 +85,7 @@
     namespace unordered_detail {
         template <class T> struct type_wrapper {};
 
- static const std::size_t default_initial_bucket_count = 50;
+ static const std::size_t default_initial_bucket_count = 11;
         static const float minimum_max_load_factor = 1e-3f;
 
         inline std::size_t double_to_size_t(double f)

Modified: branches/release/boost/unordered/detail/hash_table_impl.hpp
==============================================================================
--- branches/release/boost/unordered/detail/hash_table_impl.hpp (original)
+++ branches/release/boost/unordered/detail/hash_table_impl.hpp 2009-07-26 16:22:48 EDT (Sun, 26 Jul 2009)
@@ -206,55 +206,6 @@
                     new(node_->address()) value_type(std::forward<Args>(args)...);
                     value_constructed_ = true;
                 }
-
-#if defined(__GLIBCPP__) || defined(__GLIBCXX__)
- // The GCC C++0x standard library implementation does not have
- // a single argument pair constructor, so this works around that.
-
- template <typename Arg>
- void construct(Arg&& arg)
- {
- construct_preamble();
- construct_impl(std::forward<Arg>(arg),
- (value_type const*) 0,
- (typename boost::remove_reference<Arg>::type const*) 0);
- value_constructed_ = true;
- }
-
- template <
- typename Arg,
- typename ValueType,
- typename Type>
- void construct_impl(Arg&& arg, ValueType const*, Type const*)
- {
- new(node_->address()) value_type(std::forward<Arg>(arg));
- }
-
- template <
- typename Arg,
- typename ValueFirst, typename ValueSecond,
- typename TypeFirst, typename TypeSecond>
- void construct_impl(
- Arg&& arg,
- std::pair<ValueFirst, ValueSecond> const*,
- std::pair<TypeFirst, TypeSecond> const*)
- {
- new(node_->address()) value_type(std::forward<Arg>(arg));
- }
-
- template <
- typename Arg,
- typename ValueFirst, typename ValueSecond,
- typename Type>
- void construct_impl(
- Arg&& arg,
- std::pair<ValueFirst, ValueSecond> const*,
- Type const*)
- {
- new(node_->address()) value_type(std::forward<Arg>(arg), ValueSecond());
- }
-#endif
-
 #else
 
 #define BOOST_UNORDERED_CONSTRUCT_IMPL(z, n, _) \
@@ -316,15 +267,16 @@
                     new(node_->address()) value_type(arg0);
                 }
 
- template <typename First, typename Second, typename Key>
- void construct_impl(std::pair<First, Second>*, Key const& k)
- {
- new(node_->address()) value_type(First(k), Second());
- }
-
 #undef BOOST_UNORDERED_CONSTRUCT_IMPL
 
 #endif
+ template <typename K, typename M>
+ void construct_pair(K const& k, M*)
+ {
+ construct_preamble();
+ new(node_->address()) value_type(k, M());
+ value_constructed_ = true;
+ }
 
                 node_ptr get() const
                 {
@@ -1922,7 +1874,7 @@
                     // Create the node before rehashing in case it throws an
                     // exception (need strong safety in such a case).
                     node_constructor a(data_.allocators_);
- a.construct(k);
+ a.construct_pair(k, (mapped_type*) 0);
 
                     // reserve has basic exception safety if the hash function
                     // throws, strong otherwise.

Modified: branches/release/boost/unordered/unordered_map.hpp
==============================================================================
--- branches/release/boost/unordered/unordered_map.hpp (original)
+++ branches/release/boost/unordered/unordered_map.hpp 2009-07-26 16:22:48 EDT (Sun, 26 Jul 2009)
@@ -105,8 +105,17 @@
         unordered_map(InputIterator f, InputIterator l,
                 size_type n,
                 const hasher &hf = hasher(),
- const key_equal &eql = key_equal(),
- const allocator_type &a = allocator_type())
+ const key_equal &eql = key_equal())
+ : base(f, l, n, hf, eql, allocator_type())
+ {
+ }
+
+ template <class InputIterator>
+ unordered_map(InputIterator f, InputIterator l,
+ size_type n,
+ const hasher &hf,
+ const key_equal &eql,
+ const allocator_type &a)
             : base(f, l, n, hf, eql, a)
         {
         }
@@ -560,8 +569,17 @@
         unordered_multimap(InputIterator f, InputIterator l,
                 size_type n,
                 const hasher &hf = hasher(),
- const key_equal &eql = key_equal(),
- const allocator_type &a = allocator_type())
+ const key_equal &eql = key_equal())
+ : base(f, l, n, hf, eql, allocator_type())
+ {
+ }
+
+ template <class InputIterator>
+ unordered_multimap(InputIterator f, InputIterator l,
+ size_type n,
+ const hasher &hf,
+ const key_equal &eql,
+ const allocator_type &a)
           : base(f, l, n, hf, eql, a)
         {
         }

Modified: branches/release/boost/unordered/unordered_set.hpp
==============================================================================
--- branches/release/boost/unordered/unordered_set.hpp (original)
+++ branches/release/boost/unordered/unordered_set.hpp 2009-07-26 16:22:48 EDT (Sun, 26 Jul 2009)
@@ -103,8 +103,16 @@
         template <class InputIterator>
         unordered_set(InputIterator f, InputIterator l, size_type n,
                 const hasher &hf = hasher(),
- const key_equal &eql = key_equal(),
- const allocator_type &a = allocator_type())
+ const key_equal &eql = key_equal())
+ : base(f, l, n, hf, eql, allocator_type())
+ {
+ }
+
+ template <class InputIterator>
+ unordered_set(InputIterator f, InputIterator l, size_type n,
+ const hasher &hf,
+ const key_equal &eql,
+ const allocator_type &a)
             : base(f, l, n, hf, eql, a)
         {
         }
@@ -530,8 +538,16 @@
         template <class InputIterator>
         unordered_multiset(InputIterator f, InputIterator l, size_type n,
                 const hasher &hf = hasher(),
- const key_equal &eql = key_equal(),
- const allocator_type &a = allocator_type())
+ const key_equal &eql = key_equal())
+ : base(f, l, n, hf, eql, allocator_type())
+ {
+ }
+
+ template <class InputIterator>
+ unordered_multiset(InputIterator f, InputIterator l, size_type n,
+ const hasher &hf,
+ const key_equal &eql,
+ const allocator_type &a)
           : base(f, l, n, hf, eql, a)
         {
         }

Modified: branches/release/libs/unordered/doc/changes.qbk
==============================================================================
--- branches/release/libs/unordered/doc/changes.qbk (original)
+++ branches/release/libs/unordered/doc/changes.qbk 2009-07-26 16:22:48 EDT (Sun, 26 Jul 2009)
@@ -79,8 +79,13 @@
   the length right if it changes again in the future.
 * [@https://svn.boost.org/trac/boost/ticket/1978 Ticket 1978]:
   Implement `emplace` for all compilers.
+* [@https://svn.boost.org/trac/boost/ticket/2908 Ticket 2908],
+ [@https://svn.boost.org/trac/boost/ticket/3096 Ticket 3096]:
+ Some workarounds for old versions of borland, including adding explicit
+ destructors to all containers.
+* [@https://svn.boost.org/trac/boost/ticket/3082 Ticket 3082]:
+ Disable incorrect Visual C++ warnings.
 * Better configuration for C++0x features when the headers aren't available.
-* [@https://svn.boost.org/trac/boost/ticket/2908 Ticket 2908]:
- Add explicit destructors to all containers.
+* Create less buckets by default.
 
 [endsect]

Modified: branches/release/libs/unordered/doc/ref.xml
==============================================================================
--- branches/release/libs/unordered/doc/ref.xml (original)
+++ branches/release/libs/unordered/doc/ref.xml 2009-07-26 16:22:48 EDT (Sun, 26 Jul 2009)
@@ -284,7 +284,9 @@
               <notes>
                 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para>
                 <para>Pointers and references to elements are never invalidated.</para>
- <para>Only available on compilers with support for variadic template arguments and rvalue references.</para>
+ <para>If the compiler doesn't support variadic template arguments or rvalue
+ references, this is emulated for up to 10 arguments, with no support
+ for rvalue references or move semantics.</para>
               </notes>
             </method>
             <method name="emplace_hint">
@@ -313,7 +315,9 @@
                 <para>The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same value. </para>
                 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para>
                 <para>Pointers and references to elements are never invalidated.</para>
- <para>Only available on compilers with support for variadic template arguments and rvalue references.</para>
+ <para>If the compiler doesn't support variadic template arguments or rvalue
+ references, this is emulated for up to 10 arguments, with no support
+ for rvalue references or move semantics.</para>
               </notes>
             </method>
             <method name="insert">
@@ -1017,7 +1021,9 @@
               <notes>
                 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para>
                 <para>Pointers and references to elements are never invalidated.</para>
- <para>Only available on compilers with support for variadic template arguments and rvalue references.</para>
+ <para>If the compiler doesn't support variadic template arguments or rvalue
+ references, this is emulated for up to 10 arguments, with no support
+ for rvalue references or move semantics.</para>
               </notes>
             </method>
             <method name="emplace_hint">
@@ -1046,7 +1052,9 @@
                 <para>The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same value. </para>
                 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para>
                 <para>Pointers and references to elements are never invalidated.</para>
- <para>Only available on compilers with support for variadic template arguments and rvalue references.</para>
+ <para>If the compiler doesn't support variadic template arguments or rvalue
+ references, this is emulated for up to 10 arguments, with no support
+ for rvalue references or move semantics.</para>
               </notes>
             </method>
             <method name="insert">
@@ -1762,7 +1770,9 @@
               <notes>
                 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para>
                 <para>Pointers and references to elements are never invalidated.</para>
- <para>Only available on compilers with support for variadic template arguments and rvalue references.</para>
+ <para>If the compiler doesn't support variadic template arguments or rvalue
+ references, this is emulated for up to 10 arguments, with no support
+ for rvalue references or move semantics.</para>
               </notes>
             </method>
             <method name="emplace_hint">
@@ -1791,7 +1801,9 @@
                 <para>The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. </para>
                 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para>
                 <para>Pointers and references to elements are never invalidated.</para>
- <para>Only available on compilers with support for variadic template arguments and rvalue references.</para>
+ <para>If the compiler doesn't support variadic template arguments or rvalue
+ references, this is emulated for up to 10 arguments, with no support
+ for rvalue references or move semantics.</para>
               </notes>
             </method>
             <method name="insert">
@@ -2544,7 +2556,9 @@
               <notes>
                 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para>
                 <para>Pointers and references to elements are never invalidated.</para>
- <para>Only available on compilers with support for variadic template arguments and rvalue references.</para>
+ <para>If the compiler doesn't support variadic template arguments or rvalue
+ references, this is emulated for up to 10 arguments, with no support
+ for rvalue references or move semantics.</para>
               </notes>
             </method>
             <method name="emplace_hint">
@@ -2573,7 +2587,9 @@
                 <para>The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. </para>
                 <para>Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.</para>
                 <para>Pointers and references to elements are never invalidated.</para>
- <para>Only available on compilers with support for variadic template arguments and rvalue references.</para>
+ <para>If the compiler doesn't support variadic template arguments or rvalue
+ references, this is emulated for up to 10 arguments, with no support
+ for rvalue references or move semantics.</para>
               </notes>
             </method>
             <method name="insert">

Modified: branches/release/libs/unordered/test/exception/insert_exception_tests.cpp
==============================================================================
--- branches/release/libs/unordered/test/exception/insert_exception_tests.cpp (original)
+++ branches/release/libs/unordered/test/exception/insert_exception_tests.cpp 2009-07-26 16:22:48 EDT (Sun, 26 Jul 2009)
@@ -195,7 +195,7 @@
         rehash_bucket_count = static_cast<size_type>(
             ceil(original_bucket_count * (double) x.max_load_factor())) - 1;
 
- size_type initial_elements = rehash_bucket_count - 5;
+ size_type initial_elements = rehash_bucket_count > 5 ? rehash_bucket_count - 5 : 1;
 
         BOOST_TEST(initial_elements < this->values.size());
         x.insert(this->values.begin(),

Modified: branches/release/libs/unordered/test/helpers/input_iterator.hpp
==============================================================================
--- branches/release/libs/unordered/test/helpers/input_iterator.hpp (original)
+++ branches/release/libs/unordered/test/helpers/input_iterator.hpp 2009-07-26 16:22:48 EDT (Sun, 26 Jul 2009)
@@ -6,19 +6,34 @@
 #if !defined(BOOST_UNORDERED_TEST_HELPERS_INPUT_ITERATOR_HEADER)
 #define BOOST_UNORDERED_TEST_HELPERS_INPUT_ITERATOR_HEADER
 
+#include <boost/config.hpp>
 #include <boost/iterator_adaptors.hpp>
 
 namespace test
 {
     template <class Iterator>
+ struct proxy
+ {
+ typedef BOOST_DEDUCED_TYPENAME Iterator::value_type value_type;
+
+ proxy(value_type const& v) : v_(v) {}
+ proxy(proxy const& x) : v_(x.v_) {}
+ operator value_type const&() const { return v_; }
+
+ value_type v_;
+ };
+
+ template <class Iterator>
     struct input_iterator_adaptor
         : boost::iterator_adaptor<
             input_iterator_adaptor<Iterator>, Iterator,
- boost::use_default, std::input_iterator_tag>
+ boost::use_default, std::input_iterator_tag,
+ proxy<Iterator> >
     {
         typedef boost::iterator_adaptor<
             input_iterator_adaptor<Iterator>, Iterator,
- boost::use_default, std::input_iterator_tag> base;
+ boost::use_default, std::input_iterator_tag,
+ proxy<Iterator> > base;
 
         explicit input_iterator_adaptor(Iterator it = Iterator())
             : base(it) {}


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