src/cxx_supportlib/vendor-modified/boost/container/vector.hpp in passenger-6.0.14 vs src/cxx_supportlib/vendor-modified/boost/container/vector.hpp in passenger-6.0.15
- old
+ new
@@ -80,22 +80,25 @@
template <class Pointer, bool IsConst>
class vec_iterator
{
public:
typedef std::random_access_iterator_tag iterator_category;
+ #ifdef BOOST_MOVE_CONTIGUOUS_ITERATOR_TAG
typedef std::contiguous_iterator_tag iterator_concept;
+ #endif
typedef typename boost::intrusive::pointer_traits<Pointer>::element_type value_type;
//Defining element_type to make libstdc++'s std::pointer_traits well-formed leads to ambiguity
//due to LWG3446. So we need to specialize std::pointer_traits. See
- //https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96416 for details. /Many thanks to Jonathan Wakely
- //for explaning the issue.
+ //https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96416 for details. Many thanks to Jonathan Wakely
+ //for explaining the issue.
#ifndef BOOST_GNU_STDLIB
//Define element_
typedef typename boost::intrusive::pointer_traits<Pointer>::element_type element_type;
#endif
typedef typename boost::intrusive::pointer_traits<Pointer>::difference_type difference_type;
+ typedef typename boost::intrusive::pointer_traits<Pointer>::size_type size_type;
typedef typename dtl::if_c
< IsConst
, typename boost::intrusive::pointer_traits<Pointer>::template
rebind_pointer<const value_type>::type
, Pointer
@@ -192,10 +195,11 @@
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
friend vec_iterator operator-(vec_iterator left, difference_type off) BOOST_NOEXCEPT_OR_NOTHROW
{ BOOST_ASSERT(left.m_ptr || !off); left.m_ptr -= off; return left; }
+ //Difference
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
friend difference_type operator-(const vec_iterator &left, const vec_iterator& right) BOOST_NOEXCEPT_OR_NOTHROW
{ return left.m_ptr - right.m_ptr; }
//Comparison operators
@@ -313,11 +317,12 @@
static bool is_propagable_from(const allocator_type &from_alloc, pointer p, const allocator_type &to_alloc, bool const propagate_allocator)
{
(void)propagate_allocator; (void)p; (void)to_alloc; (void)from_alloc;
const bool all_storage_propagable = !allocator_traits_type::is_partially_propagable::value ||
!allocator_traits_type::storage_is_unpropagable(from_alloc, p);
- return all_storage_propagable && (propagate_allocator || allocator_traits_type::equal(from_alloc, to_alloc));
+ return all_storage_propagable &&
+ (propagate_allocator || allocator_traits_type::is_always_equal::value || allocator_traits_type::equal(from_alloc, to_alloc));
}
BOOST_CONTAINER_FORCEINLINE
static bool are_swap_propagable(const allocator_type &l_a, pointer l_p, const allocator_type &r_a, pointer r_p, bool const propagate_allocator)
{
@@ -415,14 +420,14 @@
BOOST_CONTAINER_FORCEINLINE void set_stored_size(size_type s) BOOST_NOEXCEPT_OR_NOTHROW
{ this->m_size = static_cast<stored_size_type>(s); }
BOOST_CONTAINER_FORCEINLINE void dec_stored_size(size_type s) BOOST_NOEXCEPT_OR_NOTHROW
- { this->m_size -= static_cast<stored_size_type>(s); }
+ { this->m_size = static_cast<stored_size_type>(this->m_size - s); }
BOOST_CONTAINER_FORCEINLINE void inc_stored_size(size_type s) BOOST_NOEXCEPT_OR_NOTHROW
- { this->m_size += static_cast<stored_size_type>(s); }
+ { this->m_size = static_cast<stored_size_type>(this->m_size + s); }
BOOST_CONTAINER_FORCEINLINE void set_stored_capacity(size_type c) BOOST_NOEXCEPT_OR_NOTHROW
{ this->m_capacity = static_cast<stored_size_type>(c); }
BOOST_CONTAINER_FORCEINLINE pointer allocation_command(boost::container::allocation_type command,
@@ -430,11 +435,11 @@
{
typedef typename dtl::version<allocator_type>::type alloc_version;
return this->priv_allocation_command(alloc_version(), command, limit_size, prefer_in_recvd_out_size, reuse);
}
- BOOST_CONTAINER_FORCEINLINE pointer allocate(size_type n)
+ pointer allocate(size_type n)
{
const size_type max_alloc = allocator_traits_type::max_size(this->alloc());
const size_type max = max_alloc <= stored_size_type(-1) ? max_alloc : stored_size_type(-1);
if ( max < n )
boost::container::throw_length_error("get_next_capacity, allocator's max size reached");
@@ -448,11 +453,11 @@
}
bool try_expand_fwd(size_type at_least)
{
//There is not enough memory, try to expand the old one
- const size_type new_cap = this->capacity() + at_least;
+ const size_type new_cap = size_type(this->capacity() + at_least);
size_type real_cap = new_cap;
pointer reuse = this->start();
bool const success = !!this->allocation_command(expand_fwd, new_cap, real_cap, reuse);
//Check for forward expansion
if(success){
@@ -468,12 +473,12 @@
size_type next_capacity(size_type additional_objects) const
{
BOOST_ASSERT(additional_objects > size_type(this->m_capacity - this->m_size));
size_type max = allocator_traits_type::max_size(this->alloc());
(clamp_by_stored_size_type<size_type>)(max, stored_size_type());
- const size_type remaining_cap = max - size_type(this->m_capacity);
- const size_type min_additional_cap = additional_objects - size_type(this->m_capacity - this->m_size);
+ const size_type remaining_cap = size_type(max - size_type(this->m_capacity));
+ const size_type min_additional_cap = size_type(additional_objects - size_type(this->m_capacity - this->m_size));
if ( remaining_cap < min_additional_cap )
boost::container::throw_length_error("get_next_capacity, allocator's max size reached");
return GrowthFactorType()( size_type(this->m_capacity), min_additional_cap, max);
@@ -645,26 +650,24 @@
BOOST_CONTAINER_FORCEINLINE void set_stored_size(size_type s) BOOST_NOEXCEPT_OR_NOTHROW
{ this->m_size = static_cast<stored_size_type>(s); }
BOOST_CONTAINER_FORCEINLINE void dec_stored_size(size_type s) BOOST_NOEXCEPT_OR_NOTHROW
- { this->m_size -= static_cast<stored_size_type>(s); }
+ { this->m_size = static_cast<stored_size_type>(this->m_size - s); }
BOOST_CONTAINER_FORCEINLINE void inc_stored_size(size_type s) BOOST_NOEXCEPT_OR_NOTHROW
- { this->m_size += static_cast<stored_size_type>(s); }
+ { this->m_size = static_cast<stored_size_type>(this->m_size + s); }
BOOST_CONTAINER_FORCEINLINE void priv_first_allocation(size_type cap)
{
if(cap > allocator_type::internal_capacity){
on_capacity_overflow();
}
}
BOOST_CONTAINER_FORCEINLINE void deep_swap(vector_alloc_holder &x)
- {
- this->priv_deep_swap(x);
- }
+ { this->priv_deep_swap(x); }
template<class OtherAllocator, class OtherStoredSizeType, class OtherAllocatorVersion>
void deep_swap(vector_alloc_holder<OtherAllocator, OtherStoredSizeType, OtherAllocatorVersion> &x)
{
typedef typename real_allocator<value_type, OtherAllocator>::type other_allocator_type;
@@ -677,11 +680,10 @@
BOOST_CONTAINER_FORCEINLINE void swap_resources(vector_alloc_holder &) BOOST_NOEXCEPT_OR_NOTHROW
{ //Containers with version 0 allocators can't be moved without moving elements one by one
on_capacity_overflow();
}
-
BOOST_CONTAINER_FORCEINLINE void steal_resources(vector_alloc_holder &)
{ //Containers with version 0 allocators can't be moved without moving elements one by one
on_capacity_overflow();
}
@@ -811,24 +813,24 @@
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
private:
BOOST_COPYABLE_AND_MOVABLE(vector)
typedef vector_value_traits<allocator_type> value_traits;
- typedef constant_iterator<T, difference_type> cvalue_iterator;
+ typedef constant_iterator<T> cvalue_iterator;
protected:
BOOST_CONTAINER_FORCEINLINE void steal_resources(vector &x)
{ return this->m_holder.steal_resources(x.m_holder); }
template<class AllocFwd>
- BOOST_CONTAINER_FORCEINLINE vector(initial_capacity_t, pointer initial_memory, size_type capacity, BOOST_FWD_REF(AllocFwd) a)
- : m_holder(initial_capacity_t(), initial_memory, capacity, ::boost::forward<AllocFwd>(a))
+ BOOST_CONTAINER_FORCEINLINE vector(initial_capacity_t, pointer initial_memory, size_type cap, BOOST_FWD_REF(AllocFwd) a)
+ : m_holder(initial_capacity_t(), initial_memory, cap, ::boost::forward<AllocFwd>(a))
{}
- BOOST_CONTAINER_FORCEINLINE vector(initial_capacity_t, pointer initial_memory, size_type capacity)
- : m_holder(initial_capacity_t(), initial_memory, capacity)
+ BOOST_CONTAINER_FORCEINLINE vector(initial_capacity_t, pointer initial_memory, size_type cap)
+ : m_holder(initial_capacity_t(), initial_memory, cap)
{}
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
public:
@@ -1288,13 +1290,14 @@
BOOST_MOVE_I dtl::is_convertible<FwdIt BOOST_MOVE_I size_type>
BOOST_MOVE_I dtl::is_input_iterator<FwdIt>
>::type * = 0)
)
{
+ typedef typename iter_size<FwdIt>::type it_size_type;
//For Fwd iterators the standard only requires EmplaceConstructible and assignable from *first
//so we can't do any backwards allocation
- const typename iterator_traits<FwdIt>::size_type sz = boost::container::iterator_distance(first, last);
+ const it_size_type sz = boost::container::iterator_udistance(first, last);
if (sz > size_type(-1)){
boost::container::throw_length_error("vector::assign, FwdIt's max length reached");
}
const size_type input_sz = static_cast<size_type>(sz);
@@ -1398,11 +1401,11 @@
//!
//! <b>Complexity</b>: Constant.
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE iterator end() BOOST_NOEXCEPT_OR_NOTHROW
{
iterator it (this->m_holder.start());
- it += this->m_holder.m_size;
+ it += difference_type(this->m_holder.m_size);
return it; //Adding zero to null pointer is allowed (non-UB)
}
//! <b>Effects</b>: Returns a const_iterator to the end of the vector.
//!
@@ -1462,11 +1465,11 @@
//!
//! <b>Complexity</b>: Constant.
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW
{
const_iterator it (this->m_holder.start());
- it += this->m_holder.m_size;
+ it += difference_type(this->m_holder.m_size);
return it; //Adding zero to null pointer is allowed (non-UB)
}
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
//! of the reversed vector.
@@ -1619,11 +1622,11 @@
//!
//! <b>Complexity</b>: Constant.
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE reference back() BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(!this->empty());
- return this->m_holder.start()[this->m_holder.m_size - 1];
+ return this->m_holder.start()[difference_type(this->m_holder.m_size - 1u)];
}
//! <b>Requires</b>: !empty()
//!
//! <b>Effects</b>: Returns a const reference to the last
@@ -1647,11 +1650,11 @@
//!
//! <b>Complexity</b>: Constant.
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE reference operator[](size_type n) BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(this->m_holder.m_size > n);
- return this->m_holder.start()[n];
+ return this->m_holder.start()[difference_type(n)];
}
//! <b>Requires</b>: size() > n.
//!
//! <b>Effects</b>: Returns a const reference to the nth element
@@ -1680,11 +1683,11 @@
//! <b>Note</b>: Non-standard extension
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(this->m_holder.m_size >= n);
- return iterator(this->m_holder.start()+n);
+ return iterator(this->m_holder.start()+difference_type(n));
}
//! <b>Requires</b>: size() >= n.
//!
//! <b>Effects</b>: Returns a const_iterator to the nth element
@@ -1698,11 +1701,11 @@
//! <b>Note</b>: Non-standard extension
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(this->m_holder.m_size >= n);
- return const_iterator(this->m_holder.start()+n);
+ return const_iterator(this->m_holder.start()+difference_type(n));
}
//! <b>Requires</b>: begin() <= p <= end().
//!
//! <b>Effects</b>: Returns the index of the element pointed by p
@@ -1746,11 +1749,11 @@
//!
//! <b>Complexity</b>: Constant.
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE reference at(size_type n)
{
this->priv_throw_if_out_of_range(n);
- return this->m_holder.start()[n];
+ return this->m_holder.start()[difference_type(n)];
}
//! <b>Requires</b>: size() > n.
//!
//! <b>Effects</b>: Returns a const reference to the nth element
@@ -1988,17 +1991,17 @@
>::type * = 0
#endif
)
{
BOOST_ASSERT(this->priv_in_range_or_end(pos));
- const size_type n_pos = pos - this->cbegin();
+ const size_type n_pos = size_type(pos - this->cbegin());
iterator it(vector_iterator_get_ptr(pos));
for(;first != last; ++first){
it = this->emplace(it, *first);
++it;
}
- return iterator(this->m_holder.start() + n_pos);
+ return iterator(this->m_holder.start() + difference_type(n_pos));
}
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
template <class FwdIt>
BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator pos, FwdIt first, FwdIt last
@@ -2007,12 +2010,13 @@
, dtl::is_convertible<FwdIt, size_type>
, dtl::is_input_iterator<FwdIt>
>::type * = 0
)
{
+ typedef typename iter_size<FwdIt>::type it_size_type;
BOOST_ASSERT(this->priv_in_range_or_end(pos));
- const typename iterator_traits<FwdIt>::size_type sz = boost::container::iterator_distance(first, last);
+ const it_size_type sz = boost::container::iterator_udistance(first, last);
if (sz > size_type(-1)){
boost::container::throw_length_error("vector::insert, FwdIt's max length reached");
}
dtl::insert_range_proxy<allocator_type, FwdIt, T*> proxy(first);
@@ -2039,11 +2043,11 @@
template <class InIt>
BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator pos, size_type num, InIt first, InIt last)
{
BOOST_ASSERT(this->priv_in_range_or_end(pos));
BOOST_ASSERT(dtl::is_input_iterator<InIt>::value ||
- num == static_cast<size_type>(boost::container::iterator_distance(first, last)));
+ num == boost::container::iterator_udistance(first, last));
(void)last;
dtl::insert_range_proxy<allocator_type, InIt, T*> proxy(first);
return this->priv_insert_forward_range(vector_iterator_get_ptr(pos), num, proxy);
}
#endif
@@ -2221,11 +2225,11 @@
//!
//! <b>Note</b>: Non-standard extension.
bool stable_reserve(size_type new_cap)
{
const size_type cp = this->capacity();
- return cp >= new_cap || (alloc_version::value == 2 && this->m_holder.try_expand_fwd(new_cap - cp));
+ return cp >= new_cap || (alloc_version::value == 2 && this->m_holder.try_expand_fwd(size_type(new_cap - cp)));
}
//Absolutely experimental. This function might change, disappear or simply crash!
template<class BiDirPosConstIt, class BiDirValueIt>
BOOST_CONTAINER_FORCEINLINE void insert_ordered_at(const size_type element_count, BiDirPosConstIt last_position_it, BiDirValueIt last_value_it)
@@ -2245,11 +2249,11 @@
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 = static_cast<size_type>(boost::container::iterator_distance(first, last)))){
+ 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();
@@ -2431,16 +2435,16 @@
BOOST_CONTAINER_FORCEINLINE bool room_enough() const
{ return this->m_holder.m_size != this->m_holder.capacity(); }
BOOST_CONTAINER_FORCEINLINE pointer back_ptr() const
- { return this->m_holder.start() + this->m_holder.m_size; }
+ { return this->m_holder.start() + difference_type(this->m_holder.m_size); }
BOOST_CONTAINER_FORCEINLINE size_type priv_index_of(pointer p) const
{
BOOST_ASSERT(this->m_holder.start() <= p);
- BOOST_ASSERT(p <= (this->m_holder.start()+this->size()));
+ BOOST_ASSERT(p <= (this->m_holder.start()+difference_type(this->size())));
return static_cast<size_type>(p - this->m_holder.start());
}
template<class OtherA>
void priv_move_assign(BOOST_RV_REF_BEG vector<T, OtherA, Options> BOOST_RV_REF_END x
@@ -2543,35 +2547,44 @@
template<class Vector> //Template it to avoid it in explicit instantiations
void priv_swap(Vector &x, dtl::false_type) //version_N
{
const bool propagate_alloc = allocator_traits_type::propagate_on_container_swap::value;
- if(are_swap_propagable( this->get_stored_allocator(), this->m_holder.start()
- , x.get_stored_allocator(), x.m_holder.start(), propagate_alloc)){
+ if (BOOST_UNLIKELY(&x == this)){
+ return;
+ }
+ else if(are_swap_propagable( this->get_stored_allocator(), this->m_holder.start()
+ , x.get_stored_allocator(), x.m_holder.start(), propagate_alloc)){
//Just swap internals
this->m_holder.swap_resources(x.m_holder);
}
else{
- if (BOOST_UNLIKELY(&x == this))
- return;
-
//Else swap element by element...
bool const t_smaller = this->size() < x.size();
vector &sml = t_smaller ? *this : x;
vector &big = t_smaller ? x : *this;
- size_type const common_elements = sml.size();
- for(size_type i = 0; i != common_elements; ++i){
- boost::adl_move_swap(sml[i], big[i]);
+ //For empty containers, maybe storage can be moved from the other (just like in the move constructor)
+ if(sml.empty() && is_propagable_from(big.get_stored_allocator(), big.data(), sml.get_allocator(), propagate_alloc)){
+ if(BOOST_LIKELY(0u != sml.capacity()))
+ sml.m_holder.deallocate(sml.m_holder.m_start, sml.m_holder.m_capacity);
+ sml.steal_resources(big);
}
- //... and move-insert the remaining range
- sml.insert( sml.cend()
- , boost::make_move_iterator(boost::movelib::iterator_to_raw_pointer(big.nth(common_elements)))
- , boost::make_move_iterator(boost::movelib::iterator_to_raw_pointer(big.end()))
- );
- //Destroy remaining elements
- big.erase(big.nth(common_elements), big.cend());
+ else {
+ //Else swap element by element...
+ size_type const common_elements = sml.size();
+ for(size_type i = 0; i != common_elements; ++i){
+ boost::adl_move_swap(sml[i], big[i]);
+ }
+ //... and move-insert the remaining range
+ sml.insert( sml.cend()
+ , boost::make_move_iterator(boost::movelib::iterator_to_raw_pointer(big.nth(common_elements)))
+ , boost::make_move_iterator(boost::movelib::iterator_to_raw_pointer(big.end()))
+ );
+ //Destroy remaining elements
+ big.erase(big.nth(common_elements), big.cend());
+ }
}
//And now swap the allocator
dtl::swap_alloc(this->m_holder.alloc(), x.m_holder.alloc(), dtl::bool_<propagate_alloc>());
}
@@ -2620,11 +2633,11 @@
if(reuse){ //Backwards (and possibly forward) expansion
#ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
++this->num_expand_bwd;
#endif
this->priv_insert_forward_range_expand_backwards
- ( new_mem , real_cap, ins_pos, 0, this->priv_dummy_empty_proxy());
+ ( new_mem, real_cap, ins_pos, 0, this->priv_dummy_empty_proxy());
}
else{ //New buffer
#ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
++this->num_alloc;
#endif
@@ -2748,26 +2761,26 @@
T * const new_buf = boost::movelib::to_raw_pointer(this->m_holder.allocate(new_cap));
#ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
++this->num_alloc;
#endif
this->priv_insert_forward_range_new_allocation(new_buf, new_cap, raw_pos, n, insert_range_proxy);
- return iterator(this->m_holder.start() + n_pos);
+ return iterator(this->m_holder.start() + difference_type(n_pos));
}
template <class InsertionProxy>
BOOST_CONTAINER_NOINLINE iterator priv_insert_forward_range_no_capacity
(T *const raw_pos, const size_type n, const InsertionProxy insert_range_proxy, version_2)
{
//Check if we have enough memory or try to expand current memory
- const size_type n_pos = raw_pos - this->priv_raw_begin();
+ const size_type n_pos = size_type(raw_pos - this->priv_raw_begin());
//There is not enough memory, allocate a new
//buffer or expand the old one.
size_type real_cap = this->m_holder.template next_capacity<growth_factor_type>(n);
pointer reuse(this->m_holder.start());
pointer const ret (this->m_holder.allocation_command
- (allocate_new | expand_fwd | expand_bwd, this->m_holder.m_size + n, real_cap, reuse));
+ (allocate_new | expand_fwd | expand_bwd, size_type(this->m_holder.m_size + n), real_cap, reuse));
//Buffer reallocated
if(reuse){
//Forward expansion, delay insertion
if(this->m_holder.start() == ret){
@@ -2795,11 +2808,11 @@
#endif
this->priv_insert_forward_range_new_allocation
( boost::movelib::to_raw_pointer(ret), real_cap, raw_pos, n, insert_range_proxy);
}
- return iterator(this->m_holder.start() + n_pos);
+ return iterator(this->m_holder.start() + (difference_type)(n_pos));
}
template <class InsertionProxy>
BOOST_CONTAINER_FORCEINLINE iterator priv_insert_forward_range
(const pointer &pos, const size_type n, const InsertionProxy insert_range_proxy)
@@ -2841,14 +2854,14 @@
void priv_resize(const size_type new_size, const U &u, AllocVersion)
{
const size_type sz = this->m_holder.m_size;
if (new_size < sz){
//Destroy last elements
- this->priv_destroy_last_n(sz - new_size);
+ this->priv_destroy_last_n(size_type(sz - new_size));
}
else {
- this->priv_insert_forward_range(this->back_ptr(), new_size - sz, this->priv_resize_proxy(u));
+ this->priv_insert_forward_range(this->back_ptr(), size_type(new_size - sz), this->priv_resize_proxy(u));
}
}
//Takes the range pointed by [first_pos, last_pos) and shifts it to the right
//by 'shift_count'. 'limit_pos' marks the end of constructed elements.
@@ -2920,11 +2933,13 @@
//Case B:
else if((first_pos + shift_count) >= limit_pos){
//All uninitialized_moved
::boost::container::uninitialized_move_alloc
(this->m_holder.alloc(), first_ptr, last_ptr, first_ptr + shift_count);
- hole_size = first_pos + shift_count - limit_pos;
+ //Cast in case size_type is narrower than int, promotions are applied
+ //and Wconversion is in place
+ hole_size = static_cast<size_type>(first_pos + shift_count - limit_pos);
}
//Case C:
else{
//Some uninitialized_moved
T* const limit_ptr = begin_ptr + limit_pos;
@@ -3022,11 +3037,11 @@
this->m_holder.m_size = 0;
//We can have 8 possibilities:
const size_type elemsbefore = static_cast<size_type>(pos - old_start);
const size_type s_before = static_cast<size_type>(old_start - new_start);
- const size_type before_plus_new = elemsbefore + n;
+ const size_type before_plus_new = size_type(elemsbefore + n);
typedef typename value_traits::ArrayDestructor array_destructor_t;
//If anything goes wrong, this object will destroy
//all the old objects to fulfill previous vector state
@@ -3037,11 +3052,11 @@
T *const new_elem_pos =
::boost::container::uninitialized_move_alloc(a, old_start, pos, new_start);
this->m_holder.set_stored_size(elemsbefore);
insert_range_proxy.uninitialized_copy_n_and_update(a, new_elem_pos, n);
this->m_holder.set_stored_size(before_plus_new);
- const size_type new_size = old_size + n;
+ const size_type new_size = size_type(old_size + n);
//Check if s_before is so big that even copying the old data + new data
//there is a gap between the new data and the old data
if(s_before >= new_size){
//Old situation:
// _________________________________________________________
@@ -3172,11 +3187,11 @@
}
else{
old_values_destroyer.shrink_forward(old_size - (s_before - n));
}
}
- this->m_holder.set_stored_size(old_size + new_1st_range);
+ this->m_holder.set_stored_size(size_type(old_size + new_1st_range));
//Now copy the second part of old_begin overwriting itself
T *const next = ::boost::container::move(old_start + s_before, pos, old_start);
//Now copy the new_beg elements
insert_range_proxy.copy_n_and_update(a, next, new_1st_range);
@@ -3214,35 +3229,35 @@
//
//First copy whole old_begin and part of new to raw_mem
T * const new_pos = ::boost::container::uninitialized_move_alloc
(a, old_start, pos, new_start);
this->m_holder.set_stored_size(elemsbefore);
- const size_type mid_n = s_before - elemsbefore;
+ const size_type mid_n = size_type(s_before - elemsbefore);
insert_range_proxy.uninitialized_copy_n_and_update(a, new_pos, mid_n);
//The buffer is all constructed until old_end,
//release destroyer
- this->m_holder.set_stored_size(old_size + s_before);
+ this->m_holder.set_stored_size(size_type(old_size + s_before));
old_values_destroyer.release();
if(do_after){
//Copy new_beg part
insert_range_proxy.copy_n_and_update(a, old_start, elemsbefore);
}
else{
//Copy all new elements
- const size_type rest_new = n - mid_n;
+ const size_type rest_new = size_type(n - mid_n);
insert_range_proxy.copy_n_and_update(a, old_start, rest_new);
T* const move_start = old_start + rest_new;
//Displace old_end, but make sure data has to be moved
T* const move_end = move_start != pos ? ::boost::container::move(pos, old_finish, move_start)
: old_finish;
(void)move_end; //To avoid warnings of unused initialization for move_end in case
//trivial_dctr_after_move is true
//Destroy remaining moved elements from old_end except if they
//have trivial destructor after being moved
- const size_type n_destroy = s_before - n;
+ const size_type n_destroy = size_type(s_before - n);
BOOST_IF_CONSTEXPR(!value_traits::trivial_dctr_after_move){
boost::container::destroy_alloc_n(a, move_end, n_destroy);
}
this->m_holder.dec_stored_size(n_destroy);
}
@@ -3265,12 +3280,12 @@
//New situation with do_after(2):
// ______________________________________________________
//| old_begin + new | old_end |raw |
//|_______________________________________|_________|____|
//
- const size_type n_after = n - s_before;
- const size_type elemsafter = old_size - elemsbefore;
+ const size_type n_after = size_type(n - s_before);
+ const size_type elemsafter = size_type(old_size - elemsbefore);
//We can have two situations:
if (elemsafter >= n_after){
//The raw_mem from end will divide displaced old_end
//
@@ -3306,11 +3321,11 @@
// _____________________________________________________________
//| old_begin + new_beg | new_end |old_end | raw_mem |
//|__________________________|_______________|________|_________|
//First initialize data in raw memory
- const size_type mid_last_dist = n_after - elemsafter;
+ const size_type mid_last_dist = size_type(n_after - elemsafter);
//Copy to the old_end part to the uninitialized zone leaving a gap.
::boost::container::uninitialized_move_alloc(a, pos, old_finish, old_finish + mid_last_dist);
array_destructor_t old_end_destroyer(old_finish + mid_last_dist, a, static_cast<size_type>(old_finish - pos));
@@ -3358,14 +3373,14 @@
#ifndef BOOST_CONTAINER_NO_CXX17_CTAD
template <typename InputIterator>
vector(InputIterator, InputIterator) ->
- vector<typename iterator_traits<InputIterator>::value_type>;
+ vector<typename iter_value<InputIterator>::type>;
template <typename InputIterator, typename Allocator>
vector(InputIterator, InputIterator, Allocator const&) ->
- vector<typename iterator_traits<InputIterator>::value_type, Allocator>;
+ vector<typename iter_value<InputIterator>::type, Allocator>;
#endif
}} //namespace boost::container