From 241316e0d96ab25f70f80dcfdfaa3ea9b14ac5ab Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 6 Jun 2009 14:05:54 +0000 Subject: [PATCH] Misc. unordered changes. Fixes #3082, #3119. Merged revisions 53505-53506,53525,53550,53552,53614 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r53505 | danieljames | 2009-05-31 16:50:56 +0100 (Sun, 31 May 2009) | 1 line Disable incorrect Visual C++ 64-bit warnings. Ref #3082. ........ r53506 | danieljames | 2009-05-31 16:53:09 +0100 (Sun, 31 May 2009) | 1 line Remove misplaced visual C++ warning pragma. ........ r53525 | danieljames | 2009-06-01 07:50:37 +0100 (Mon, 01 Jun 2009) | 1 line Fix tests for when the library has support for initializer lists but the compiler doesn't. ........ r53550 | danieljames | 2009-06-01 20:17:49 +0100 (Mon, 01 Jun 2009) | 1 line Get the type of the initializer_list right. ........ r53552 | danieljames | 2009-06-01 20:22:27 +0100 (Mon, 01 Jun 2009) | 1 line Fix the unordered_map declaration in the tutorial. Fixes #3119. ........ r53614 | danieljames | 2009-06-03 23:48:49 +0100 (Wed, 03 Jun 2009) | 1 line The move tests pass on 64 bit visual c++. ........ [SVN r53687] --- doc/hash_equality.qbk | 2 +- include/boost/unordered/detail/hash_table.hpp | 12 ++++++++++++ test/unordered/assign_tests.cpp | 15 +++++++++++++++ test/unordered/constructor_tests.cpp | 11 +++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/doc/hash_equality.qbk b/doc/hash_equality.qbk index 8fc08fb3..db1b0616 100644 --- a/doc/hash_equality.qbk +++ b/doc/hash_equality.qbk @@ -13,7 +13,7 @@ is declared as: class Key, class Mapped, class Hash = ``[classref boost::hash]``, class Pred = std::equal_to, - class Alloc = std::allocator > + class Alloc = std::allocator > > class ``[classref boost::unordered_map unordered_map]``; The hash function comes first as you might want to change the hash function diff --git a/include/boost/unordered/detail/hash_table.hpp b/include/boost/unordered/detail/hash_table.hpp index 8a458f7f..1609e955 100644 --- a/include/boost/unordered/detail/hash_table.hpp +++ b/include/boost/unordered/detail/hash_table.hpp @@ -61,6 +61,14 @@ #endif +#if defined(BOOST_MSVC) +#pragma warning(push) +#if BOOST_MSVC >= 1400 +#pragma warning(disable:4267) // conversion from 'size_t' to 'unsigned int', + // possible loss of data. +#endif +#endif + #if BOOST_WORKAROUND(__BORLANDC__, <= 0x0582) #define BOOST_UNORDERED_BORLAND_BOOL(x) (bool)(x) #else @@ -332,4 +340,8 @@ namespace boost { #undef BOOST_UNORDERED_BORLAND_BOOL #undef BOOST_UNORDERED_MSVC_RESET_PTR +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + #endif // BOOST_UNORDERED_DETAIL_HASH_TABLE_HPP_INCLUDED diff --git a/test/unordered/assign_tests.cpp b/test/unordered/assign_tests.cpp index efe1c157..56df1b20 100644 --- a/test/unordered/assign_tests.cpp +++ b/test/unordered/assign_tests.cpp @@ -105,6 +105,21 @@ UNORDERED_TEST(assign_tests2, #if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) +UNORDERED_AUTO_TEST(assign_default_initializer_list) { + std::cerr<<"Initializer List Tests\n"; + std::initializer_list > init; + boost::unordered_map x1; + x1[25] = 3; + x1[16] = 10; + BOOST_TEST(!x1.empty()); + x1 = init; + BOOST_TEST(x1.empty()); +} + +#endif + +#if !defined(BOOST_NO_INITIALIZER_LISTS) + UNORDERED_AUTO_TEST(assign_initializer_list) { std::cerr<<"Initializer List Tests\n"; diff --git a/test/unordered/constructor_tests.cpp b/test/unordered/constructor_tests.cpp index 1a73289f..d5475b1f 100644 --- a/test/unordered/constructor_tests.cpp +++ b/test/unordered/constructor_tests.cpp @@ -290,6 +290,17 @@ UNORDERED_TEST(map_constructor_test, #if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) +UNORDERED_AUTO_TEST(test_default_initializer_list) { + std::cerr<<"Initializer List Tests\n"; + std::initializer_list init; + boost::unordered_set x1 = init; + BOOST_TEST(x1.empty()); +} + +#endif + +#if !defined(BOOST_NO_INITIALIZER_LISTS) + UNORDERED_AUTO_TEST(test_initializer_list) { std::cerr<<"Initializer List Tests\n"; boost::unordered_set x1 = { 2, 10, 45, -5 };