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..200cd1e7 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -1730,10 +1731,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 +1743,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 +1796,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 +1806,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 +1822,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 +1833,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 +1887,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_) {