diff --git a/CMakeLists.txt b/CMakeLists.txt index 510cb811..f1477e65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,6 @@ target_link_libraries(boost_unordered Boost::config Boost::container_hash Boost::core - Boost::iterator Boost::move Boost::mp11 Boost::predef diff --git a/include/boost/unordered/detail/fca.hpp b/include/boost/unordered/detail/fca.hpp index 3d7b6e2b..a255f29b 100644 --- a/include/boost/unordered/detail/fca.hpp +++ b/include/boost/unordered/detail/fca.hpp @@ -124,25 +124,6 @@ to normal separate chaining implementations. #include #include #include - -// `iterator_facade` has transitive dependencies on Boost.MPL; one of the -// headers is generating a `-Wsign-conversion` warning which has an open PR to -// address the issue but merging does not seem likely so for now create a rote -// workaround. -// -// TODO: eventually remove this once MPL is fixed or we decide to migrate off of -// the Boost.Iterator dependency. -// -#if defined(BOOST_GCC) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-conversion" -#pragma GCC diagnostic ignored "-Wconversion" -#include -#pragma GCC diagnostic pop -#else -#include -#endif - #include #include #include @@ -153,6 +134,7 @@ to normal separate chaining implementations. #include #include +#include namespace boost { namespace unordered { @@ -472,10 +454,7 @@ namespace boost { return ~(~(std::size_t(0)) >> (sizeof(std::size_t) * 8 - n)); } - template - struct grouped_bucket_iterator - : public boost::iterator_facade, - Bucket, boost::forward_traversal_tag> + template struct grouped_bucket_iterator { public: typedef typename Bucket::bucket_pointer bucket_pointer; @@ -483,8 +462,12 @@ namespace boost { typename boost::pointer_traits::template rebind_to< bucket_group >::type bucket_group_pointer; + typedef Bucket value_type; typedef typename boost::pointer_traits::difference_type difference_type; + typedef Bucket& reference; + typedef Bucket* pointer; + typedef std::forward_iterator_tag iterator_category; private: bucket_pointer p; @@ -493,9 +476,38 @@ namespace boost { public: grouped_bucket_iterator() : p(), pbg() {} - private: - friend class boost::iterator_core_access; + reference operator*() const BOOST_NOEXCEPT { return dereference(); } + pointer operator->() const BOOST_NOEXCEPT + { + return boost::to_address(p); + } + grouped_bucket_iterator& operator++() BOOST_NOEXCEPT + { + increment(); + return *this; + } + + grouped_bucket_iterator operator++(int) BOOST_NOEXCEPT + { + grouped_bucket_iterator old = *this; + increment(); + return old; + } + + bool operator==( + grouped_bucket_iterator const& other) const BOOST_NOEXCEPT + { + return equal(other); + } + + bool operator!=( + grouped_bucket_iterator const& other) const BOOST_NOEXCEPT + { + return !equal(other); + } + + private: template friend class grouped_bucket_array; @@ -533,12 +545,8 @@ namespace boost { template struct const_grouped_local_bucket_iterator; - template - struct grouped_local_bucket_iterator - : public boost::iterator_facade, - typename Node::value_type, boost::forward_traversal_tag> + template struct grouped_local_bucket_iterator { - typedef typename Node::node_pointer node_pointer; public: @@ -551,9 +559,39 @@ namespace boost { grouped_local_bucket_iterator() : p() {} - private: - friend class boost::iterator_core_access; + reference operator*() const BOOST_NOEXCEPT { return dereference(); } + pointer operator->() const BOOST_NOEXCEPT + { + return boost::to_address(p); + } + + grouped_local_bucket_iterator& operator++() BOOST_NOEXCEPT + { + increment(); + return *this; + } + + grouped_local_bucket_iterator operator++(int) BOOST_NOEXCEPT + { + grouped_local_bucket_iterator old = *this; + increment(); + return old; + } + + bool operator==( + grouped_local_bucket_iterator const& other) const BOOST_NOEXCEPT + { + return equal(other); + } + + bool operator!=( + grouped_local_bucket_iterator const& other) const BOOST_NOEXCEPT + { + return !equal(other); + } + + private: template friend class grouped_bucket_array; @@ -573,11 +611,7 @@ namespace boost { node_pointer p; }; - template - struct const_grouped_local_bucket_iterator - : public boost::iterator_facade< - const_grouped_local_bucket_iterator, - typename Node::value_type const, boost::forward_traversal_tag> + template struct const_grouped_local_bucket_iterator { typedef typename Node::node_pointer node_pointer; @@ -596,9 +630,39 @@ namespace boost { { } - private: - friend class boost::iterator_core_access; + reference operator*() const BOOST_NOEXCEPT { return dereference(); } + pointer operator->() const BOOST_NOEXCEPT + { + return boost::to_address(p); + } + + const_grouped_local_bucket_iterator& operator++() BOOST_NOEXCEPT + { + increment(); + return *this; + } + + const_grouped_local_bucket_iterator operator++(int) BOOST_NOEXCEPT + { + const_grouped_local_bucket_iterator old = *this; + increment(); + return old; + } + + bool operator==( + const_grouped_local_bucket_iterator const& other) const BOOST_NOEXCEPT + { + return equal(other); + } + + bool operator!=( + const_grouped_local_bucket_iterator const& other) const BOOST_NOEXCEPT + { + return !equal(other); + } + + private: template friend class grouped_bucket_array; diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index 1f8c0cea..cec99c79 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -1697,10 +1697,9 @@ namespace boost { }; template - struct rv_ref - : boost::detail::if_true::value>:: - BOOST_NESTED_TEMPLATE then, - please_ignore_this_overload>::type + struct rv_ref : boost::conditional::value, + boost::unordered::detail::rv_ref_impl, + please_ignore_this_overload>::type { }; @@ -1730,10 +1729,7 @@ namespace boost { namespace iterator_detail { template class c_iterator; - template - class iterator - : public boost::iterator_facade, - typename Node::value_type, boost::forward_traversal_tag> + template class iterator { public: typedef typename Node::value_type value_type; @@ -1745,6 +1741,50 @@ namespace boost { iterator() : p(), itb(){}; + reference operator*() const BOOST_NOEXCEPT { return dereference(); } + pointer operator->() const BOOST_NOEXCEPT + { + pointer x = boost::addressof(p->value()); + return x; + } + + iterator& operator++() BOOST_NOEXCEPT + { + increment(); + return *this; + } + + iterator operator++(int) BOOST_NOEXCEPT + { + iterator old = *this; + increment(); + return old; + } + + bool operator==(iterator const& other) const BOOST_NOEXCEPT + { + return equal(other); + } + + bool operator!=(iterator const& other) const BOOST_NOEXCEPT + { + return !equal(other); + } + + bool operator==( + boost::unordered::detail::iterator_detail::c_iterator const& other) const BOOST_NOEXCEPT + { + return equal(other); + } + + bool operator!=( + boost::unordered::detail::iterator_detail::c_iterator const& other) const BOOST_NOEXCEPT + { + return !equal(other); + } + private: typedef typename Node::node_pointer node_pointer; typedef grouped_bucket_iterator bucket_iterator; @@ -1754,7 +1794,6 @@ namespace boost { template friend struct boost::unordered::detail::table; template friend class c_iterator; - friend class boost::iterator_core_access; iterator(node_pointer p_, bucket_iterator itb_) : p(p_), itb(itb_) {} @@ -1765,6 +1804,13 @@ namespace boost { return (p == x.p); } + bool equal( + const boost::unordered::detail::iterator_detail::c_iterator& x) const BOOST_NOEXCEPT + { + return (p == x.p); + } + void increment() BOOST_NOEXCEPT { p = p->next; @@ -1774,10 +1820,7 @@ namespace boost { } }; - template - class c_iterator - : public boost::iterator_facade, - typename Node::value_type const, boost::forward_traversal_tag> + template class c_iterator { public: typedef typename Node::value_type value_type; @@ -1788,7 +1831,51 @@ namespace boost { typedef std::forward_iterator_tag iterator_category; c_iterator() : p(), itb(){}; - c_iterator(iterator it) : p(it.p), itb(it.itb){}; + c_iterator(iterator it) : p(it.p), itb(it.itb) {} + + reference operator*() const BOOST_NOEXCEPT { return dereference(); } + pointer operator->() const BOOST_NOEXCEPT + { + pointer x = boost::addressof(p->value()); + return x; + } + + c_iterator& operator++() BOOST_NOEXCEPT + { + increment(); + return *this; + } + + c_iterator operator++(int) BOOST_NOEXCEPT + { + c_iterator old = *this; + increment(); + return old; + } + + bool operator==(c_iterator const& other) const BOOST_NOEXCEPT + { + return equal(other); + } + + bool operator!=(c_iterator const& other) const BOOST_NOEXCEPT + { + return !equal(other); + } + + bool operator==( + boost::unordered::detail::iterator_detail::iterator const& other) const BOOST_NOEXCEPT + { + return equal(other); + } + + bool operator!=( + boost::unordered::detail::iterator_detail::iterator const& other) const BOOST_NOEXCEPT + { + return !equal(other); + } private: typedef typename Node::node_pointer node_pointer; @@ -1798,7 +1885,7 @@ namespace boost { bucket_iterator itb; template friend struct boost::unordered::detail::table; - friend class boost::iterator_core_access; + template friend class iterator; c_iterator(node_pointer p_, bucket_iterator itb_) : p(p_), itb(itb_) { @@ -2362,13 +2449,8 @@ namespace boost { k, this->hash_function(), this->key_eq()); } -#if defined(BOOST_MSVC) -#pragma warning(push) -#pragma warning( \ - disable : 4714) // function 'function' marked as __forceinline not inlined -#endif template - BOOST_FORCEINLINE iterator transparent_find( + inline iterator transparent_find( Key const& k, Hash const& h, Pred const& pred) const { std::size_t const key_hash = h(k); @@ -2382,10 +2464,6 @@ namespace boost { return this->end(); } -#if defined(BOOST_MSVC) -#pragma warning(pop) -#endif - template node_pointer* find_prev(Key const& key, bucket_iterator itb) { @@ -3418,8 +3496,8 @@ namespace boost { sizeof(choice2::type) }; - typedef typename boost::detail::if_true::BOOST_NESTED_TEMPLATE - then::type type; + typedef + typename boost::conditional::type type; }; template struct set_extractor diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 89703768..51758339 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,6 +6,12 @@ include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST) if(HAVE_BOOST_TEST) -boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::unordered Boost::core) +boost_test_jamfile( + FILE Jamfile.v2 + LINK_LIBRARIES + Boost::unordered + Boost::core + Boost::concept_check +) endif() diff --git a/test/helpers/random_values.hpp b/test/helpers/random_values.hpp index d139d180..508f7475 100644 --- a/test/helpers/random_values.hpp +++ b/test/helpers/random_values.hpp @@ -9,8 +9,8 @@ #include "./generators.hpp" #include "./list.hpp" #include "./metafunctions.hpp" +#include #include -#include namespace test { template struct unordered_generator_set @@ -69,9 +69,8 @@ namespace test { template struct unordered_generator_base - : public boost::detail::if_true::value>:: - BOOST_NESTED_TEMPLATE then, - test::unordered_generator_map > + : public boost::conditional::value, + test::unordered_generator_set, test::unordered_generator_map > { };