diff --git a/doc/container.qbk b/doc/container.qbk index 973acf2..24e7031 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -1081,6 +1081,7 @@ use [*Boost.Container]? There are several reasons for that: [section:release_notes_boost_1_58_00 Boost 1.58 Release] * Added `nth` and `index_of` functions to containers with random-access iterators (except `basic_string`). +* Fixed bug in `vector::operator==`. [endsect] diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp index 9789cbd..c6aee0a 100644 --- a/include/boost/container/vector.hpp +++ b/include/boost/container/vector.hpp @@ -1510,7 +1510,7 @@ class vector { \ T* const back_pos = container_detail::to_raw_pointer \ (this->m_holder.start()) + this->m_holder.m_size; \ - if (BOOST_LIKELY(this->m_holder.m_size < this->m_holder.capacity())){ \ + if (BOOST_LIKELY(this->m_holder.m_size < this->m_holder.capacity())){ \ allocator_traits_type::construct (this->m_holder.alloc() \ , back_pos BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ ++this->m_holder.m_size; \ @@ -1781,8 +1781,8 @@ class vector const_iterator first1(x.cbegin()), first2(y.cbegin()); const const_iterator last1(x.cend()); for (; first1 != last1; ++first1, ++first2) { - if (!(*first1 != *first2)) { - return false; + if (*first1 != *first2) { + return false; } } return true; @@ -1956,7 +1956,7 @@ class vector bool stable_emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { \ const bool room_enough = this->m_holder.m_size < this->m_holder.capacity(); \ - if (BOOST_LIKELY(room_enough)){ \ + if (BOOST_LIKELY(room_enough)){ \ T* const back_pos = container_detail::to_raw_pointer \ (this->m_holder.start()) + this->m_holder.m_size; \ allocator_traits_type::construct (this->m_holder.alloc() \ @@ -1976,7 +1976,7 @@ class vector size_type priv_index_of(pointer p) const { BOOST_ASSERT(this->m_holder.start() <= p); - BOOST_ASSERT(p <= (this->m_holder.start()+size())); + BOOST_ASSERT(p <= (this->m_holder.start()+this->size())); return static_cast(p - this->m_holder.start()); } diff --git a/test/list_test.hpp b/test/list_test.hpp index 9aae06d..d506dec 100644 --- a/test/list_test.hpp +++ b/test/list_test.hpp @@ -285,6 +285,20 @@ int list_test (bool copied_allocators_equal = true) if(!CheckEqualContainers(boostlist, stdlist)) return 1; + //some comparison operators + if(!(boostlist == boostlist)) + return 1; + if(boostlist != boostlist) + return 1; + if(boostlist < boostlist) + return 1; + if(boostlist > boostlist) + return 1; + if(!(boostlist <= boostlist)) + return 1; + if(!(boostlist >= boostlist)) + return 1; + if(push_data_t::execute(max, boostlist, stdlist)){ return 1; } diff --git a/test/map_test.hpp b/test/map_test.hpp index 83f1cfb..f1894c6 100644 --- a/test/map_test.hpp +++ b/test/map_test.hpp @@ -206,6 +206,20 @@ int map_test() if(!CheckEqualContainers(boostmap2, stdmap2)) return 1; if(!CheckEqualContainers(boostmultimap2, stdmultimap2)) return 1; + //some comparison operators + if(!(boostmap2 == boostmap2)) + return 1; + if(boostmap2 != boostmap2) + return 1; + if(boostmap2 < boostmap2) + return 1; + if(boostmap2 > boostmap2) + return 1; + if(!(boostmap2 <= boostmap2)) + return 1; + if(!(boostmap2 >= boostmap2)) + return 1; + ::boost::movelib::unique_ptr const pboostmap3 = ::boost::movelib::make_unique ( boost::make_move_iterator(&aux_vect[0]) , boost::make_move_iterator(&aux_vect[0] + 50)); diff --git a/test/set_test.hpp b/test/set_test.hpp index 90db093..74fd8b8 100644 --- a/test/set_test.hpp +++ b/test/set_test.hpp @@ -188,7 +188,19 @@ int set_test () aux_vect3[i] = boost::move(move_me); } - + //some comparison operators + if(!(boostset2 == boostset2)) + return 1; + if(boostset2 != boostset2) + return 1; + if(boostset2 < boostset2) + return 1; + if(boostset2 > boostset2) + return 1; + if(!(boostset2 <= boostset2)) + return 1; + if(!(boostset2 >= boostset2)) + return 1; ::boost::movelib::unique_ptr const pboostset3 = ::boost::movelib::make_unique ( ordered_unique_range diff --git a/test/vector_test.hpp b/test/vector_test.hpp index 60f9783..2e7fb82 100644 --- a/test/vector_test.hpp +++ b/test/vector_test.hpp @@ -277,6 +277,20 @@ int vector_test() } if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; + //some comparison operators + if(!(boostvector == boostvector)) + return 1; + if(boostvector != boostvector) + return 1; + if(boostvector < boostvector) + return 1; + if(boostvector > boostvector) + return 1; + if(!(boostvector <= boostvector)) + return 1; + if(!(boostvector >= boostvector)) + return 1; + //Test insertion from list { std::list l(50, int(1));