From 42c6be5887b34b67be4d54041acab12157d080f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 29 Apr 2018 12:37:35 +0200 Subject: [PATCH] Fixes Trac #13533: "Boost vector resize causes assert(false)" --- .../container/detail/advanced_insert_int.hpp | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/include/boost/container/detail/advanced_insert_int.hpp b/include/boost/container/detail/advanced_insert_int.hpp index d9cba48..fc8a33a 100644 --- a/include/boost/container/detail/advanced_insert_int.hpp +++ b/include/boost/container/detail/advanced_insert_int.hpp @@ -125,8 +125,16 @@ struct insert_value_initialized_n_proxy void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const { boost::container::uninitialized_value_init_alloc_n(a, n, p); } - void copy_n_and_update(Allocator &, Iterator, size_type) const - { BOOST_ASSERT(false); } + void copy_n_and_update(Allocator &a, Iterator p, size_type n) const + { + for (; 0 < n; --n, ++p){ + typename aligned_storage::value>::type stor; + value_type &v = *static_cast(static_cast(stor.data)); + alloc_traits::construct(a, &v); + value_destructor on_exit(a, v); (void)on_exit; + *p = ::boost::move(v); + } + } }; template @@ -139,8 +147,18 @@ struct insert_default_initialized_n_proxy void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const { boost::container::uninitialized_default_init_alloc_n(a, n, p); } - void copy_n_and_update(Allocator &, Iterator, size_type) const - { BOOST_ASSERT(false); } + void copy_n_and_update(Allocator &a, Iterator p, size_type n) const + { + if(!is_pod::value){ + for (; 0 < n; --n, ++p){ + typename aligned_storage::value>::type stor; + value_type &v = *static_cast(static_cast(stor.data)); + alloc_traits::construct(a, &v, default_init); + value_destructor on_exit(a, v); (void)on_exit; + *p = ::boost::move(v); + } + } + } }; template