diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 92125fc9..8fab6e65 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -199,7 +199,7 @@ namespace boost 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 @@ namespace boost 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()); } diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index 1d661deb..16418c11 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -192,7 +192,7 @@ namespace boost 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 @@ namespace boost 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()); } diff --git a/test/unordered/constructor_tests.cpp b/test/unordered/constructor_tests.cpp index e1b96087..5a719e2a 100644 --- a/test/unordered/constructor_tests.cpp +++ b/test/unordered/constructor_tests.cpp @@ -263,6 +263,59 @@ void constructor_tests2(T*, test::random_generator const& generator = test::defa test::check_container(x, v); test::check_equivalent_keys(x); } + +#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) + std::initializer_list 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