diff --git a/doc/changes.qbk b/doc/changes.qbk index 8f4bee01..f71da60d 100644 --- a/doc/changes.qbk +++ b/doc/changes.qbk @@ -252,4 +252,12 @@ C++11 support has resulted in some breaking changes: uses slower ([ticket 9282]). * Only construct elements using allocators, as specified in C++11 standard. +[h2 Boost 1.57.0] + +* Fix the `pointer` typedef in iterators ([ticket 10672]). +* Fix Coverity warning + ([@https://github.com/boostorg/unordered/pull/2 GitHub #2]). +* Rename private `iterator` typedef in some iterator classes, as it + confuses some traits classes. + [endsect] diff --git a/include/boost/unordered/detail/buckets.hpp b/include/boost/unordered/detail/buckets.hpp index fd038b7b..7de4317b 100644 --- a/include/boost/unordered/detail/buckets.hpp +++ b/include/boost/unordered/detail/buckets.hpp @@ -60,7 +60,7 @@ namespace boost { namespace unordered { namespace iterator_detail { std::forward_iterator_tag, typename Node::value_type, std::ptrdiff_t, - typename Node::node_pointer, + typename Node::value_type*, typename Node::value_type&> { #if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) @@ -120,7 +120,7 @@ namespace boost { namespace unordered { namespace iterator_detail { std::forward_iterator_tag, typename Node::value_type, std::ptrdiff_t, - ConstNodePointer, + typename Node::value_type const*, typename Node::value_type const&> { friend struct boost::unordered::iterator_detail::l_iterator @@ -188,7 +188,7 @@ namespace boost { namespace unordered { namespace iterator_detail { std::forward_iterator_tag, typename Node::value_type, std::ptrdiff_t, - typename Node::node_pointer, + typename Node::value_type*, typename Node::value_type&> { #if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) @@ -252,7 +252,7 @@ namespace boost { namespace unordered { namespace iterator_detail { std::forward_iterator_tag, typename Node::value_type, std::ptrdiff_t, - ConstNodePointer, + typename Node::value_type const*, typename Node::value_type const&> { friend struct boost::unordered::iterator_detail::iterator; diff --git a/include/boost/unordered/detail/table.hpp b/include/boost/unordered/detail/table.hpp index 7b4cc0ec..2bb5d450 100644 --- a/include/boost/unordered/detail/table.hpp +++ b/include/boost/unordered/detail/table.hpp @@ -59,6 +59,10 @@ namespace boost { namespace unordered { namespace detail { sizeof(value_type), boost::alignment_of::value>::type data_; + value_base() : + data_() + {} + void* address() { return this; } diff --git a/test/unordered/compile_tests.hpp b/test/unordered/compile_tests.hpp index 02ef78aa..b48a6efd 100644 --- a/test/unordered/compile_tests.hpp +++ b/test/unordered/compile_tests.hpp @@ -180,6 +180,28 @@ void unordered_set_test(X&, Key const&) typedef BOOST_DEDUCED_TYPENAME X::key_type key_type; BOOST_STATIC_ASSERT((boost::is_same::value)); + + // iterator pointer / const_pointer_type + + typedef BOOST_DEDUCED_TYPENAME X::iterator iterator; + typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator; + typedef BOOST_DEDUCED_TYPENAME X::local_iterator local_iterator; + typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_pointer::type iterator_pointer; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_pointer::type + const_iterator_pointer; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_pointer::type local_iterator_pointer; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_pointer::type + const_local_iterator_pointer; + + BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::value)); } template @@ -191,6 +213,30 @@ void unordered_map_test(X& r, Key const& k, T const& v) BOOST_STATIC_ASSERT(( boost::is_same >::value)); + // iterator pointer / const_pointer_type + + typedef BOOST_DEDUCED_TYPENAME X::iterator iterator; + typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator; + typedef BOOST_DEDUCED_TYPENAME X::local_iterator local_iterator; + typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_pointer::type iterator_pointer; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_pointer::type + const_iterator_pointer; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_pointer::type local_iterator_pointer; + typedef BOOST_DEDUCED_TYPENAME + boost::iterator_pointer::type + const_local_iterator_pointer; + + BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::value)); + + // Calling functions + r.insert(std::pair(k, v)); Key k_lvalue(k); diff --git a/test/unordered/insert_tests.cpp b/test/unordered/insert_tests.cpp index e80a8c1c..872bfc12 100644 --- a/test/unordered/insert_tests.cpp +++ b/test/unordered/insert_tests.cpp @@ -9,6 +9,7 @@ #include "../helpers/postfix.hpp" #include "../helpers/test.hpp" +#include #include #include "../objects/test.hpp" #include "../helpers/random_values.hpp" @@ -598,7 +599,11 @@ UNORDERED_AUTO_TEST(insert_initializer_list_set) boost::unordered_set set2; +#if BOOST_COMP_GNUC && BOOST_COMP_GNUC < BOOST_VERSION_NUMBER(4,5,0) + set2.insert({{1, 2}}); +#else set2.insert({1, 2}); +#endif BOOST_TEST(set2.size() == 1); BOOST_TEST(set2.find({1,2}) != set2.end()); BOOST_TEST(set2.find({2,1}) == set2.end());