diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2024-12-18 07:30:21 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.com> | 2024-12-18 08:30:53 +0300 |
commit | 6e2202781bb80bcb9deff0954798b0c1e5c278ef (patch) | |
tree | 989c103ea642049140ebb24bba3bd6d8491974d0 | |
parent | f77d5dbcf98390de8aa4bbaf6d8dd00b43f6b176 (diff) | |
download | ydb-6e2202781bb80bcb9deff0954798b0c1e5c278ef.tar.gz |
Update contrib/restricted/boost/container to 1.87.0
commit_hash:4cd32daab084699bd246b2d2a67a29bf1013a94c
21 files changed, 320 insertions, 151 deletions
diff --git a/contrib/restricted/boost/container/include/boost/container/allocator.hpp b/contrib/restricted/boost/container/include/boost/container/allocator.hpp index 68a158c0ee..3d82f71d63 100644 --- a/contrib/restricted/boost/container/include/boost/container/allocator.hpp +++ b/contrib/restricted/boost/container/include/boost/container/allocator.hpp @@ -336,8 +336,8 @@ class allocator BOOST_CONTAINER_STATIC_ASSERT(( Version > 1 )); dlmalloc_memchain ch; void *beg(&*chain.begin()), *last(&*chain.last()); - size_t size(chain.size()); - BOOST_CONTAINER_MEMCHAIN_INIT_FROM(&ch, beg, last, size); + size_t sz(chain.size()); + BOOST_CONTAINER_MEMCHAIN_INIT_FROM(&ch, beg, last, sz); dlmalloc_multidealloc(&ch); //dlmalloc_multidealloc(move_detail::force_ptr<dlmalloc_memchain *>(&chain)); } diff --git a/contrib/restricted/boost/container/include/boost/container/deque.hpp b/contrib/restricted/boost/container/include/boost/container/deque.hpp index da24ad0d75..c1cb4c42dc 100644 --- a/contrib/restricted/boost/container/include/boost/container/deque.hpp +++ b/contrib/restricted/boost/container/include/boost/container/deque.hpp @@ -1026,6 +1026,11 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type, #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: // Internal typedefs + + //`allocator_type::value_type` must match container's `value type`. If this + //assertion fails, please review your allocator definition. + BOOST_CONTAINER_STATIC_ASSERT((dtl::is_same<value_type, typename allocator_traits<ValAllocator>::value_type>::value)); + BOOST_COPYABLE_AND_MOVABLE(deque) typedef typename Base::ptr_alloc_ptr index_pointer; typedef allocator_traits<ValAllocator> allocator_traits_type; diff --git a/contrib/restricted/boost/container/include/boost/container/detail/config_begin.hpp b/contrib/restricted/boost/container/include/boost/container/detail/config_begin.hpp index e1075d1d5b..d459a066e1 100644 --- a/contrib/restricted/boost/container/include/boost/container/detail/config_begin.hpp +++ b/contrib/restricted/boost/container/include/boost/container/detail/config_begin.hpp @@ -41,6 +41,7 @@ #pragma warning (disable : 4671) // the copy constructor is inaccessible #pragma warning (disable : 4673) // throwing '' the following types will not be considered at the catch site #pragma warning (disable : 4675) // "method" should be declared "static" and have exactly one parameter + #pragma warning (disable : 4702) // unreachable code #pragma warning (disable : 4706) // assignment within conditional expression #pragma warning (disable : 4710) // function not inlined #pragma warning (disable : 4714) // "function": marked as __forceinline not inlined diff --git a/contrib/restricted/boost/container/include/boost/container/detail/container_or_allocator_rebind.hpp b/contrib/restricted/boost/container/include/boost/container/detail/container_or_allocator_rebind.hpp index 1525e41d9d..e6f27b2520 100644 --- a/contrib/restricted/boost/container/include/boost/container/detail/container_or_allocator_rebind.hpp +++ b/contrib/restricted/boost/container/include/boost/container/detail/container_or_allocator_rebind.hpp @@ -38,8 +38,7 @@ struct container_or_allocator_rebind_impl<AllocatorOrContainer, ToType, false> template<class ToType> struct container_or_allocator_rebind_impl<void, ToType, false> - : real_allocator<ToType, void> -{}; +{ typedef void type; }; template<class AllocatorOrContainer, class ToType> struct container_or_allocator_rebind diff --git a/contrib/restricted/boost/container/include/boost/container/detail/container_rebind.hpp b/contrib/restricted/boost/container/include/boost/container/detail/container_rebind.hpp index 854291ae7c..4c34209f9f 100644 --- a/contrib/restricted/boost/container/include/boost/container/detail/container_rebind.hpp +++ b/contrib/restricted/boost/container/include/boost/container/detail/container_rebind.hpp @@ -26,6 +26,16 @@ namespace boost { namespace container { namespace dtl { + template<class V, class A, class U> + struct void_or_portable_rebind_alloc + { + typedef typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type type; + }; + + template<class V, class U> + struct void_or_portable_rebind_alloc<V, void, U> + { typedef void type; }; + template <class Cont, class U> struct container_rebind; @@ -34,14 +44,14 @@ namespace dtl { template <template <class, class, class...> class Cont, typename V, typename A, class... An, class U> struct container_rebind<Cont<V, A, An...>, U> { - typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, An...> type; + typedef Cont<U, typename void_or_portable_rebind_alloc<V, A, U>::type, An...> type; }; //Needed for non-conforming compilers like GCC 4.3 template <template <class, class> class Cont, typename V, typename A, class U> struct container_rebind<Cont<V, A>, U> { - typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type> type; + typedef Cont<U, typename void_or_portable_rebind_alloc<V, A, U>::type> type; }; template <template <class> class Cont, typename V, class U> @@ -65,7 +75,7 @@ namespace dtl { , class U> struct container_rebind<Cont<V, A>, U> { - typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type> type; + typedef Cont<U, typename void_or_portable_rebind_alloc<V, A, U>::type> type; }; template <template <class, class, class> class Cont //1arg @@ -73,7 +83,7 @@ namespace dtl { , class U> struct container_rebind<Cont<V, A, P0>, U> { - typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0> type; + typedef Cont<U, typename void_or_portable_rebind_alloc<V, A, U>::type, P0> type; }; template <template <class, class, class, class> class Cont //2arg @@ -81,7 +91,7 @@ namespace dtl { , class U> struct container_rebind<Cont<V, A, P0, P1>, U> { - typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0, P1> type; + typedef Cont<U, typename void_or_portable_rebind_alloc<V, A, U>::type, P0, P1> type; }; template <template <class, class, class, class, class> class Cont //3arg @@ -89,7 +99,7 @@ namespace dtl { , class U> struct container_rebind<Cont<V, A, P0, P1, P2>, U> { - typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0, P1, P2> type; + typedef Cont<U, typename void_or_portable_rebind_alloc<V, A, U>::type, P0, P1, P2> type; }; template <template <class, class, class, class, class, class> class Cont //4arg @@ -97,7 +107,7 @@ namespace dtl { , class U> struct container_rebind<Cont<V, A, P0, P1, P2, P3>, U> { - typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0, P1, P2, P3> type; + typedef Cont<U, typename void_or_portable_rebind_alloc<V, A, U>::type, P0, P1, P2, P3> type; }; template <template <class, class, class, class, class, class, class> class Cont //5arg @@ -105,7 +115,7 @@ namespace dtl { , class U> struct container_rebind<Cont<V, A, P0, P1, P2, P3, P4>, U> { - typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0, P1, P2, P3, P4> type; + typedef Cont<U, typename void_or_portable_rebind_alloc<V, A, U>::type, P0, P1, P2, P3, P4> type; }; template <template <class, class, class, class, class, class, class, class> class Cont //6arg @@ -113,7 +123,7 @@ namespace dtl { , class U> struct container_rebind<Cont<V, A, P0, P1, P2, P3, P4, P5>, U> { - typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0, P1, P2, P3, P4, P5> type; + typedef Cont<U, typename void_or_portable_rebind_alloc<V, A, U>::type, P0, P1, P2, P3, P4, P5> type; }; template <template <class, class, class, class, class, class, class, class, class> class Cont //7arg @@ -121,7 +131,7 @@ namespace dtl { , class U> struct container_rebind<Cont<V, A, P0, P1, P2, P3, P4, P5, P6>, U> { - typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0, P1, P2, P3, P4, P5, P6> type; + typedef Cont<U, typename void_or_portable_rebind_alloc<V, A, U>::type, P0, P1, P2, P3, P4, P5, P6> type; }; template <template <class, class, class, class, class, class, class, class, class, class> class Cont //8arg @@ -129,7 +139,7 @@ namespace dtl { , class U> struct container_rebind<Cont<V, A, P0, P1, P2, P3, P4, P5, P6, P7>, U> { - typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0, P1, P2, P3, P4, P5, P6, P7> type; + typedef Cont<U, typename void_or_portable_rebind_alloc<V, A, U>::type, P0, P1, P2, P3, P4, P5, P6, P7> type; }; template <template <class, class, class, class, class, class, class, class, class, class, class> class Cont //9arg @@ -137,7 +147,7 @@ namespace dtl { , class U> struct container_rebind<Cont<V, A, P0, P1, P2, P3, P4, P5, P6, P7, P8>, U> { - typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0, P1, P2, P3, P4, P5, P6, P7, P8> type; + typedef Cont<U, typename void_or_portable_rebind_alloc<V, A, U>::type, P0, P1, P2, P3, P4, P5, P6, P7, P8> type; }; #endif //!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) @@ -147,7 +157,7 @@ namespace dtl { template <typename V, std::size_t N, typename A, typename O, class U> struct container_rebind<small_vector<V, N, A, O>, U> { - typedef small_vector<U, N, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, O> type; + typedef small_vector<U, N, typename void_or_portable_rebind_alloc<V, A, U>::type, O> type; }; template <typename V, std::size_t N, typename O, class U> diff --git a/contrib/restricted/boost/container/include/boost/container/detail/flat_tree.hpp b/contrib/restricted/boost/container/include/boost/container/detail/flat_tree.hpp index 98bd70280c..a753a45619 100644 --- a/contrib/restricted/boost/container/include/boost/container/detail/flat_tree.hpp +++ b/contrib/restricted/boost/container/include/boost/container/detail/flat_tree.hpp @@ -45,6 +45,7 @@ #include <boost/move/iterator.hpp> #include <boost/move/adl_move_swap.hpp> #include <boost/move/detail/iterator_to_raw_pointer.hpp> +#include <boost/move/detail/to_raw_pointer.hpp> #include <boost/move/detail/force_ptr.hpp> #include <boost/move/detail/launder.hpp> #include <boost/move/algo/adaptive_sort.hpp> @@ -120,6 +121,7 @@ namespace boost { namespace container { namespace dtl { + /////////////////////////////////////// // // Helper functions to merge elements @@ -137,14 +139,19 @@ template<class SequenceContainer, class Compare> inline void flat_tree_container_inplace_merge //is_contiguous_container == true (SequenceContainer& dest, typename SequenceContainer::iterator it, Compare comp , dtl::true_) { - typedef typename SequenceContainer::value_type value_type; + typedef typename SequenceContainer::value_type value_type; + typedef typename SequenceContainer::size_type size_type; + value_type *const braw = boost::movelib::to_raw_pointer(dest.data()); value_type *const iraw = boost::movelib::iterator_to_raw_pointer(it); //Don't use iterator_to_raw_pointer for end as debug iterators can assert when //"operator ->" is used with the end iterator value_type *const eraw = braw + dest.size(); + size_type dest_unused_storage_size = 0; + value_type *const dest_unused_storage_addr = + unused_storage<SequenceContainer>::get(dest, dest_unused_storage_size); boost::movelib::adaptive_merge - (braw, iraw, eraw, comp, eraw, back_free_capacity<SequenceContainer>::get(dest)); + (braw, iraw, eraw, comp, dest_unused_storage_addr, dest_unused_storage_size); } template<class SequenceContainer, class Compare> @@ -163,15 +170,19 @@ template<class SequenceContainer, class Compare> inline void flat_tree_container_inplace_sort_ending //is_contiguous_container == true (SequenceContainer& dest, typename SequenceContainer::iterator it, Compare comp, dtl::true_) { - typedef typename SequenceContainer::value_type value_type; + typedef typename SequenceContainer::value_type value_type; + typedef typename SequenceContainer::size_type size_type; + value_type *const iraw = boost::movelib::iterator_to_raw_pointer(it); //Don't use iterator_to_raw_pointer for end as debug iterators can assert when //"operator ->" is used with the end iterator value_type* const eraw = boost::movelib::to_raw_pointer(dest.data()) + dest.size(); - + size_type dest_unused_storage_size; + value_type* const dest_unused_storage_addr = + unused_storage<SequenceContainer>::get(dest, dest_unused_storage_size); boost::movelib::adaptive_sort - (iraw, eraw, comp, eraw, back_free_capacity<SequenceContainer>::get(dest)); + (iraw, eraw, comp, dest_unused_storage_addr, dest_unused_storage_size); } template<class SequenceContainer, class Compare> @@ -199,7 +210,8 @@ inline void flat_tree_merge_equal //has_merge_unique == false { if(first != last) { typedef typename SequenceContainer::iterator iterator; - iterator const it = dest.insert( dest.end(), first, last ); + iterator const it = dest.insert( dest.end(), first, last); + BOOST_ASSERT((is_sorted)(it, dest.end(), comp)); dtl::bool_<is_contiguous_container<SequenceContainer>::value> contiguous_tag; (flat_tree_container_inplace_merge)(dest, it, comp, contiguous_tag); } @@ -227,7 +239,9 @@ inline void flat_tree_merge_unique //has_merge_unique == false typedef typename SequenceContainer::difference_type difference_type; size_type const old_sz = dest.size(); - iterator const first_new = dest.insert(dest.cend(), first, last ); + iterator const first_new = dest.insert(dest.cend(), first, last); + //We can't assert "is_sorted_and_unique" because the sequence can come from a multiset + BOOST_ASSERT((is_sorted)(first_new, dest.end(), comp)); iterator e = boost::movelib::inplace_set_unique_difference(first_new, dest.end(), dest.begin(), first_new, comp); dest.erase(e, dest.end()); dtl::bool_<is_contiguous_container<SequenceContainer>::value> contiguous_tag; @@ -316,23 +330,26 @@ template<class SequenceContainer, class Compare> void flat_tree_sort_contiguous_to_adopt // is_contiguous_container == true (SequenceContainer &tseq, BOOST_RV_REF(SequenceContainer) seq, Compare comp) { - if(tseq.capacity() >= (seq.capacity() - seq.size())) { - tseq.clear(); - boost::movelib::adaptive_sort - (boost::movelib::iterator_to_raw_pointer(seq.begin()) - , boost::movelib::iterator_to_raw_pointer(seq.end()) - , comp - , boost::movelib::iterator_to_raw_pointer(tseq.begin()) - , tseq.capacity()); - } - else{ - boost::movelib::adaptive_sort - (boost::movelib::iterator_to_raw_pointer(seq.begin()) - , boost::movelib::iterator_to_raw_pointer(seq.end()) - , comp - , boost::movelib::iterator_to_raw_pointer(seq.end()) - , seq.capacity() - seq.size()); - } + typedef typename SequenceContainer::value_type value_type; + typedef typename SequenceContainer::size_type size_type; + + size_type tseq_unused_storage_size, seq_unused_storage_size; + value_type* const tseq_unused_storage_addr = + unused_storage<SequenceContainer>::get(tseq, tseq_unused_storage_size); + value_type* const seq_unused_storage_addr = + unused_storage<SequenceContainer>::get(seq, seq_unused_storage_size); + + tseq.clear(); + const bool use_tseq_storage = tseq_unused_storage_size > seq_unused_storage_size; + + value_type * const seq_beg = boost::movelib::iterator_to_raw_pointer(seq.data()); + + boost::movelib::adaptive_sort + ( seq_beg + , seq_beg + seq.size() + , comp + , use_tseq_storage ? tseq_unused_storage_addr : seq_unused_storage_addr + , use_tseq_storage ? tseq_unused_storage_size : seq_unused_storage_size); } template<class SequenceContainer, class Compare> @@ -360,9 +377,11 @@ template<class SequenceContainer, class Compare> void flat_tree_adopt_sequence_unique// is_contiguous_container == true (SequenceContainer &tseq, BOOST_RV_REF(SequenceContainer) seq, Compare comp, dtl::true_) { + typedef typename SequenceContainer::value_type value_type; + value_type * const seq_beg = boost::movelib::iterator_to_raw_pointer(seq.data()); boost::movelib::pdqsort - ( boost::movelib::iterator_to_raw_pointer(seq.begin()) - , boost::movelib::iterator_to_raw_pointer(seq.end()) + ( seq_beg + , seq_beg + seq.size() , comp); seq.erase(boost::movelib::unique (seq.begin(), seq.end(), boost::movelib::negate<Compare>(comp)), seq.cend()); @@ -454,21 +473,21 @@ class flat_tree_value_compare /////////////////////////////////////// // -// select_container_type +// select_flat_tree_container_type // /////////////////////////////////////// template < class Value, class AllocatorOrContainer , bool = boost::container::dtl::is_container<AllocatorOrContainer>::value > -struct select_container_type +struct select_flat_tree_container_type { typedef AllocatorOrContainer type; }; -template <class Value, class AllocatorOrContainer> -struct select_container_type<Value, AllocatorOrContainer, false> +template <class Value, class AllocatorOrVoid> +struct select_flat_tree_container_type<Value, AllocatorOrVoid, false> { - typedef boost::container::vector<Value, typename real_allocator<Value, AllocatorOrContainer>::type> type; + typedef boost::container::vector<Value, AllocatorOrVoid> type; }; @@ -482,7 +501,7 @@ template <class Value, class KeyOfValue, class flat_tree { public: - typedef typename select_container_type<Value, AllocatorOrContainer>::type container_type; + typedef typename select_flat_tree_container_type<Value, AllocatorOrContainer>::type container_type; typedef container_type sequence_type; //For backwards compatibility private: @@ -562,20 +581,24 @@ class flat_tree public: - typedef typename container_type::value_type value_type; - typedef typename container_type::pointer pointer; - typedef typename container_type::const_pointer const_pointer; - typedef typename container_type::reference reference; - typedef typename container_type::const_reference const_reference; + typedef typename container_type::value_type value_type; + typedef typename container_type::pointer pointer; + typedef typename container_type::const_pointer const_pointer; + typedef typename container_type::reference reference; + typedef typename container_type::const_reference const_reference; typedef typename KeyOfValue::type key_type; typedef Compare key_compare; - typedef typename container_type::allocator_type allocator_type; - typedef typename container_type::size_type size_type; - typedef typename container_type::difference_type difference_type; - typedef typename container_type::iterator iterator; - typedef typename container_type::const_iterator const_iterator; - typedef typename container_type::reverse_iterator reverse_iterator; - typedef typename container_type::const_reverse_iterator const_reverse_iterator; + typedef typename container_type::allocator_type allocator_type; + typedef typename container_type::size_type size_type; + typedef typename container_type::difference_type difference_type; + typedef typename container_type::iterator iterator; + typedef typename container_type::const_iterator const_iterator; + typedef typename container_type::reverse_iterator reverse_iterator; + typedef typename container_type::const_reverse_iterator const_reverse_iterator; + + //`allocator_type::value_type` must match container's `value type`. If this + //assertion fails, please review your allocator definition. + BOOST_CONTAINER_STATIC_ASSERT((is_same<value_type, typename allocator_traits_type::value_type>::value)); //!Standard extension typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT @@ -718,7 +741,8 @@ class flat_tree } inline ~flat_tree() - {} + { + } inline flat_tree& operator=(BOOST_COPY_ASSIGN_REF(flat_tree) x) { m_data = x.m_data; return *this; } @@ -928,9 +952,10 @@ class flat_tree typename container_type::iterator const e = boost::movelib::inplace_set_unique_difference (it, seq.end(), seq.begin(), it, val_cmp); + //it might be invalidated by erasing [e, seq.end) if e == it, so check it before + const bool remaining = e != it; seq.erase(e, seq.cend()); - //it might be invalidated by erasing [e, seq.end) if e == it - if (it != e) + if (remaining) { //Step 4: merge both ranges (flat_tree_container_inplace_merge)(seq, it, this->priv_value_comp(), contiguous_tag); @@ -954,7 +979,6 @@ class flat_tree template <class InIt> void insert_equal(ordered_range_t, InIt first, InIt last) { - BOOST_ASSERT((is_sorted)(first, last, this->priv_value_comp())); const bool value = boost::container::dtl:: has_member_function_callable_with_merge_unique<container_type, InIt, InIt, value_compare>::value; (flat_tree_merge_equal)(this->m_data.m_seq, first, last, this->priv_value_comp(), dtl::bool_<value>()); @@ -963,7 +987,6 @@ class flat_tree template <class InIt> void insert_unique(ordered_unique_range_t, InIt first, InIt last) { - BOOST_ASSERT((is_sorted_and_unique)(this->m_data.m_seq.cbegin(), this->m_data.m_seq.cend(), this->priv_value_comp())); const bool value = boost::container::dtl:: has_member_function_callable_with_merge_unique<container_type, InIt, InIt, value_compare>::value; (flat_tree_merge_unique)(this->m_data.m_seq, first, last, this->priv_value_comp(), dtl::bool_<value>()); diff --git a/contrib/restricted/boost/container/include/boost/container/detail/function_detector.hpp b/contrib/restricted/boost/container/include/boost/container/detail/function_detector.hpp index 33134cb06f..6e432637eb 100644 --- a/contrib/restricted/boost/container/include/boost/container/detail/function_detector.hpp +++ b/contrib/restricted/boost/container/include/boost/container/detail/function_detector.hpp @@ -80,7 +80,7 @@ namespace function_detector { template <class U> \ static NotFoundType Test( ... ); \ public : \ - BOOST_STATIC_CONSTEXPR int check = NotFound + (sizeof(Test<T>(0, 0)) - sizeof(NotFoundType));\ + BOOST_STATIC_CONSTEXPR int check = NotFound + int(sizeof(Test<T>(0, 0)) - sizeof(NotFoundType));\ };\ }}} //namespace boost::container::function_detector { diff --git a/contrib/restricted/boost/container/include/boost/container/detail/is_contiguous_container.hpp b/contrib/restricted/boost/container/include/boost/container/detail/is_contiguous_container.hpp index 2688f809cf..e0cf6bab1e 100644 --- a/contrib/restricted/boost/container/include/boost/container/detail/is_contiguous_container.hpp +++ b/contrib/restricted/boost/container/include/boost/container/detail/is_contiguous_container.hpp @@ -31,9 +31,9 @@ #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 0 #include <boost/intrusive/detail/has_member_function_callable_with.hpp> -//back_free_capacity -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME back_free_capacity -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace back_free_capacity_detail { +//free_storage +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME unused_storage +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace unused_storage_detail { #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 0 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 0 @@ -60,19 +60,23 @@ struct is_contiguous_container template < class Container - , bool = boost::container::back_free_capacity_detail:: - has_member_function_callable_with_back_free_capacity<const Container>::value> -struct back_free_capacity + , bool = boost::container::unused_storage_detail:: + has_member_function_callable_with_unused_storage<const Container>::value> +struct unused_storage { - static typename Container::size_type get(const Container &c) - { return c.back_free_capacity(); } + static typename Container::value_type* get(Container &c, typename Container::size_type &s) + { return c.unused_storage(s); } }; + template < class Container> -struct back_free_capacity<Container, false> +struct unused_storage<Container, false> { - static typename Container::size_type get(const Container &c) - { return c.capacity() - c.size(); } + static typename Container::value_type* get(Container&, typename Container::size_type &s) + { + s = 0; + return 0; + } }; } //namespace dtl { diff --git a/contrib/restricted/boost/container/include/boost/container/detail/tree.hpp b/contrib/restricted/boost/container/include/boost/container/detail/tree.hpp index 1a3aa421a6..433792472d 100644 --- a/contrib/restricted/boost/container/include/boost/container/detail/tree.hpp +++ b/contrib/restricted/boost/container/include/boost/container/detail/tree.hpp @@ -456,6 +456,10 @@ class tree private: + //`allocator_type::value_type` must match container's `value type`. If this + //assertion fails, please review your allocator definition. + BOOST_CONTAINER_STATIC_ASSERT((dtl::is_same<value_type, typename allocator_traits<allocator_type>::value_type>::value)); + typedef key_node_pred<key_compare, key_of_value_t, Node> KeyNodeCompare; public: diff --git a/contrib/restricted/boost/container/include/boost/container/devector.hpp b/contrib/restricted/boost/container/include/boost/container/devector.hpp index 9b1f643090..59581a3ea8 100644 --- a/contrib/restricted/boost/container/include/boost/container/devector.hpp +++ b/contrib/restricted/boost/container/include/boost/container/devector.hpp @@ -173,6 +173,11 @@ class devector #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: + + //`allocator_type::value_type` must match container's `value type`. If this + //assertion fails, please review your allocator definition. + BOOST_CONTAINER_STATIC_ASSERT((dtl::is_same<value_type, typename allocator_traits<allocator_type>::value_type>::value)); + BOOST_COPYABLE_AND_MOVABLE(devector) // Guard to deallocate buffer on exception @@ -2170,6 +2175,28 @@ class devector || allocator_traits_type::is_always_equal::value) { x.swap(y); } + #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + + //Functions for optimizations, not for users + T *unused_storage(size_type &sz) + { + T *const storage_addr = boost::movelib::to_raw_pointer(m_.buffer); + if(this->empty()){ + sz = m_.capacity; + return storage_addr; + } + else if(this->back_free_capacity() > this->front_free_capacity()){ + sz = this->back_free_capacity(); + return storage_addr + m_.back_idx; + } + else{ + sz = this->front_free_capacity(); + return storage_addr; + } + } + + #endif + private: void priv_move_assign(BOOST_RV_REF(devector) x, dtl::bool_<true> /*steal_resources*/) @@ -2285,20 +2312,20 @@ class devector return static_cast<const allocator_type&>(m_); } - pointer allocate(size_type capacity) + pointer allocate(size_type cap) { - pointer const p = impl::do_allocate(get_allocator_ref(), capacity); + pointer const p = impl::do_allocate(get_allocator_ref(), cap); #ifdef BOOST_CONTAINER_DEVECTOR_ALLOC_STATS ++m_.capacity_alloc_count; #endif // BOOST_CONTAINER_DEVECTOR_ALLOC_STATS return p; } - void destroy_elements(pointer begin, pointer end) + void destroy_elements(pointer b, pointer e) { - for (; begin != end; ++begin) + for (; b != e; ++b) { - allocator_traits_type::destroy(get_allocator_ref(), boost::movelib::to_raw_pointer(begin)); + allocator_traits_type::destroy(get_allocator_ref(), boost::movelib::to_raw_pointer(b)); } } @@ -2400,10 +2427,10 @@ class devector } template <typename Guard> - void opt_move_or_copy(pointer begin, pointer end, pointer dst, Guard& guard) + void opt_move_or_copy(pointer b, pointer e, pointer dst, Guard& guard) { // if trivial copy and default allocator, memcpy - boost::container::uninitialized_move_alloc(get_allocator_ref(), begin, end, dst); + boost::container::uninitialized_move_alloc(get_allocator_ref(), b, e, dst); guard.extend(); } @@ -2782,10 +2809,10 @@ class devector template <typename Iterator> - void construct_from_range(Iterator begin, Iterator end) + void construct_from_range(Iterator b, Iterator e) { allocation_guard buffer_guard(m_.buffer, m_.capacity, get_allocator_ref()); - boost::container::uninitialized_copy_alloc(get_allocator_ref(), begin, end, m_.buffer); + boost::container::uninitialized_copy_alloc(get_allocator_ref(), b, e, m_.buffer); buffer_guard.release(); } diff --git a/contrib/restricted/boost/container/include/boost/container/flat_map.hpp b/contrib/restricted/boost/container/include/boost/container/flat_map.hpp index cf6d650354..8ec402c63e 100644 --- a/contrib/restricted/boost/container/include/boost/container/flat_map.hpp +++ b/contrib/restricted/boost/container/include/boost/container/flat_map.hpp @@ -163,11 +163,14 @@ class flat_map typedef dtl_pair_t impl_pair_t; #endif - typedef dtl::flat_tree< - impl_pair_t, + typedef dtl::flat_tree< impl_pair_t, dtl::select1st<Key>, Compare, + #ifdef BOOST_CONTAINER_STD_PAIR_IS_MOVABLE + AllocatorOrContainer + #else typename dtl::container_or_allocator_rebind<AllocatorOrContainer, impl_pair_t >::type + #endif > impl_tree_t; impl_tree_t m_flat_tree; // flat tree representing flat_map @@ -1849,7 +1852,11 @@ class flat_multimap impl_pair_t, dtl::select1st<Key>, Compare, + #ifdef BOOST_CONTAINER_STD_PAIR_IS_MOVABLE + AllocatorOrContainer + #else typename dtl::container_or_allocator_rebind<AllocatorOrContainer, impl_pair_t >::type + #endif > impl_tree_t; impl_tree_t m_flat_tree; // flat tree representing flat_map diff --git a/contrib/restricted/boost/container/include/boost/container/list.hpp b/contrib/restricted/boost/container/include/boost/container/list.hpp index e597c48766..1061446fc5 100644 --- a/contrib/restricted/boost/container/include/boost/container/list.hpp +++ b/contrib/restricted/boost/container/include/boost/container/list.hpp @@ -1378,6 +1378,10 @@ class list #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: + //`allocator_type::value_type` must match container's `value type`. If this + //assertion fails, please review your allocator definition. + BOOST_CONTAINER_STATIC_ASSERT((dtl::is_same<value_type, typename allocator_traits_type::value_type>::value)); + void priv_move_assign(BOOST_RV_REF(list) x, dtl::bool_<true> /*steal_resources*/) { //Destroy objects but retain memory in case x reuses it in the future diff --git a/contrib/restricted/boost/container/include/boost/container/options.hpp b/contrib/restricted/boost/container/include/boost/container/options.hpp index dad41b7aef..13b168f1a2 100644 --- a/contrib/restricted/boost/container/include/boost/container/options.hpp +++ b/contrib/restricted/boost/container/include/boost/container/options.hpp @@ -289,8 +289,8 @@ BOOST_INTRUSIVE_OPTION_TYPE(growth_factor, GrowthFactor, GrowthFactor, growth_fa //! //!If the maximum capacity() to be used is limited, a user can try to use 8-bit, 16-bit //!(e.g. in 32-bit machines), or 32-bit size types (e.g. in a 64 bit machine) to see if some -//!memory can be saved for empty vectors. This could potentially performance benefits due to better -//!cache usage. +//!memory can be saved, specially for empty containers. This could potentially improve performance +//!due to better cache usage. //! //!Note that alignment requirements can disallow theoretical space savings. Example: //!\c vector holds a pointer and two size types (for size and capacity), in a 32 bit machine @@ -301,7 +301,7 @@ BOOST_INTRUSIVE_OPTION_TYPE(growth_factor, GrowthFactor, GrowthFactor, growth_fa //!Measure the size of the resulting container and do not assume a smaller \c stored_size //!will always lead to a smaller sizeof(container). //! -//!If a user tries to insert more elements than representable by \c stored_size, vector +//!If a user tries to insert more elements than representable by \c stored_size, the container //!will throw a length_error. //! //!If this option is not specified, `allocator_traits<A>::size_type` (usually std::size_t) will @@ -337,7 +337,6 @@ struct vector_options //! Helper alias metafunction to combine options into a single type to be used //! by \c boost::container::vector. -//! Supported options are: \c boost::container::growth_factor and \c boost::container::stored_size template<class ...Options> using vector_options_t = typename boost::container::vector_options<Options...>::type; @@ -360,20 +359,23 @@ BOOST_INTRUSIVE_OPTION_CONSTANT(inplace_alignment, std::size_t, Alignment, inpla #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) -template<class GrowthType, std::size_t InplaceAlignment> +template<class GrowthType, std::size_t InplaceAlignment, class StoredSizeType> struct small_vector_opt { - typedef GrowthType growth_factor_type; + typedef GrowthType growth_factor_type; BOOST_STATIC_CONSTEXPR std::size_t inplace_alignment = InplaceAlignment; + typedef StoredSizeType stored_size_type; }; -typedef small_vector_opt<void, 0u> small_vector_null_opt; +typedef small_vector_opt<void, 0u, void> small_vector_null_opt; #endif //!defined(BOOST_CONTAINER_DOXYGEN_INVOKED) //! Helper metafunction to combine options into a single type to be used //! by \c boost::container::small_vector. -//! Supported options are: \c boost::container::growth_factor and \c boost::container::inplace_alignment +//! Supported options are: \c boost::container::growth_factor, +//! \c boost::container::inplace_alignment and +//! \c boost::container::stored_size. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) || defined(BOOST_CONTAINER_VARIADIC_TEMPLATES) template<class ...Options> #else @@ -391,7 +393,9 @@ struct small_vector_options #endif >::type packed_options; typedef small_vector_opt< typename packed_options::growth_factor_type - , packed_options::inplace_alignment> implementation_defined; + , packed_options::inplace_alignment + , typename packed_options::stored_size_type + > implementation_defined; /// @endcond typedef implementation_defined type; }; @@ -400,7 +404,6 @@ struct small_vector_options //! Helper alias metafunction to combine options into a single type to be used //! by \c boost::container::small_vector. -//! Supported options are: \c boost::container::growth_factor and \c boost::container::stored_size template<class ...Options> using small_vector_options_t = typename boost::container::small_vector_options<Options...>::type; @@ -427,20 +430,22 @@ BOOST_INTRUSIVE_OPTION_CONSTANT(throw_on_overflow, bool, ThrowOnOverflow, throw_ #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) -template<bool ThrowOnOverflow, std::size_t InplaceAlignment> +template<bool ThrowOnOverflow, std::size_t InplaceAlignment, class StoredSizeType> struct static_vector_opt { BOOST_STATIC_CONSTEXPR bool throw_on_overflow = ThrowOnOverflow; BOOST_STATIC_CONSTEXPR std::size_t inplace_alignment = InplaceAlignment; + typedef StoredSizeType stored_size_type; }; -typedef static_vector_opt<true, 0u> static_vector_null_opt; +typedef static_vector_opt<true, 0u, void> static_vector_null_opt; #endif //!defined(BOOST_CONTAINER_DOXYGEN_INVOKED) //! Helper metafunction to combine options into a single type to be used //! by \c boost::container::static_vector. -//! Supported options are: \c boost::container::throw_on_overflow and \c boost::container::inplace_alignment +//! Supported options are: \c boost::container::throw_on_overflow, \c boost::container::inplace_alignment +//! and \c boost::container::stored_size. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) || defined(BOOST_CONTAINER_VARIADIC_TEMPLATES) template<class ...Options> #else @@ -458,7 +463,9 @@ struct static_vector_options #endif >::type packed_options; typedef static_vector_opt< packed_options::throw_on_overflow - , packed_options::inplace_alignment> implementation_defined; + , packed_options::inplace_alignment + , typename packed_options::stored_size_type + > implementation_defined; /// @endcond typedef implementation_defined type; }; @@ -467,7 +474,6 @@ struct static_vector_options //! Helper alias metafunction to combine options into a single type to be used //! by \c boost::container::static_vector. -//! Supported options are: \c boost::container::growth_factor and \c boost::container::stored_size template<class ...Options> using static_vector_options_t = typename boost::container::static_vector_options<Options...>::type; @@ -587,7 +593,6 @@ struct devector_options //! Helper alias metafunction to combine options into a single type to be used //! by \c boost::container::devector. -//! Supported options are: \c boost::container::growth_factor and \c boost::container::stored_size template<class ...Options> using devector_options_t = typename boost::container::devector_options<Options...>::type; @@ -643,7 +648,6 @@ struct deque_options //! Helper alias metafunction to combine options into a single type to be used //! by \c boost::container::deque. -//! Supported options are: \c boost::container::block_bytes template<class ...Options> using deque_options_t = typename boost::container::deque_options<Options...>::type; diff --git a/contrib/restricted/boost/container/include/boost/container/slist.hpp b/contrib/restricted/boost/container/include/boost/container/slist.hpp index b8853f5645..54ef5bde25 100644 --- a/contrib/restricted/boost/container/include/boost/container/slist.hpp +++ b/contrib/restricted/boost/container/include/boost/container/slist.hpp @@ -1565,6 +1565,11 @@ class slist #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: + + //`allocator_type::value_type` must match container's `value type`. If this + //assertion fails, please review your allocator definition. + BOOST_CONTAINER_STATIC_ASSERT((dtl::is_same<value_type, typename allocator_traits_type::value_type>::value)); + void priv_move_assign(BOOST_RV_REF(slist) x, dtl::bool_<true> /*steal_resources*/) { //Destroy objects but retain memory in case x reuses it in the future diff --git a/contrib/restricted/boost/container/include/boost/container/small_vector.hpp b/contrib/restricted/boost/container/include/boost/container/small_vector.hpp index 5882326f2c..afed910873 100644 --- a/contrib/restricted/boost/container/include/boost/container/small_vector.hpp +++ b/contrib/restricted/boost/container/include/boost/container/small_vector.hpp @@ -69,7 +69,9 @@ struct get_vopt_from_svopt : get_small_vector_opt<Options>::type { typedef typename get_small_vector_opt<Options>::type options_t; - typedef vector_opt< typename options_t::growth_factor_type, void> type; + typedef vector_opt< typename options_t::growth_factor_type + , typename options_t::stored_size_type + > type; }; template<> @@ -340,9 +342,11 @@ struct small_vector_storage<T, 0u, Alignment> //! template <class T, class SecAlloc, class Options> class small_vector_base +#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED : public dtl::vector_for_small_vector<T, SecAlloc, Options>::type +#endif { - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKEDVECTOR + #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED public: //Make it public as it will be inherited by small_vector and container //must have this public member @@ -389,13 +393,13 @@ class small_vector_base {} template<class AllocFwd> - inline explicit small_vector_base(initial_capacity_t, size_type capacity, BOOST_FWD_REF(AllocFwd) a) - : base_type(initial_capacity_t(), this->internal_storage(), capacity, ::boost::forward<AllocFwd>(a)) + inline explicit small_vector_base(initial_capacity_t, size_type initial_capacity, BOOST_FWD_REF(AllocFwd) a) + : base_type(initial_capacity_t(), this->internal_storage(), initial_capacity, ::boost::forward<AllocFwd>(a)) {} template<class AllocFwd> - inline explicit small_vector_base(initial_capacity_t, size_type capacity, BOOST_FWD_REF(AllocFwd) a, small_vector_base &x) - : base_type(initial_capacity_t(), this->internal_storage(), capacity, ::boost::forward<AllocFwd>(a), x) + inline explicit small_vector_base(initial_capacity_t, size_type initial_capacity, BOOST_FWD_REF(AllocFwd) a, small_vector_base &x) + : base_type(initial_capacity_t(), this->internal_storage(), initial_capacity, ::boost::forward<AllocFwd>(a), x) {} inline explicit small_vector_base(maybe_initial_capacity_t, size_type initial_capacity, size_type initial_size) diff --git a/contrib/restricted/boost/container/include/boost/container/stable_vector.hpp b/contrib/restricted/boost/container/include/boost/container/stable_vector.hpp index e0799129c7..f8952c8368 100644 --- a/contrib/restricted/boost/container/include/boost/container/stable_vector.hpp +++ b/contrib/restricted/boost/container/include/boost/container/stable_vector.hpp @@ -597,6 +597,11 @@ class stable_vector #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: + + //`allocator_type::value_type` must match container's `value type`. If this + //assertion fails, please review your allocator definition. + BOOST_CONTAINER_STATIC_ASSERT((dtl::is_same<value_type, typename allocator_traits<allocator_type>::value_type>::value)); + BOOST_COPYABLE_AND_MOVABLE(stable_vector) BOOST_STATIC_CONSTEXPR size_type ExtraPointers = index_traits_type::ExtraPointers; @@ -2177,11 +2182,11 @@ class stable_vector , node_ptr_traits::static_cast_from(pool_first_ref) , node_ptr_traits::static_cast_from(pool_last_ref) , internal_data.pool_size); - typename multiallocation_chain::iterator beg(holder.begin()), end(holder.end()); + typename multiallocation_chain::iterator b(holder.begin()), e(holder.end()); size_type num_pool = 0; - while(beg != end){ + while(b != e){ ++num_pool; - ++beg; + ++b; } return n >= num_pool && num_pool == internal_data.pool_size; } diff --git a/contrib/restricted/boost/container/include/boost/container/static_vector.hpp b/contrib/restricted/boost/container/include/boost/container/static_vector.hpp index 1406fdb7de..4039912089 100644 --- a/contrib/restricted/boost/container/include/boost/container/static_vector.hpp +++ b/contrib/restricted/boost/container/include/boost/container/static_vector.hpp @@ -102,6 +102,19 @@ struct get_static_vector_opt<void> typedef static_vector_null_opt type; }; +template<class Options> +struct get_vector_opt_from_static_vector_opt +{ + typedef typename get_static_vector_opt<Options>::type options_t; + typedef vector_opt<void, typename options_t::stored_size_type> type; +}; + +template<> +struct get_vector_opt_from_static_vector_opt<void> +{ + typedef void type; +}; + template <typename T, std::size_t Capacity, class Options> struct get_static_vector_allocator { @@ -114,7 +127,6 @@ struct get_static_vector_allocator > type; }; - } //namespace dtl { #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED @@ -148,12 +160,18 @@ struct get_static_vector_allocator //! is specified, by default throw_on_overflow<true> option is set. template <typename T, std::size_t Capacity, class Options BOOST_CONTAINER_DOCONLY(= void) > class static_vector - : public vector<T, typename dtl::get_static_vector_allocator< T, Capacity, Options>::type> + #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + : public vector< T + , typename dtl::get_static_vector_allocator< T, Capacity, Options>::type + , typename dtl::get_vector_opt_from_static_vector_opt<Options>::type + > + #endif { public: #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED typedef typename dtl::get_static_vector_allocator< T, Capacity, Options>::type allocator_type; - typedef vector<T, allocator_type > base_t; + typedef typename dtl::get_vector_opt_from_static_vector_opt<Options>::type options_type; + typedef vector<T, allocator_type, options_type> base_t; BOOST_COPYABLE_AND_MOVABLE(static_vector) diff --git a/contrib/restricted/boost/container/include/boost/container/string.hpp b/contrib/restricted/boost/container/include/boost/container/string.hpp index b7eaa1adc5..4a69e192e2 100644 --- a/contrib/restricted/boost/container/include/boost/container/string.hpp +++ b/contrib/restricted/boost/container/include/boost/container/string.hpp @@ -628,6 +628,11 @@ class basic_string #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: + + //`allocator_type::value_type` must match container's `value type`. If this + //assertion fails, please review your allocator definition. + BOOST_CONTAINER_STATIC_ASSERT((dtl::is_same<value_type, typename allocator_traits<allocator_type>::value_type>::value)); + typedef constant_iterator<CharT> cvalue_iterator; typedef typename base_t::alloc_version alloc_version; typedef ::boost::intrusive::pointer_traits<pointer> pointer_traits; @@ -3545,21 +3550,6 @@ getline(std::basic_istream<CharT, Traits>& is, basic_string<CharT,Traits,Allocat return getline(is, s, '\n'); } -template <class Ch, class Allocator> -inline std::size_t hash_value(basic_string<Ch, std::char_traits<Ch>, Allocator> const& v) -{ - std::size_t seed = 0; - const Ch *first = v.data(); - - for(std::size_t i = 0, i_max = v.size(); i != i_max; ++i) - { - boost::intrusive::detail::hash_combine_size_t(seed, static_cast<std::size_t>(*first)); - ++first; - } - - return seed; -} - }} //GCC 12 has a regression for array-bounds warnings diff --git a/contrib/restricted/boost/container/include/boost/container/vector.hpp b/contrib/restricted/boost/container/include/boost/container/vector.hpp index 091417620f..aecb7dd2b5 100644 --- a/contrib/restricted/boost/container/include/boost/container/vector.hpp +++ b/contrib/restricted/boost/container/include/boost/container/vector.hpp @@ -643,7 +643,7 @@ struct vector_alloc_holder<Allocator, StoredSizeType, version_0> template<class AllocConvertible> vector_alloc_holder(vector_uninitialized_size_t, BOOST_FWD_REF(AllocConvertible) a, size_type initial_size) : allocator_type(boost::forward<AllocConvertible>(a)) - , m_size(initial_size) //Size is initialized here... + , m_size(static_cast<stored_size_type>(initial_size)) //Size is initialized here... { //... and capacity here, so vector, must call uninitialized_xxx in the derived constructor this->priv_first_allocation(initial_size); @@ -652,7 +652,7 @@ struct vector_alloc_holder<Allocator, StoredSizeType, version_0> //Constructor, does not throw vector_alloc_holder(vector_uninitialized_size_t, size_type initial_size) : allocator_type() - , m_size(initial_size) //Size is initialized here... + , m_size(static_cast<stored_size_type>(initial_size)) //Size is initialized here... { //... and capacity here, so vector, must call uninitialized_xxx in the derived constructor this->priv_first_allocation(initial_size); @@ -813,8 +813,11 @@ public: typedef BOOST_CONTAINER_IMPDEF(boost::container::reverse_iterator<const_iterator>) const_reverse_iterator; private: - #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + //`allocator_type::value_type` must match container's `value type`. If this + //assertion fails, please review your allocator definition. + BOOST_CONTAINER_STATIC_ASSERT((dtl::is_same<value_type, typename allocator_traits_t::value_type>::value)); + typedef typename boost::container:: allocator_traits<allocator_type>::size_type alloc_size_type; typedef typename get_vector_opt<Options, alloc_size_type>::type options_type; @@ -2315,6 +2318,7 @@ private: return cp >= new_cap || (alloc_version::value == 2 && this->m_holder.try_expand_fwd(size_type(new_cap - cp))); } + #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED //Absolutely experimental. This function might change, disappear or simply crash! template<class BiDirPosConstIt, class BiDirValueIt> inline void insert_ordered_at(const size_type element_count, BiDirPosConstIt last_position_it, BiDirValueIt last_value_it) @@ -2328,32 +2332,48 @@ private: { this->merge(first, last, value_less_t()); } template<class InputIt, class Compare> - inline void merge(InputIt first, InputIt last, Compare comp) + inline + typename dtl::enable_if_c + < !dtl::is_input_iterator<InputIt>::value && + dtl::is_same<value_type, typename iterator_traits<InputIt>::value_type>::value + , void>::type + merge(InputIt first, InputIt last, Compare comp) { size_type const s = this->size(); size_type const c = this->capacity(); size_type n = 0; size_type const free_cap = c - s; //If not input iterator and new elements don't fit in the remaining capacity, merge in new buffer - if(!dtl::is_input_iterator<InputIt>::value && - free_cap < (n = boost::container::iterator_udistance(first, last))){ + if(free_cap < (n = boost::container::iterator_udistance(first, last))){ this->priv_merge_in_new_buffer(first, n, comp, alloc_version()); } else{ - this->insert(this->cend(), first, last); - T *const raw_beg = this->priv_raw_begin(); - T *const raw_end = this->priv_raw_end(); - T *const raw_pos = raw_beg + s; - boost::movelib::adaptive_merge(raw_beg, raw_pos, raw_end, comp, raw_end, free_cap - n); + this->priv_merge_generic(first, last, comp); } } + template<class InputIt, class Compare> + inline + typename dtl::enable_if_c + < dtl::is_input_iterator<InputIt>::value || + !dtl::is_same<value_type, typename iterator_traits<InputIt>::value_type>::value + , void>::type + merge(InputIt first, InputIt last, Compare comp) + { + this->priv_merge_generic(first, last, comp); + } + template<class InputIt> inline void merge_unique(InputIt first, InputIt last) { this->merge_unique(first, last, value_less_t()); } template<class InputIt, class Compare> - inline void merge_unique(InputIt first, InputIt last, Compare comp) + inline + typename dtl::enable_if_c + < !dtl::is_input_iterator<InputIt>::value && + dtl::is_same<value_type, typename iterator_traits<InputIt>::value_type>::value + , void>::type + merge_unique(InputIt first, InputIt last, Compare comp) { size_type const old_size = this->size(); this->priv_set_difference_back(first, last, comp); @@ -2363,7 +2383,42 @@ private: boost::movelib::adaptive_merge(raw_beg, raw_pos, raw_end, comp, raw_end, this->capacity() - this->size()); } + template<class InputIt, class Compare> + inline + typename dtl::enable_if_c + < dtl::is_input_iterator<InputIt>::value || + !dtl::is_same<value_type, typename iterator_traits<InputIt>::value_type>::value + , void>::type + merge_unique(InputIt first, InputIt last, Compare comp) + { + iterator pos = this->insert(this->end(), first, last); + const iterator e = boost::movelib::inplace_set_unique_difference(pos, this->end(), this->begin(), pos, comp); + this->erase(e, this->end()); + boost::movelib::adaptive_merge( this->begin(), pos, e, comp + , this->priv_raw_end(), this->capacity() - this->size()); + } + + //Function for optimizations, not for users + T *unused_storage(size_type &sz) + { + sz = static_cast<size_type>(this->capacity() - this->size()); + return this->priv_raw_end(); + } + + #endif + private: + template<class InputIt, class Compare> + inline void priv_merge_generic(InputIt first, InputIt last, Compare comp) + { + size_type const old_s = this->size(); + this->insert(this->cend(), first, last); + T* const raw_beg = this->priv_raw_begin(); + T* const raw_end = this->priv_raw_end(); + T* const raw_pos = raw_beg + old_s; + boost::movelib::adaptive_merge(raw_beg, raw_pos, raw_end, comp, raw_end, this->capacity() - this->size()); + } + template<class PositionValue> void priv_insert_ordered_at(const size_type element_count, PositionValue position_value) { @@ -2710,7 +2765,7 @@ private: //Move internal memory data to the internal memory data of the target, this can throw BOOST_ASSERT(extmem.capacity() >= intmem.size()); ::boost::container::uninitialized_move_alloc_n - (intmem.get_stored_allocator(), this->priv_raw_begin(), intmem.size(), extmem.priv_raw_begin()); + (intmem.get_stored_allocator(), intmem.priv_raw_begin(), intmem.size(), extmem.priv_raw_begin()); //Exception not thrown, commit new state extmem.m_holder.set_stored_size(intmem.size()); @@ -2721,7 +2776,7 @@ private: //Destroy moved elements from intmem boost::container::destroy_alloc_n - ( intmem.get_stored_allocator(), this->priv_raw_begin() + ( intmem.get_stored_allocator(), intmem.priv_raw_begin() , intmem.size()); //Adopt dynamic buffer @@ -3319,6 +3374,8 @@ struct has_trivial_destructor_after_move<boost::container::vector<T, Allocator, //See comments on vec_iterator::element_type to know why is this needed #ifdef BOOST_GNU_STDLIB +#include <boost/move/detail/std_ns_begin.hpp> + BOOST_MOVE_STD_NS_BEG template <class Pointer, bool IsConst> @@ -3328,6 +3385,8 @@ struct pointer_traits< boost::container::vec_iterator<Pointer, IsConst> > BOOST_MOVE_STD_NS_END +#include <boost/move/detail/std_ns_end.hpp> + #endif //BOOST_GNU_STDLIB #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED diff --git a/contrib/restricted/boost/container/src/dlmalloc_2_8_6.c b/contrib/restricted/boost/container/src/dlmalloc_2_8_6.c index 63ef0d3fb8..db6b8235cb 100644 --- a/contrib/restricted/boost/container/src/dlmalloc_2_8_6.c +++ b/contrib/restricted/boost/container/src/dlmalloc_2_8_6.c @@ -1853,8 +1853,8 @@ static FORCEINLINE void x86_clear_lock(int* sl) { #define CLEAR_LOCK(sl) x86_clear_lock(sl) #else /* Win32 MSC */ -#define CAS_LOCK(sl) interlockedexchange(sl, (LONG)1) -#define CLEAR_LOCK(sl) interlockedexchange (sl, (LONG)0) +#define CAS_LOCK(sl) interlockedexchange((volatile long*)sl, (LONG)1) +#define CLEAR_LOCK(sl) interlockedexchange ((volatile long*)sl, (LONG)0) #endif /* ... gcc spins locks ... */ diff --git a/contrib/restricted/boost/container/ya.make b/contrib/restricted/boost/container/ya.make index 4ebf93e111..ea45272059 100644 --- a/contrib/restricted/boost/container/ya.make +++ b/contrib/restricted/boost/container/ya.make @@ -9,9 +9,9 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(1.86.0) +VERSION(1.87.0) -ORIGINAL_SOURCE(https://github.com/boostorg/container/archive/boost-1.86.0.tar.gz) +ORIGINAL_SOURCE(https://github.com/boostorg/container/archive/boost-1.87.0.tar.gz) PEERDIR( contrib/restricted/boost/assert |