From f47bf08ccc9b64da1e6afa6da8ab4e2147ecede8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Tue, 3 Feb 2015 16:09:47 +0100 Subject: [PATCH] Try to definitely fix Trac Issue #9931 (flat_map::insert(ordered_unique_range_t...) fails with move_iterators") --- doc/container.qbk | 3 ++- include/boost/container/detail/flat_tree.hpp | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/container.qbk b/doc/container.qbk index 965d7da..8780547 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -1089,13 +1089,14 @@ use [*Boost.Container]? There are several reasons for that: * Updated containers to implement new constructors as specified in [@http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2210 2210. Missing allocator-extended constructor for allocator-aware containers]. * Fixed bugs: + * [@https://svn.boost.org/trac/boost/ticket/9931 #9931: ['"flat_map::insert(ordered_unique_range_t...) fails with move_iterators"]] (reopened). * [@https://svn.boost.org/trac/boost/ticket/10790 Trac #10790 (['long long errors from container"])]. * [@https://svn.boost.org/trac/boost/ticket/10808 Trac #10808 (['compare equal operator of vector is broken"])]. * [*Source Breaking]: [classref boost::container::scoped_allocator_adaptor scoped_allocator_adaptor]'s `propagate_on_container_copy_assignment`, `propagate_on_container_move_assignment` and `propagate_on_container_swap` are no longer `::boost::integral_constant` types. The dependency reorganization needed to break with those classes to avoid MPL dependencies, and interoperability with `std::integral_constant` was not guaranteed. - Code assumming `boost::true_type/boost::false_type` on this will not compile. As a workaround, use the guarantee internal + Code assumming `boost::true_type/boost::false_type` on this will not compile. As a workaround, use the guaranteed internal `::value` constant: `::boost::integral_constant::propagate_on_container_move_assignment::value>`. [endsect] diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp index 714d087..a94043c 100644 --- a/include/boost/container/detail/flat_tree.hpp +++ b/include/boost/container/detail/flat_tree.hpp @@ -995,7 +995,11 @@ class flat_tree while(len--){ BidirIt next(first); ++next; - if(next == last || val_cmp(*first, *next)){ + //Use iterator_traits::value_type + //because it can be different from container::value_type + //(e.g. conversion between std::pair -> boost::container::pair + const typename boost::container::iterator_traits::value_type & val = *first; + if (next == last || val_cmp(val, *next)){ const bool room = this->m_data.m_vect.stable_emplace_back(*first); (void)room; BOOST_ASSERT(room);