Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57027 - in branches/release: . boost boost/algorithm/string boost/archive boost/config boost/filesystem boost/fusion boost/graph boost/interprocess boost/intrusive boost/iostreams boost/math boost/numeric/ublas boost/program_options boost/property_tree boost/python boost/regex boost/serialization boost/signals boost/signals2 boost/spirit boost/spirit/home boost/spirit/home/karma boost/spirit/home/qi/nonterminal boost/spirit/home/qi/numeric/detail boost/spirit/home/support boost/spirit/repository/home/qi/nonterminal boost/system boost/thread boost/tr1 boost/type_traits boost/unordered boost/unordered/detail boost/utility boost/wave libs libs/config libs/filesystem libs/fusion libs/graph_parallel libs/interprocess libs/intrusive libs/iostreams libs/math libs/mpl/doc/refmanual libs/mpl/doc/src/refmanual libs/numeric/ublas libs/program_options libs/property_tree libs/python libs/regex libs/serialization libs/signals libs/signals2 libs/spirit libs/spirit/classic/example libs/spirit/doc/html/spirit/abstracts/customize libs/spirit/doc/html/spirit/abstracts/indepth libs/spirit/example libs/spirit/phoenix libs/spirit/test libs/spirit/test/qi libs/system libs/thread libs/timer libs/tr1 libs/type_traits libs/unordered/test/unordered libs/utility libs/wave status tools/boostbook tools/build/v2 tools/quickbook tools/regression tools/release tools/wave
From: daniel_james_at_[hidden]
Date: 2009-10-20 19:05:29


Author: danieljames
Date: 2009-10-20 19:05:28 EDT (Tue, 20 Oct 2009)
New Revision: 57027
URL: http://svn.boost.org/trac/boost/changeset/57027

Log:
A couple of bug fixes for unordered containers.

Merged revisions 57005-57006 via svnmerge from
https://svn.boost.org/svn/boost/trunk

........
  r57005 | danieljames | 2009-10-19 20:24:33 +0100 (Mon, 19 Oct 2009) | 6 lines
  
  Use normal emplace implementation for emplace_hint and insert with hint.
  
  There's a bug in the emplace_hint implementation for unordered
  containers with equivalent keys. Since my tests missed it, I'm just
  going to use the normal emplace implementation until I write better
  tests.
........
  r57006 | danieljames | 2009-10-19 20:32:09 +0100 (Mon, 19 Oct 2009) | 1 line
  
  Fix allocator for construct from initializer list.
........

Properties modified:
   branches/release/ (props changed)
   branches/release/boost/algorithm/string/ (props changed)
   branches/release/boost/archive/ (props changed)
   branches/release/boost/config/ (props changed)
   branches/release/boost/filesystem/ (props changed)
   branches/release/boost/fusion/ (props changed)
   branches/release/boost/graph/ (props changed)
   branches/release/boost/interprocess/ (props changed)
   branches/release/boost/intrusive/ (props changed)
   branches/release/boost/iostreams/ (props changed)
   branches/release/boost/math/ (props changed)
   branches/release/boost/numeric/ublas/ (props changed)
   branches/release/boost/program_options/ (props changed)
   branches/release/boost/property_tree/ (props changed)
   branches/release/boost/python/ (props changed)
   branches/release/boost/regex/ (props changed)
   branches/release/boost/serialization/ (props changed)
   branches/release/boost/signals/ (props changed)
   branches/release/boost/signals2/ (props changed)
   branches/release/boost/spirit/ (props changed)
   branches/release/boost/spirit/home/ (props changed)
   branches/release/boost/spirit/home/karma/ (props changed)
   branches/release/boost/spirit/home/qi/nonterminal/rule.hpp (props changed)
   branches/release/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp (props changed)
   branches/release/boost/spirit/home/support/attributes.hpp (props changed)
   branches/release/boost/spirit/repository/home/qi/nonterminal/subrule.hpp (props changed)
   branches/release/boost/system/ (props changed)
   branches/release/boost/thread/ (props changed)
   branches/release/boost/thread.hpp (props changed)
   branches/release/boost/tr1/ (props changed)
   branches/release/boost/type_traits/ (props changed)
   branches/release/boost/utility/value_init.hpp (props changed)
   branches/release/boost/wave/ (props changed)
   branches/release/index.html (props changed)
   branches/release/libs/config/ (props changed)
   branches/release/libs/filesystem/ (props changed)
   branches/release/libs/fusion/ (props changed)
   branches/release/libs/graph_parallel/ (props changed)
   branches/release/libs/interprocess/ (props changed)
   branches/release/libs/intrusive/ (props changed)
   branches/release/libs/iostreams/ (props changed)
   branches/release/libs/libraries.htm (props changed)
   branches/release/libs/maintainers.txt (props changed)
   branches/release/libs/math/ (props changed)
   branches/release/libs/mpl/doc/refmanual/broken-compiler-workarounds.html (props changed)
   branches/release/libs/mpl/doc/refmanual/categorized-index-concepts.html (props changed)
   branches/release/libs/mpl/doc/refmanual/cfg-no-preprocessed-headers.html (props changed)
   branches/release/libs/mpl/doc/refmanual/composition-and-argument-binding.html (props changed)
   branches/release/libs/mpl/doc/refmanual/data-types-concepts.html (props changed)
   branches/release/libs/mpl/doc/refmanual/data-types-miscellaneous.html (props changed)
   branches/release/libs/mpl/doc/refmanual/extensible-associative-sequence.html (props changed)
   branches/release/libs/mpl/doc/refmanual/inserter-class.html (props changed)
   branches/release/libs/mpl/doc/refmanual/tag-dispatched-metafunction.html (props changed)
   branches/release/libs/mpl/doc/refmanual/trivial-metafunctions-summary.html (props changed)
   branches/release/libs/mpl/doc/src/refmanual/Iterators-Iterator.rst (props changed)
   branches/release/libs/numeric/ublas/ (props changed)
   branches/release/libs/program_options/ (props changed)
   branches/release/libs/property_tree/ (props changed)
   branches/release/libs/python/ (props changed)
   branches/release/libs/regex/ (props changed)
   branches/release/libs/serialization/ (props changed)
   branches/release/libs/signals/ (props changed)
   branches/release/libs/signals2/ (props changed)
   branches/release/libs/spirit/ (props changed)
   branches/release/libs/spirit/classic/example/ (props changed)
   branches/release/libs/spirit/doc/html/spirit/abstracts/customize/ (props changed)
   branches/release/libs/spirit/doc/html/spirit/abstracts/indepth/ (props changed)
   branches/release/libs/spirit/example/ (props changed)
   branches/release/libs/spirit/phoenix/ (props changed)
   branches/release/libs/spirit/test/ (props changed)
   branches/release/libs/spirit/test/qi/optional.cpp (props changed)
   branches/release/libs/system/ (props changed)
   branches/release/libs/thread/ (props changed)
   branches/release/libs/timer/ (props changed)
   branches/release/libs/tr1/ (props changed)
   branches/release/libs/type_traits/ (props changed)
   branches/release/libs/utility/swap.html (props changed)
   branches/release/libs/utility/value_init.htm (props changed)
   branches/release/libs/utility/value_init_test.cpp (props changed)
   branches/release/libs/wave/ (props changed)
   branches/release/status/ (props changed)
   branches/release/tools/boostbook/ (props changed)
   branches/release/tools/build/v2/ (props changed)
   branches/release/tools/quickbook/ (props changed)
   branches/release/tools/regression/ (props changed)
   branches/release/tools/release/ (props changed)
   branches/release/tools/wave/ (props changed)
Text files modified:
   branches/release/boost/unordered/detail/equivalent.hpp | 61 ----------------------------------------
   branches/release/boost/unordered/detail/fwd.hpp | 10 -----
   branches/release/boost/unordered/unordered_map.hpp | 25 +++++++--------
   branches/release/boost/unordered/unordered_set.hpp | 23 +++++++-------
   branches/release/libs/unordered/test/unordered/constructor_tests.cpp | 53 ++++++++++++++++++++++++++++++++++
   5 files changed, 77 insertions(+), 95 deletions(-)

Modified: branches/release/boost/unordered/detail/equivalent.hpp
==============================================================================
--- branches/release/boost/unordered/detail/equivalent.hpp (original)
+++ branches/release/boost/unordered/detail/equivalent.hpp 2009-10-20 19:05:28 EDT (Tue, 20 Oct 2009)
@@ -97,36 +97,6 @@
     }
     
     template <class H, class P, class A, class K>
- inline BOOST_DEDUCED_TYPENAME
- hash_equivalent_table<H, P, A, K>::iterator_base
- hash_equivalent_table<H, P, A, K>
- ::emplace_hint_impl(iterator_base const& it, node_constructor& a)
- {
- // equal can throw, but with no effects
- if (!it.node_ || !equal(get_key(a.value()), *it)) {
- // Use the standard emplace if the iterator doesn't point
- // to a matching key.
- return emplace_impl(a);
- }
- else {
- // Find the first node in the group - so that the node
- // will be added at the end of the group.
-
- node_ptr start = node::first_in_group(it.node_);
-
- // reserve has basic exception safety if the hash function
- // throws, strong otherwise.
- bucket_ptr bucket = this->reserve_for_insert(this->size_ + 1) ?
- get_bucket(this->bucket_index(get_key(a.value()))) :
- it.bucket_;
-
- // Nothing after this point can throw
-
- return iterator_base(bucket, add_node(a, bucket, start));
- }
- }
-
- template <class H, class P, class A, class K>
     inline void hash_equivalent_table<H, P, A, K>
             ::emplace_impl_no_rehash(node_constructor& a)
     {
@@ -156,25 +126,6 @@
         return emplace_impl(a);
     }
 
- // Emplace (equivalent key containers)
- // (I'm using an overloaded emplace for both 'insert' and 'emplace')
-
- // if hash function throws, basic exception safety
- // strong otherwise
- template <class H, class P, class A, class K>
- template <class... Args>
- BOOST_DEDUCED_TYPENAME hash_equivalent_table<H, P, A, K>::iterator_base
- hash_equivalent_table<H, P, A, K>
- ::emplace_hint(iterator_base const& it, Args&&... args)
- {
- // Create the node before rehashing in case it throws an
- // exception (need strong safety in such a case).
- node_constructor a(*this);
- a.construct(std::forward<Args>(args)...);
-
- return emplace_hint_impl(it, a);
- }
-
 #else
 
 #define BOOST_UNORDERED_INSERT_IMPL(z, num_params, _) \
@@ -187,18 +138,6 @@
         node_constructor a(*this); \
         a.construct(BOOST_UNORDERED_CALL_PARAMS(z, num_params)); \
         return emplace_impl(a); \
- } \
- \
- template <class H, class P, class A, class K> \
- template <BOOST_UNORDERED_TEMPLATE_ARGS(z, num_params)> \
- BOOST_DEDUCED_TYPENAME hash_equivalent_table<H, P, A, K>::iterator_base \
- hash_equivalent_table<H, P, A, K> \
- ::emplace_hint(iterator_base const& it, \
- BOOST_UNORDERED_FUNCTION_PARAMS(z, num_params)) \
- { \
- node_constructor a(*this); \
- a.construct(BOOST_UNORDERED_CALL_PARAMS(z, num_params)); \
- return emplace_hint_impl(it, a); \
     }
 
     BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT,

Modified: branches/release/boost/unordered/detail/fwd.hpp
==============================================================================
--- branches/release/boost/unordered/detail/fwd.hpp (original)
+++ branches/release/boost/unordered/detail/fwd.hpp 2009-10-20 19:05:28 EDT (Tue, 20 Oct 2009)
@@ -710,8 +710,6 @@
         // Insert methods
 
         iterator_base emplace_impl(node_constructor& a);
- iterator_base emplace_hint_impl(iterator_base const& it,
- node_constructor& a);
         void emplace_impl_no_rehash(node_constructor& a);
 
         // equals
@@ -725,18 +723,12 @@
 
         template <class... Args>
         iterator_base emplace(Args&&... args);
- template <class... Args>
- iterator_base emplace_hint(iterator_base const& it, Args&&... args);
 
 #else
 
 #define BOOST_UNORDERED_INSERT_IMPL(z, n, _) \
         template <BOOST_UNORDERED_TEMPLATE_ARGS(z, n)> \
- iterator_base emplace(BOOST_UNORDERED_FUNCTION_PARAMS(z, n)); \
- \
- template <BOOST_UNORDERED_TEMPLATE_ARGS(z, n)> \
- iterator_base emplace_hint(iterator_base const& it, \
- BOOST_UNORDERED_FUNCTION_PARAMS(z, n));
+ iterator_base emplace(BOOST_UNORDERED_FUNCTION_PARAMS(z, n));
 
         BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT,
             BOOST_UNORDERED_INSERT_IMPL, _)

Modified: branches/release/boost/unordered/unordered_map.hpp
==============================================================================
--- branches/release/boost/unordered/unordered_map.hpp (original)
+++ branches/release/boost/unordered/unordered_map.hpp 2009-10-20 19:05:28 EDT (Tue, 20 Oct 2009)
@@ -199,7 +199,7 @@
                 const allocator_type &a = allocator_type())
           : table_(boost::unordered_detail::initial_size(
                     list.begin(), list.end(), n),
- hf, eql, allocator_type())
+ hf, eql, a)
         {
             table_.insert_range(list.begin(), list.end());
         }
@@ -311,7 +311,7 @@
             template < \
                 BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
- iterator emplace_hint(const_iterator hint, \
+ iterator emplace_hint(const_iterator, \
                 BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
             ) \
             { \
@@ -332,7 +332,7 @@
                     table_.emplace(obj));
         }
 
- iterator insert(const_iterator hint, const value_type& obj)
+ iterator insert(const_iterator, const value_type& obj)
         {
             return iterator(table_.emplace(obj).first);
         }
@@ -699,7 +699,7 @@
                 const allocator_type &a = allocator_type())
           : table_(boost::unordered_detail::initial_size(
                     list.begin(), list.end(), n),
- hf, eql, allocator_type())
+ hf, eql, a)
         {
             table_.insert_range(list.begin(), list.end());
         }
@@ -776,10 +776,9 @@
         }
 
         template <class... Args>
- iterator emplace_hint(const_iterator hint, Args&&... args)
+ iterator emplace_hint(const_iterator, Args&&... args)
         {
- return iterator(table_.emplace_hint(get(hint),
- std::forward<Args>(args)...));
+ return iterator(table_.emplace(std::forward<Args>(args)...));
         }
 #else
 
@@ -788,10 +787,10 @@
             return iterator(table_.emplace(v));
         }
         
- iterator emplace_hint(const_iterator hint,
+ iterator emplace_hint(const_iterator,
             value_type const& v = value_type())
         {
- return iterator(table_.emplace_hint(get(hint), v));
+ return iterator(table_.emplace(v));
         }
 
 
@@ -812,11 +811,11 @@
             template < \
                 BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
- iterator emplace_hint(const_iterator hint, \
+ iterator emplace_hint(const_iterator, \
                 BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
             ) \
             { \
- return iterator(table_.emplace_hint(get(hint), \
+ return iterator(table_.emplace( \
                         BOOST_UNORDERED_CALL_PARAMS(z, n) \
                 )); \
             }
@@ -833,9 +832,9 @@
             return iterator(table_.emplace(obj));
         }
 
- iterator insert(const_iterator hint, const value_type& obj)
+ iterator insert(const_iterator, const value_type& obj)
         {
- return iterator(table_.emplace_hint(get(hint), obj));
+ return iterator(table_.emplace(obj));
         }
 
         template <class InputIt>

Modified: branches/release/boost/unordered/unordered_set.hpp
==============================================================================
--- branches/release/boost/unordered/unordered_set.hpp (original)
+++ branches/release/boost/unordered/unordered_set.hpp 2009-10-20 19:05:28 EDT (Tue, 20 Oct 2009)
@@ -192,7 +192,7 @@
                 const allocator_type &a = allocator_type())
           : table_(boost::unordered_detail::initial_size(
                     list.begin(), list.end(), n),
- hf, eql, allocator_type())
+ hf, eql, a)
         {
             table_.insert_range(list.begin(), list.end());
         }
@@ -326,7 +326,7 @@
                     table_.emplace(obj));
         }
 
- iterator insert(const_iterator hint, const value_type& obj)
+ iterator insert(const_iterator, const value_type& obj)
         {
             return iterator(table_.emplace(obj).first);
         }
@@ -658,7 +658,7 @@
                 const allocator_type &a = allocator_type())
           : table_(boost::unordered_detail::initial_size(
                     list.begin(), list.end(), n),
- hf, eql, allocator_type())
+ hf, eql, a)
         {
             table_.insert_range(list.begin(), list.end());
         }
@@ -735,10 +735,9 @@
         }
 
         template <class... Args>
- iterator emplace_hint(const_iterator hint, Args&&... args)
+ iterator emplace_hint(const_iterator, Args&&... args)
         {
- return iterator(table_.emplace_hint(get(hint),
- std::forward<Args>(args)...));
+ return iterator(table_.emplace(std::forward<Args>(args)...));
         }
 #else
 
@@ -747,10 +746,10 @@
             return iterator(table_.emplace(v));
         }
 
- iterator emplace_hint(const_iterator hint,
+ iterator emplace_hint(const_iterator,
             value_type const& v = value_type())
         {
- return iterator(table_.emplace_hint(get(hint), v));
+ return iterator(table_.emplace(v));
         }
 
 #define BOOST_UNORDERED_EMPLACE(z, n, _) \
@@ -768,11 +767,11 @@
             template < \
                 BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
> \
- iterator emplace_hint(const_iterator hint, \
+ iterator emplace_hint(const_iterator, \
                 BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
             ) \
             { \
- return iterator(table_.emplace_hint(get(hint), \
+ return iterator(table_.emplace( \
                         BOOST_UNORDERED_CALL_PARAMS(z, n) \
                 )); \
             }
@@ -789,9 +788,9 @@
             return iterator(table_.emplace(obj));
         }
 
- iterator insert(const_iterator hint, const value_type& obj)
+ iterator insert(const_iterator, const value_type& obj)
         {
- return iterator(table_.emplace_hint(get(hint), obj));
+ return iterator(table_.emplace(obj));
         }
 
         template <class InputIt>

Modified: branches/release/libs/unordered/test/unordered/constructor_tests.cpp
==============================================================================
--- branches/release/libs/unordered/test/unordered/constructor_tests.cpp (original)
+++ branches/release/libs/unordered/test/unordered/constructor_tests.cpp 2009-10-20 19:05:28 EDT (Tue, 20 Oct 2009)
@@ -263,6 +263,59 @@
         test::check_container(x, v);
         test::check_equivalent_keys(x);
     }
+
+#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
+ std::initializer_list<BOOST_DEDUCED_TYPENAME T::value_type> list;
+
+ std::cerr<<"Initializer list construct 1\n";
+ {
+ T x(list);
+ BOOST_TEST(x.empty());
+ BOOST_TEST(test::equivalent(x.hash_function(), hf));
+ BOOST_TEST(test::equivalent(x.key_eq(), eq));
+ BOOST_TEST(test::equivalent(x.get_allocator(), al));
+ }
+
+ std::cerr<<"Initializer list construct 2\n";
+ {
+ T x(list, 1000);
+ BOOST_TEST(x.empty());
+ BOOST_TEST(x.bucket_count() >= 1000);
+ BOOST_TEST(test::equivalent(x.hash_function(), hf));
+ BOOST_TEST(test::equivalent(x.key_eq(), eq));
+ BOOST_TEST(test::equivalent(x.get_allocator(), al));
+ }
+
+ std::cerr<<"Initializer list construct 3\n";
+ {
+ T x(list, 10, hf1);
+ BOOST_TEST(x.empty());
+ BOOST_TEST(x.bucket_count() >= 10);
+ BOOST_TEST(test::equivalent(x.hash_function(), hf1));
+ BOOST_TEST(test::equivalent(x.key_eq(), eq));
+ BOOST_TEST(test::equivalent(x.get_allocator(), al));
+ }
+
+ std::cerr<<"Initializer list construct 4\n";
+ {
+ T x(list, 10, hf1, eq1);
+ BOOST_TEST(x.empty());
+ BOOST_TEST(x.bucket_count() >= 10);
+ BOOST_TEST(test::equivalent(x.hash_function(), hf1));
+ BOOST_TEST(test::equivalent(x.key_eq(), eq1));
+ BOOST_TEST(test::equivalent(x.get_allocator(), al));
+ }
+
+ std::cerr<<"Initializer list construct 5\n";
+ {
+ T x(list, 10, hf1, eq1, al1);
+ BOOST_TEST(x.empty());
+ BOOST_TEST(x.bucket_count() >= 10);
+ BOOST_TEST(test::equivalent(x.hash_function(), hf1));
+ BOOST_TEST(test::equivalent(x.key_eq(), eq1));
+ BOOST_TEST(test::equivalent(x.get_allocator(), al1));
+ }
+#endif
 }
 
 template <class T>


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