Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57006 - in trunk: boost/unordered libs/unordered/test/unordered
From: daniel_james_at_[hidden]
Date: 2009-10-19 15:32:11


Author: danieljames
Date: 2009-10-19 15:32:09 EDT (Mon, 19 Oct 2009)
New Revision: 57006
URL: http://svn.boost.org/trac/boost/changeset/57006

Log:
Fix allocator for construct from initializer list.
Text files modified:
   trunk/boost/unordered/unordered_map.hpp | 4 +-
   trunk/boost/unordered/unordered_set.hpp | 4 +-
   trunk/libs/unordered/test/unordered/constructor_tests.cpp | 53 ++++++++++++++++++++++++++++++++++++++++
   3 files changed, 57 insertions(+), 4 deletions(-)

Modified: trunk/boost/unordered/unordered_map.hpp
==============================================================================
--- trunk/boost/unordered/unordered_map.hpp (original)
+++ trunk/boost/unordered/unordered_map.hpp 2009-10-19 15:32:09 EDT (Mon, 19 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());
         }
@@ -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());
         }

Modified: trunk/boost/unordered/unordered_set.hpp
==============================================================================
--- trunk/boost/unordered/unordered_set.hpp (original)
+++ trunk/boost/unordered/unordered_set.hpp 2009-10-19 15:32:09 EDT (Mon, 19 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());
         }
@@ -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());
         }

Modified: trunk/libs/unordered/test/unordered/constructor_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/constructor_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/constructor_tests.cpp 2009-10-19 15:32:09 EDT (Mon, 19 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