From ef4d33ce89f3cde9b6872e34a1066139c22bcc73 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 17 Nov 2012 10:30:19 +0000 Subject: [PATCH] Unordered: Remove the deprecated equality implementation. [SVN r81385] --- doc/changes.qbk | 3 +- doc/ref.php | 8 +- doc/ref.xml | 32 +--- include/boost/unordered/detail/equivalent.hpp | 22 --- .../boost/unordered/detail/extract_key.hpp | 10 - include/boost/unordered/detail/table.hpp | 12 ++ include/boost/unordered/detail/unique.hpp | 5 - test/unordered/Jamfile.v2 | 1 - test/unordered/equality_deprecated.cpp | 174 ------------------ 9 files changed, 24 insertions(+), 243 deletions(-) delete mode 100644 test/unordered/equality_deprecated.cpp diff --git a/doc/changes.qbk b/doc/changes.qbk index fef7b59b..ae3b5e3a 100644 --- a/doc/changes.qbk +++ b/doc/changes.qbk @@ -222,6 +222,7 @@ C++11 support has resulted in some breaking changes: [h2 Boost 1.53.0] -* Remove support for the old pre-standard variadic pair constructors. +* Remove support for the old pre-standard variadic pair constructors, and + equality implementation. Both have been deprecated since Boost 1.48. [endsect] diff --git a/doc/ref.php b/doc/ref.php index b931cd08..0a474807 100644 --- a/doc/ref.php +++ b/doc/ref.php @@ -1106,9 +1106,7 @@ EOL; The behavior of this function was changed to match - the C++11 standard in Boost 1.48. If you wish to use - the old behaviour, define the macro - BOOST_UNORDERED_DEPRECATED_EQUALITY. + the C++11 standard in Boost 1.48. Behavior is undefined if the two containers don't have equivalent equality predicates. @@ -1149,9 +1147,7 @@ EOL; The behavior of this function was changed to match - the C++11 standard in Boost 1.48. If you wish to use - the old behaviour, define the macro - BOOST_UNORDERED_DEPRECATED_EQUALITY. + the C++11 standard in Boost 1.48. Behavior is undefined if the two containers don't have equivalent equality predicates. diff --git a/doc/ref.xml b/doc/ref.xml index 6d55c8eb..f16e6028 100644 --- a/doc/ref.xml +++ b/doc/ref.xml @@ -962,9 +962,7 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) The behavior of this function was changed to match - the C++11 standard in Boost 1.48. If you wish to use - the old behaviour, define the macro - BOOST_UNORDERED_DEPRECATED_EQUALITY. + the C++11 standard in Boost 1.48. Behavior is undefined if the two containers don't have equivalent equality predicates. @@ -997,9 +995,7 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) The behavior of this function was changed to match - the C++11 standard in Boost 1.48. If you wish to use - the old behaviour, define the macro - BOOST_UNORDERED_DEPRECATED_EQUALITY. + the C++11 standard in Boost 1.48. Behavior is undefined if the two containers don't have equivalent equality predicates. @@ -1998,9 +1994,7 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) The behavior of this function was changed to match - the C++11 standard in Boost 1.48. If you wish to use - the old behaviour, define the macro - BOOST_UNORDERED_DEPRECATED_EQUALITY. + the C++11 standard in Boost 1.48. Behavior is undefined if the two containers don't have equivalent equality predicates. @@ -2033,9 +2027,7 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) The behavior of this function was changed to match - the C++11 standard in Boost 1.48. If you wish to use - the old behaviour, define the macro - BOOST_UNORDERED_DEPRECATED_EQUALITY. + the C++11 standard in Boost 1.48. Behavior is undefined if the two containers don't have equivalent equality predicates. @@ -3084,9 +3076,7 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) The behavior of this function was changed to match - the C++11 standard in Boost 1.48. If you wish to use - the old behaviour, define the macro - BOOST_UNORDERED_DEPRECATED_EQUALITY. + the C++11 standard in Boost 1.48. Behavior is undefined if the two containers don't have equivalent equality predicates. @@ -3121,9 +3111,7 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) The behavior of this function was changed to match - the C++11 standard in Boost 1.48. If you wish to use - the old behaviour, define the macro - BOOST_UNORDERED_DEPRECATED_EQUALITY. + the C++11 standard in Boost 1.48. Behavior is undefined if the two containers don't have equivalent equality predicates. @@ -4136,9 +4124,7 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) The behavior of this function was changed to match - the C++11 standard in Boost 1.48. If you wish to use - the old behaviour, define the macro - BOOST_UNORDERED_DEPRECATED_EQUALITY. + the C++11 standard in Boost 1.48. Behavior is undefined if the two containers don't have equivalent equality predicates. @@ -4173,9 +4159,7 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) The behavior of this function was changed to match - the C++11 standard in Boost 1.48. If you wish to use - the old behaviour, define the macro - BOOST_UNORDERED_DEPRECATED_EQUALITY. + the C++11 standard in Boost 1.48. Behavior is undefined if the two containers don't have equivalent equality predicates. diff --git a/include/boost/unordered/detail/equivalent.hpp b/include/boost/unordered/detail/equivalent.hpp index bd3d7588..15347d99 100644 --- a/include/boost/unordered/detail/equivalent.hpp +++ b/include/boost/unordered/detail/equivalent.hpp @@ -302,8 +302,6 @@ namespace boost { namespace unordered { namespace detail { return true; } -#if !defined(BOOST_UNORDERED_DEPRECATED_EQUALITY) - static bool group_equals(iterator n1, iterator end1, iterator n2, iterator end2) { @@ -364,26 +362,6 @@ namespace boost { namespace unordered { namespace detail { return count; } -#else - - static bool group_equals(iterator n1, iterator end1, - iterator n2, iterator end2) - { - for(;;) - { - if(!extractor::compare_mapped(*n1, *n2)) - return false; - - ++n1; - ++n2; - - if (n1 == end1) return n2 == end2; - if (n2 == end2) return false; - } - } - -#endif - // Emplace/Insert static inline void add_after_node( diff --git a/include/boost/unordered/detail/extract_key.hpp b/include/boost/unordered/detail/extract_key.hpp index 8a89ce1d..969cd6ae 100644 --- a/include/boost/unordered/detail/extract_key.hpp +++ b/include/boost/unordered/detail/extract_key.hpp @@ -75,11 +75,6 @@ namespace detail { return no_key(); } #endif - - static bool compare_mapped(value_type const&, value_type const&) - { - return true; - } }; template @@ -182,11 +177,6 @@ BOOST_UNORDERED_KEY_FROM_TUPLE(boost::) #if !defined(BOOST_NO_CXX11_HDR_TUPLE) BOOST_UNORDERED_KEY_FROM_TUPLE(std::) #endif - - static bool compare_mapped(value_type const& x, value_type const& y) - { - return x.second == y.second; - } }; }}} diff --git a/include/boost/unordered/detail/table.hpp b/include/boost/unordered/detail/table.hpp index 48319581..a0b14c0c 100644 --- a/include/boost/unordered/detail/table.hpp +++ b/include/boost/unordered/detail/table.hpp @@ -18,6 +18,18 @@ #pragma warning(disable:4127) // conditional expression is constant #endif +#if defined(BOOST_UNORDERED_DEPRECATED_EQUALITY) + +#if defined(__EDG__) +#elif defined(_MSC_VER) || defined(__BORLANDC__) || defined(__DMC__) +#pragma message("Warning: BOOST_UNORDERED_DEPRECATED_EQUALITY is no longer supported.") +#elif defined(__GNUC__) || defined(__HP_aCC) || \ + defined(__SUNPRO_CC) || defined(__IBMCPP__) +#warning "BOOST_UNORDERED_DEPRECATED_EQUALITY is no longer supported." +#endif + +#endif + namespace boost { namespace unordered { namespace detail { //////////////////////////////////////////////////////////////////////////// diff --git a/include/boost/unordered/detail/unique.hpp b/include/boost/unordered/detail/unique.hpp index 9712eff3..f5b26924 100644 --- a/include/boost/unordered/detail/unique.hpp +++ b/include/boost/unordered/detail/unique.hpp @@ -290,13 +290,8 @@ namespace boost { namespace unordered { namespace detail { { iterator n2 = other.find_matching_node(n1); -#if !defined(BOOST_UNORDERED_DEPRECATED_EQUALITY) if (!n2.node_ || *n1 != *n2) return false; -#else - if (!n2.node_ || !extractor::compare_mapped(*n1, *n2)) - return false; -#endif } return true; diff --git a/test/unordered/Jamfile.v2 b/test/unordered/Jamfile.v2 index 16044fe1..581e4ee0 100644 --- a/test/unordered/Jamfile.v2 +++ b/test/unordered/Jamfile.v2 @@ -44,7 +44,6 @@ test-suite unordered [ run load_factor_tests.cpp ] [ run rehash_tests.cpp ] [ run equality_tests.cpp ] - [ run equality_deprecated.cpp ] [ run swap_tests.cpp ] [ run compile_set.cpp : : diff --git a/test/unordered/equality_deprecated.cpp b/test/unordered/equality_deprecated.cpp deleted file mode 100644 index af56bdea..00000000 --- a/test/unordered/equality_deprecated.cpp +++ /dev/null @@ -1,174 +0,0 @@ - -// Copyright 2008-2009 Daniel James. -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#define BOOST_UNORDERED_DEPRECATED_EQUALITY - -#include "../helpers/prefix.hpp" -#include -#include -#include "../helpers/postfix.hpp" - -#include -#include -#include "../helpers/test.hpp" - -namespace equality_tests -{ - struct mod_compare - { - bool alt_hash_; - - explicit mod_compare(bool alt_hash = false) : alt_hash_(alt_hash) {} - - bool operator()(int x, int y) const - { - return x % 1000 == y % 1000; - } - - int operator()(int x) const - { - return alt_hash_ ? x % 250 : (x + 5) % 250; - } - }; - -#define UNORDERED_EQUALITY_SET_TEST(seq1, op, seq2) \ - { \ - boost::unordered_set set1, set2; \ - BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set1, seq1) \ - BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set2, seq2) \ - BOOST_TEST(set1 op set2); \ - } - -#define UNORDERED_EQUALITY_MULTISET_TEST(seq1, op, seq2) \ - { \ - boost::unordered_multiset \ - set1, set2; \ - BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set1, seq1) \ - BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set2, seq2) \ - BOOST_TEST(set1 op set2); \ - } - -#define UNORDERED_EQUALITY_MAP_TEST(seq1, op, seq2) \ - { \ - boost::unordered_map \ - map1, map2; \ - BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map1, seq1) \ - BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map2, seq2) \ - BOOST_TEST(map1 op map2); \ - } - -#define UNORDERED_EQUALITY_MULTIMAP_TEST(seq1, op, seq2) \ - { \ - boost::unordered_multimap \ - map1, map2; \ - BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map1, seq1) \ - BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map2, seq2) \ - BOOST_TEST(map1 op map2); \ - } - -#define UNORDERED_SET_INSERT(r, set, item) set.insert(item); -#define UNORDERED_MAP_INSERT(r, map, item) \ - map.insert(std::pair BOOST_PP_SEQ_TO_TUPLE(item)); - - UNORDERED_AUTO_TEST(equality_size_tests) - { - boost::unordered_set x1, x2; - BOOST_TEST(x1 == x2); - BOOST_TEST(!(x1 != x2)); - - x1.insert(1); - BOOST_TEST(x1 != x2); - BOOST_TEST(!(x1 == x2)); - BOOST_TEST(x2 != x1); - BOOST_TEST(!(x2 == x1)); - - x2.insert(1); - BOOST_TEST(x1 == x2); - BOOST_TEST(!(x1 != x2)); - - x2.insert(2); - BOOST_TEST(x1 != x2); - BOOST_TEST(!(x1 == x2)); - BOOST_TEST(x2 != x1); - BOOST_TEST(!(x2 == x1)); - } - - UNORDERED_AUTO_TEST(equality_key_value_tests) - { - UNORDERED_EQUALITY_MULTISET_TEST((1), !=, (2)) - UNORDERED_EQUALITY_SET_TEST((2), ==, (2)) - UNORDERED_EQUALITY_MAP_TEST(((1)(1))((2)(1)), !=, ((1)(1))((3)(1))) - } - - UNORDERED_AUTO_TEST(equality_collision_test) - { - UNORDERED_EQUALITY_MULTISET_TEST( - (1), !=, (501)) - UNORDERED_EQUALITY_MULTISET_TEST( - (1)(251), !=, (1)(501)) - UNORDERED_EQUALITY_MULTIMAP_TEST( - ((251)(1))((1)(1)), !=, ((501)(1))((1)(1))) - UNORDERED_EQUALITY_MULTISET_TEST( - (1)(501), ==, (1)(501)) - UNORDERED_EQUALITY_SET_TEST( - (1)(501), ==, (501)(1)) - } - - UNORDERED_AUTO_TEST(equality_group_size_test) - { - UNORDERED_EQUALITY_MULTISET_TEST( - (10)(20)(20), !=, (10)(10)(20)) - UNORDERED_EQUALITY_MULTIMAP_TEST( - ((10)(1))((20)(1))((20)(1)), !=, - ((10)(1))((20)(1))((10)(1))) - UNORDERED_EQUALITY_MULTIMAP_TEST( - ((20)(1))((10)(1))((10)(1)), ==, - ((10)(1))((20)(1))((10)(1))) - } - - UNORDERED_AUTO_TEST(equality_map_value_test) - { - UNORDERED_EQUALITY_MAP_TEST( - ((1)(1)), !=, ((1)(2))) - UNORDERED_EQUALITY_MAP_TEST( - ((1)(1)), ==, ((1)(1))) - UNORDERED_EQUALITY_MULTIMAP_TEST( - ((1)(1)), !=, ((1)(2))) - UNORDERED_EQUALITY_MULTIMAP_TEST( - ((1)(1))((1)(1)), !=, ((1)(1))((1)(2))) - UNORDERED_EQUALITY_MULTIMAP_TEST( - ((1)(2))((1)(1)), !=, ((1)(1))((1)(2))) - } - - UNORDERED_AUTO_TEST(equality_predicate_test) - { - UNORDERED_EQUALITY_SET_TEST( - (1), ==, (1001)) - UNORDERED_EQUALITY_MAP_TEST( - ((1)(2))((1001)(1)), ==, ((1001)(2))((1)(1))) - } - - // Test that equality still works when the two containers have - // different hash functions but the same equality predicate. - - UNORDERED_AUTO_TEST(equality_different_hash_test) - { - typedef boost::unordered_set set; - set set1(0, mod_compare(false), mod_compare(false)); - set set2(0, mod_compare(true), mod_compare(true)); - BOOST_TEST(set1 == set2); - set1.insert(1); set2.insert(2); - BOOST_TEST(set1 != set2); - set1.insert(2); set2.insert(1); - BOOST_TEST(set1 == set2); - set1.insert(10); set2.insert(20); - BOOST_TEST(set1 != set2); - set1.insert(20); set2.insert(10); - BOOST_TEST(set1 == set2); - } - -} - -RUN_TESTS()