Support GCC's -Wconversion -Wfloat-conversion -Warith-conversion -Wsign-conversion warnings.

This commit is contained in:
Ion Gaztañaga
2021-10-16 15:57:47 +02:00
parent 883868e6b2
commit dad2cb2d02
42 changed files with 813 additions and 754 deletions

View File

@@ -114,6 +114,7 @@ class deque_iterator
typedef std::random_access_iterator_tag iterator_category;
typedef typename boost::intrusive::pointer_traits<Pointer>::element_type value_type;
typedef typename boost::intrusive::pointer_traits<Pointer>::difference_type difference_type;
typedef typename boost::intrusive::pointer_traits<Pointer>::size_type size_type;
typedef typename if_c
< IsConst
, typename boost::intrusive::pointer_traits<Pointer>::template
@@ -151,6 +152,10 @@ class deque_iterator
: m_cur(x), m_first(*y), m_last(*y + block_size), m_node(y)
{}
BOOST_CONTAINER_FORCEINLINE deque_iterator(val_alloc_ptr x, index_pointer y, size_type block_size) BOOST_NOEXCEPT_OR_NOTHROW
: m_cur(x), m_first(*y), m_last(*y + difference_type(block_size)), m_node(y)
{}
BOOST_CONTAINER_FORCEINLINE deque_iterator() BOOST_NOEXCEPT_OR_NOTHROW
: m_cur(), m_first(), m_last(), m_node() //Value initialization to achieve "null iterators" (N3644)
{}
@@ -186,7 +191,7 @@ class deque_iterator
if(!this->m_cur && !x.m_cur){
return 0;
}
const difference_type block_size = this->m_last - this->m_first;
const difference_type block_size = m_last - m_first;
BOOST_ASSERT(block_size);
return block_size * (this->m_node - x.m_node - 1) +
(this->m_cur - this->m_first) + (x.m_last - x.m_cur);
@@ -238,15 +243,15 @@ class deque_iterator
return *this;
BOOST_ASSERT(!!m_cur);
difference_type offset = n + (this->m_cur - this->m_first);
const difference_type block_size = this->m_last - this->m_first;
const difference_type block_size = m_last - m_first;
BOOST_ASSERT(block_size);
if (offset >= 0 && offset < block_size)
this->m_cur += n;
this->m_cur += difference_type(n);
else {
difference_type node_offset =
offset > 0 ? (offset / block_size)
: (-difference_type((-offset - 1) / block_size) - 1);
this->priv_set_node(this->m_node + node_offset, block_size);
this->priv_set_node(this->m_node + node_offset, size_type(block_size));
this->m_cur = this->m_first +
(offset - node_offset * block_size);
}
@@ -269,6 +274,7 @@ class deque_iterator
reference operator[](difference_type n) const BOOST_NOEXCEPT_OR_NOTHROW
{ return *(*this + n); }
//Comparisons
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
friend bool operator==(const deque_iterator& l, const deque_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW
{ return l.m_cur == r.m_cur; }
@@ -297,6 +303,9 @@ class deque_iterator
friend deque_iterator operator+(difference_type n, deque_iterator x) BOOST_NOEXCEPT_OR_NOTHROW
{ return x += n; }
BOOST_CONTAINER_FORCEINLINE void priv_set_node(index_pointer new_node, size_type block_size) BOOST_NOEXCEPT_OR_NOTHROW
{ return this->priv_set_node(new_node, difference_type(block_size)); }
BOOST_CONTAINER_FORCEINLINE void priv_set_node(index_pointer new_node, difference_type block_size) BOOST_NOEXCEPT_OR_NOTHROW
{
this->m_node = new_node;
@@ -346,6 +355,7 @@ class deque_base
typedef Allocator allocator_type;
typedef allocator_type stored_allocator_type;
typedef val_alloc_size size_type;
typedef val_alloc_diff difference_type;
private:
typedef typename get_deque_opt<Options>::type options_type;
@@ -357,6 +367,9 @@ class deque_base
BOOST_CONSTEXPR BOOST_CONTAINER_FORCEINLINE static size_type get_block_size() BOOST_NOEXCEPT_OR_NOTHROW
{ return deque_block_size<val_alloc_val, options_type::block_bytes, options_type::block_size>::value; }
BOOST_CONSTEXPR BOOST_CONTAINER_FORCEINLINE static val_alloc_diff get_block_ssize() BOOST_NOEXCEPT_OR_NOTHROW
{ return val_alloc_diff((get_block_size)()); }
typedef deque_value_traits<val_alloc_val> traits_t;
typedef ptr_alloc_t map_allocator_type;
@@ -418,8 +431,8 @@ class deque_base
this->members_.m_map_size = dtl::max_value((size_type) InitialMapSize, num_nodes + 2);
this->members_.m_map = this->priv_allocate_map(this->members_.m_map_size);
ptr_alloc_ptr nstart = this->members_.m_map + (this->members_.m_map_size - num_nodes) / 2;
ptr_alloc_ptr nfinish = nstart + num_nodes;
ptr_alloc_ptr nstart = this->members_.m_map + difference_type(this->members_.m_map_size - num_nodes) / 2;
ptr_alloc_ptr nfinish = nstart + difference_type(num_nodes);
BOOST_TRY {
this->priv_create_nodes(nstart, nfinish);
@@ -435,8 +448,7 @@ class deque_base
this->members_.m_start.priv_set_node(nstart, get_block_size());
this->members_.m_finish.priv_set_node(nfinish - 1, get_block_size());
this->members_.m_start.m_cur = this->members_.m_start.m_first;
this->members_.m_finish.m_cur = this->members_.m_finish.m_first +
num_elements % get_block_size();
this->members_.m_finish.m_cur = this->members_.m_finish.m_first + difference_type(num_elements % get_block_size());
// }
}
@@ -538,6 +550,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
typedef deque_base<typename real_allocator<T, Allocator>::type, Options> Base;
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
typedef typename real_allocator<T, Allocator>::type ValAllocator;
typedef constant_iterator<T> c_it;
public:
@@ -570,10 +583,12 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
using Base::get_block_ssize;
public:
BOOST_CONSTEXPR BOOST_CONTAINER_FORCEINLINE static size_type get_block_size() BOOST_NOEXCEPT_OR_NOTHROW
{ return Base::get_block_size(); }
using Base::get_block_size;
//////////////////////////////////////////////
//
@@ -903,7 +918,6 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
//! <b>Complexity</b>: Linear to n.
BOOST_CONTAINER_FORCEINLINE void assign(size_type n, const T& val)
{
typedef constant_iterator<value_type, difference_type> c_it;
this->assign(c_it(val, n), c_it());
}
@@ -946,10 +960,10 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
>::type * = 0
)
{
const size_type len = boost::container::iterator_distance(first, last);
const size_type len = boost::container::iterator_udistance(first, last);
if (len > size()) {
FwdIt mid = first;
boost::container::iterator_advance(mid, this->size());
boost::container::iterator_uadvance(mid, this->size());
boost::container::copy(first, mid, begin());
this->insert(this->cend(), mid, last);
}
@@ -1143,7 +1157,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
//! <b>Complexity</b>: Constant.
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
size_type size() const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->members_.m_finish - this->members_.m_start; }
{ return size_type(this->members_.m_finish - this->members_.m_start); }
//! <b>Effects</b>: Returns the largest possible size of the deque.
//!
@@ -1202,7 +1216,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
{
const size_type len = size();
if (new_size < len)
this->erase(this->members_.m_start + new_size, this->members_.m_finish);
this->erase(this->members_.m_start + difference_type(new_size), this->members_.m_finish);
else
this->insert(this->members_.m_finish, new_size - len, x);
}
@@ -1335,7 +1349,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(this->size() >= n);
return iterator(this->begin()+n);
return iterator(this->begin()+difference_type(n));
}
//! <b>Requires</b>: size() >= n.
@@ -1353,7 +1367,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(this->size() >= n);
return const_iterator(this->cbegin()+n);
return const_iterator(this->cbegin()+difference_type(n));
}
//! <b>Requires</b>: begin() <= p <= end().
@@ -1649,7 +1663,6 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator pos, size_type n, const value_type& x)
{
//Range check of p is done by insert()
typedef constant_iterator<value_type, difference_type> c_it;
return this->insert(pos, c_it(x, n), c_it());
}
@@ -1681,7 +1694,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
it = this->emplace(it, *first);
++it;
}
it -= n;
it -= difference_type(n);
return it;
}
@@ -1717,7 +1730,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
{
BOOST_ASSERT(this->priv_in_range_or_end(p));
dtl::insert_range_proxy<ValAllocator, FwdIt, iterator> proxy(first);
return priv_insert_aux_impl(p, boost::container::iterator_distance(first, last), proxy);
return priv_insert_aux_impl(p, boost::container::iterator_udistance(first, last), proxy);
}
#endif
@@ -1772,7 +1785,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
BOOST_ASSERT(this->priv_in_range(pos));
iterator next = pos.unconst();
++next;
size_type index = pos - this->members_.m_start;
size_type index = size_type(pos - this->members_.m_start);
if (index < (this->size()/2)) {
boost::container::move_backward(this->begin(), pos.unconst(), next);
pop_front();
@@ -1781,7 +1794,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
boost::container::move(next, this->end(), pos.unconst());
pop_back();
}
return this->members_.m_start + index;
return this->members_.m_start + difference_type(index);
}
//! <b>Effects</b>: Erases the elements pointed by [first, last).
@@ -1805,19 +1818,19 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
const size_type elems_before = static_cast<size_type>(first - this->members_.m_start);
if (elems_before < (this->size() - n) - elems_before) {
boost::container::move_backward(begin(), first.unconst(), last.unconst());
iterator new_start = this->members_.m_start + n;
iterator new_start = this->members_.m_start + difference_type(n);
this->priv_destroy_range(this->members_.m_start, new_start);
this->priv_destroy_nodes(this->members_.m_start.m_node, new_start.m_node);
this->members_.m_start = new_start;
}
else {
boost::container::move(last.unconst(), end(), first.unconst());
iterator new_finish = this->members_.m_finish - n;
iterator new_finish = this->members_.m_finish - difference_type(n);
this->priv_destroy_range(new_finish, this->members_.m_finish);
this->priv_destroy_nodes(new_finish.m_node + 1, this->members_.m_finish.m_node + 1);
this->members_.m_finish = new_finish;
}
return this->members_.m_start + elems_before;
return this->members_.m_start + difference_type(elems_before);
}
}
@@ -1848,7 +1861,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
for (index_pointer node = this->members_.m_start.m_node + 1;
node < this->members_.m_finish.m_node;
++node) {
this->priv_destroy_range(*node, *node + get_block_size());
this->priv_destroy_range(*node, *node + get_block_ssize());
this->priv_deallocate_node(*node);
}
@@ -1929,7 +1942,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
this->clear();
}
else {
iterator new_finish = this->members_.m_finish - n;
iterator new_finish = this->members_.m_finish - difference_type(n);
this->priv_destroy_range(new_finish, this->members_.m_finish);
this->priv_destroy_nodes(new_finish.m_node + 1, this->members_.m_finish.m_node + 1);
this->members_.m_finish = new_finish;
@@ -2051,7 +2064,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
iterator priv_insert_aux_impl(const_iterator p, size_type n, InsertProxy proxy)
{
iterator pos(p.unconst());
const size_type pos_n = p - this->cbegin();
const size_type pos_n = size_type(p - this->cbegin());
if(!this->members_.m_map){
this->priv_initialize_map(0);
pos = this->begin();
@@ -2067,18 +2080,18 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
this->members_.m_start = new_start;
}
else{
pos = this->members_.m_start + elemsbefore;
pos = this->members_.m_start + difference_type(elemsbefore);
if (elemsbefore >= n) {
const iterator start_n = this->members_.m_start + n;
const iterator start_n = this->members_.m_start + difference_type(n);
::boost::container::uninitialized_move_alloc
(this->alloc(), this->members_.m_start, start_n, new_start);
this->members_.m_start = new_start;
boost::container::move(start_n, pos, old_start);
proxy.copy_n_and_update(this->alloc(), pos - n, n);
proxy.copy_n_and_update(this->alloc(), pos - difference_type(n), n);
}
else {
const size_type mid_count = n - elemsbefore;
const iterator mid_start = old_start - mid_count;
const iterator mid_start = old_start - difference_type(mid_count);
proxy.uninitialized_copy_n_and_update(this->alloc(), mid_start, mid_count);
this->members_.m_start = mid_start;
::boost::container::uninitialized_move_alloc
@@ -2097,7 +2110,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
this->members_.m_finish = new_finish;
}
else{
pos = old_finish - elemsafter;
pos = old_finish - difference_type(elemsafter);
if (elemsafter >= n) {
iterator finish_n = old_finish - difference_type(n);
::boost::container::uninitialized_move_alloc
@@ -2109,13 +2122,13 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
else {
const size_type raw_gap = n - elemsafter;
::boost::container::uninitialized_move_alloc
(this->alloc(), pos, old_finish, old_finish + raw_gap);
(this->alloc(), pos, old_finish, old_finish + difference_type(raw_gap));
BOOST_TRY{
proxy.copy_n_and_update(this->alloc(), pos, elemsafter);
proxy.uninitialized_copy_n_and_update(this->alloc(), old_finish, raw_gap);
}
BOOST_CATCH(...){
this->priv_destroy_range(old_finish, old_finish + elemsafter);
this->priv_destroy_range(old_finish, old_finish + difference_type(elemsafter));
BOOST_RETHROW
}
BOOST_CATCH_END
@@ -2123,7 +2136,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
}
}
}
return this->begin() + pos_n;
return this->begin() + difference_type(pos_n);
}
template <class InsertProxy>
@@ -2137,7 +2150,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
iterator old_finish = this->members_.m_finish;
proxy.uninitialized_copy_n_and_update(this->alloc(), old_finish, n);
this->members_.m_finish = new_finish;
return iterator(this->members_.m_finish - n);
return iterator(this->members_.m_finish - difference_type(n));
}
template <class InsertProxy>
@@ -2155,7 +2168,6 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
BOOST_CONTAINER_FORCEINLINE iterator priv_fill_insert(const_iterator pos, size_type n, const value_type& x)
{
typedef constant_iterator<value_type, difference_type> c_it;
return this->insert(pos, c_it(x, n), c_it());
}
@@ -2167,7 +2179,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
BOOST_TRY {
for ( ; cur < this->members_.m_finish.m_node; ++cur){
boost::container::uninitialized_fill_alloc
(this->alloc(), *cur, *cur + get_block_size(), value);
(this->alloc(), *cur, *cur + get_block_ssize(), value);
}
boost::container::uninitialized_fill_alloc
(this->alloc(), this->members_.m_finish.m_first, this->members_.m_finish.m_cur, value);
@@ -2198,14 +2210,14 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
void priv_range_initialize(FwdIt first, FwdIt last, typename iterator_disable_if_tag<FwdIt, std::input_iterator_tag>::type* =0)
{
size_type n = 0;
n = boost::container::iterator_distance(first, last);
n = boost::container::iterator_udistance(first, last);
this->priv_initialize_map(n);
index_pointer cur_node = this->members_.m_start.m_node;
BOOST_TRY {
for (; cur_node < this->members_.m_finish.m_node; ++cur_node) {
FwdIt mid = first;
boost::container::iterator_advance(mid, get_block_size());
boost::container::iterator_uadvance(mid, get_block_size());
::boost::container::uninitialized_copy_alloc(this->alloc(), first, mid, *cur_node);
first = mid;
}
@@ -2247,11 +2259,10 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
iterator priv_reserve_elements_at_front(size_type n)
{
size_type vacancies = this->members_.m_start.m_cur - this->members_.m_start.m_first;
size_type vacancies = size_type(this->members_.m_start.m_cur - this->members_.m_start.m_first);
if (n > vacancies){
size_type new_elems = n-vacancies;
size_type new_nodes = (new_elems + get_block_size() - 1) /
get_block_size();
size_type new_nodes = (new_elems + get_block_size() - 1u) / get_block_size();
size_type s = (size_type)(this->members_.m_start.m_node - this->members_.m_map);
if (new_nodes > s){
this->priv_reallocate_map(new_nodes, true);
@@ -2259,11 +2270,11 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
size_type i = 1;
BOOST_TRY {
for (; i <= new_nodes; ++i)
*(this->members_.m_start.m_node - i) = this->priv_allocate_node();
*(this->members_.m_start.m_node - difference_type(i)) = this->priv_allocate_node();
}
BOOST_CATCH(...) {
for (size_type j = 1; j < i; ++j)
this->priv_deallocate_node(*(this->members_.m_start.m_node - j));
this->priv_deallocate_node(*(this->members_.m_start.m_node - difference_type(j)));
BOOST_RETHROW
}
BOOST_CATCH_END
@@ -2273,22 +2284,22 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
iterator priv_reserve_elements_at_back(size_type n)
{
size_type vacancies = (this->members_.m_finish.m_last - this->members_.m_finish.m_cur) - 1;
size_type vacancies = size_type(this->members_.m_finish.m_last - this->members_.m_finish.m_cur - 1);
if (n > vacancies){
size_type new_elems = n - vacancies;
size_type new_nodes = (new_elems + get_block_size() - 1)/get_block_size();
size_type s = (size_type)(this->members_.m_map_size - (this->members_.m_finish.m_node - this->members_.m_map));
size_type new_elems = size_type(n - vacancies);
size_type new_nodes = size_type(new_elems + get_block_size() - 1u)/get_block_size();
size_type s = (size_type)(this->members_.m_map_size - size_type(this->members_.m_finish.m_node - this->members_.m_map));
if (new_nodes + 1 > s){
this->priv_reallocate_map(new_nodes, false);
}
size_type i = 1;
BOOST_TRY {
for (; i <= new_nodes; ++i)
*(this->members_.m_finish.m_node + i) = this->priv_allocate_node();
*(this->members_.m_finish.m_node + difference_type(i)) = this->priv_allocate_node();
}
BOOST_CATCH(...) {
for (size_type j = 1; j < i; ++j)
this->priv_deallocate_node(*(this->members_.m_finish.m_node + j));
this->priv_deallocate_node(*(this->members_.m_finish.m_node + difference_type(j)));
BOOST_RETHROW
}
BOOST_CATCH_END
@@ -2298,26 +2309,26 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
void priv_reallocate_map(size_type nodes_to_add, bool add_at_front)
{
size_type old_num_nodes = this->members_.m_finish.m_node - this->members_.m_start.m_node + 1;
size_type old_num_nodes = size_type(this->members_.m_finish.m_node - this->members_.m_start.m_node + 1);
size_type new_num_nodes = old_num_nodes + nodes_to_add;
index_pointer new_nstart;
if (this->members_.m_map_size > 2 * new_num_nodes) {
new_nstart = this->members_.m_map + (this->members_.m_map_size - new_num_nodes) / 2
+ (add_at_front ? nodes_to_add : 0);
new_nstart = this->members_.m_map + difference_type(this->members_.m_map_size - new_num_nodes) / 2
+ difference_type(add_at_front ? nodes_to_add : 0u);
if (new_nstart < this->members_.m_start.m_node)
boost::container::move(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1, new_nstart);
else
boost::container::move_backward
(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1, new_nstart + old_num_nodes);
(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1, new_nstart + difference_type(old_num_nodes));
}
else {
size_type new_map_size =
this->members_.m_map_size + dtl::max_value(this->members_.m_map_size, nodes_to_add) + 2;
index_pointer new_map = this->priv_allocate_map(new_map_size);
new_nstart = new_map + (new_map_size - new_num_nodes) / 2
+ (add_at_front ? nodes_to_add : 0);
new_nstart = new_map + difference_type(new_map_size - new_num_nodes) / 2
+ difference_type(add_at_front ? nodes_to_add : 0u);
boost::container::move(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1, new_nstart);
this->priv_deallocate_map(this->members_.m_map, this->members_.m_map_size);
@@ -2326,7 +2337,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
}
this->members_.m_start.priv_set_node(new_nstart, get_block_size());
this->members_.m_finish.priv_set_node(new_nstart + old_num_nodes - 1, get_block_size());
this->members_.m_finish.priv_set_node(new_nstart + difference_type(old_num_nodes - 1u), get_block_size());
}
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
};

View File

@@ -535,7 +535,7 @@ class private_adaptive_node_pool_impl_common
//Check that header offsets are correct
hdr_offset_holder *hdr_off_holder = this->priv_first_subblock_from_block(const_cast<block_info_t *>(&*it), num_subblocks, real_block_alignment);
for (size_type i = 0, max = num_subblocks; i < max; ++i) {
const size_type offset = reinterpret_cast<char*>(const_cast<block_info_t *>(&*it)) - reinterpret_cast<char*>(hdr_off_holder);
const size_type offset = size_type(reinterpret_cast<char*>(const_cast<block_info_t *>(&*it)) - reinterpret_cast<char*>(hdr_off_holder));
(void)offset;
BOOST_ASSERT(hdr_off_holder->hdr_offset == offset);
BOOST_ASSERT(0 == (reinterpret_cast<std::size_t>(hdr_off_holder) & (real_block_alignment - 1)));

View File

@@ -46,20 +46,19 @@ namespace boost { namespace container { namespace dtl {
template<class Allocator, class FwdIt, class Iterator>
struct move_insert_range_proxy
{
typedef typename allocator_traits<Allocator>::size_type size_type;
typedef typename allocator_traits<Allocator>::value_type value_type;
BOOST_CONTAINER_FORCEINLINE explicit move_insert_range_proxy(FwdIt first)
: first_(first)
{}
BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n)
BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, std::size_t n)
{
this->first_ = ::boost::container::uninitialized_move_alloc_n_source
(a, this->first_, n, p);
}
BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &, Iterator p, size_type n)
BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &, Iterator p, std::size_t n)
{
this->first_ = ::boost::container::move_n_source(this->first_, n, p);
}
@@ -71,19 +70,18 @@ struct move_insert_range_proxy
template<class Allocator, class FwdIt, class Iterator>
struct insert_range_proxy
{
typedef typename allocator_traits<Allocator>::size_type size_type;
typedef typename allocator_traits<Allocator>::value_type value_type;
BOOST_CONTAINER_FORCEINLINE explicit insert_range_proxy(FwdIt first)
: first_(first)
{}
BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n)
BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, std::size_t n)
{
this->first_ = ::boost::container::uninitialized_copy_alloc_n_source(a, this->first_, n, p);
}
BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &, Iterator p, size_type n)
BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &, Iterator p, std::size_t n)
{
this->first_ = ::boost::container::copy_n_source(this->first_, n, p);
}
@@ -95,17 +93,16 @@ struct insert_range_proxy
template<class Allocator, class Iterator>
struct insert_n_copies_proxy
{
typedef typename allocator_traits<Allocator>::size_type size_type;
typedef typename allocator_traits<Allocator>::value_type value_type;
BOOST_CONTAINER_FORCEINLINE explicit insert_n_copies_proxy(const value_type &v)
: v_(v)
{}
BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const
BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, std::size_t n) const
{ boost::container::uninitialized_fill_alloc_n(a, v_, n, p); }
BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &, Iterator p, size_type n) const
BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &, Iterator p, std::size_t n) const
{
while (n){
--n;
@@ -121,14 +118,13 @@ template<class Allocator, class Iterator>
struct insert_value_initialized_n_proxy
{
typedef ::boost::container::allocator_traits<Allocator> alloc_traits;
typedef typename allocator_traits<Allocator>::size_type size_type;
typedef typename allocator_traits<Allocator>::value_type value_type;
typedef typename dtl::aligned_storage<sizeof(value_type), dtl::alignment_of<value_type>::value>::type storage_t;
BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const
BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, std::size_t n) const
{ boost::container::uninitialized_value_init_alloc_n(a, n, p); }
void copy_n_and_update(Allocator &a, Iterator p, size_type n) const
void copy_n_and_update(Allocator &a, Iterator p, std::size_t n) const
{
while (n){
--n;
@@ -146,14 +142,13 @@ template<class Allocator, class Iterator>
struct insert_default_initialized_n_proxy
{
typedef ::boost::container::allocator_traits<Allocator> alloc_traits;
typedef typename allocator_traits<Allocator>::size_type size_type;
typedef typename allocator_traits<Allocator>::value_type value_type;
typedef typename dtl::aligned_storage<sizeof(value_type), dtl::alignment_of<value_type>::value>::type storage_t;
BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const
BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, std::size_t n) const
{ boost::container::uninitialized_default_init_alloc_n(a, n, p); }
void copy_n_and_update(Allocator &a, Iterator p, size_type n) const
void copy_n_and_update(Allocator &a, Iterator p, std::size_t n) const
{
if(!is_pod<value_type>::value){
while (n){
@@ -173,7 +168,6 @@ template<class Allocator, class Iterator>
struct insert_copy_proxy
{
typedef boost::container::allocator_traits<Allocator> alloc_traits;
typedef typename alloc_traits::size_type size_type;
typedef typename alloc_traits::value_type value_type;
static const bool single_value = true;
@@ -182,13 +176,13 @@ struct insert_copy_proxy
: v_(v)
{}
BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const
BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, std::size_t n) const
{
BOOST_ASSERT(n == 1); (void)n;
alloc_traits::construct( a, boost::movelib::iterator_to_raw_pointer(p), v_);
}
BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &, Iterator p, size_type n) const
BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &, Iterator p, std::size_t n) const
{
BOOST_ASSERT(n == 1); (void)n;
*p = v_;
@@ -202,7 +196,6 @@ template<class Allocator, class Iterator>
struct insert_move_proxy
{
typedef boost::container::allocator_traits<Allocator> alloc_traits;
typedef typename alloc_traits::size_type size_type;
typedef typename alloc_traits::value_type value_type;
static const bool single_value = true;
@@ -211,13 +204,13 @@ struct insert_move_proxy
: v_(v)
{}
BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n) const
BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, std::size_t n) const
{
BOOST_ASSERT(n == 1); (void)n;
alloc_traits::construct( a, boost::movelib::iterator_to_raw_pointer(p), ::boost::move(v_) );
}
BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &, Iterator p, size_type n) const
BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &, Iterator p, std::size_t n) const
{
BOOST_ASSERT(n == 1); (void)n;
*p = ::boost::move(v_);
@@ -253,7 +246,6 @@ template<class Allocator, class Iterator, class ...Args>
struct insert_nonmovable_emplace_proxy
{
typedef boost::container::allocator_traits<Allocator> alloc_traits;
typedef typename alloc_traits::size_type size_type;
typedef typename alloc_traits::value_type value_type;
typedef typename build_number_seq<sizeof...(Args)>::type index_tuple_t;
@@ -263,12 +255,12 @@ struct insert_nonmovable_emplace_proxy
: args_(args...)
{}
BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n)
BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, std::size_t n)
{ this->priv_uninitialized_copy_some_and_update(a, index_tuple_t(), p, n); }
private:
template<std::size_t ...IdxPack>
BOOST_CONTAINER_FORCEINLINE void priv_uninitialized_copy_some_and_update(Allocator &a, const index_tuple<IdxPack...>&, Iterator p, size_type n)
BOOST_CONTAINER_FORCEINLINE void priv_uninitialized_copy_some_and_update(Allocator &a, const index_tuple<IdxPack...>&, Iterator p, std::size_t n)
{
BOOST_ASSERT(n == 1); (void)n;
alloc_traits::construct( a, boost::movelib::iterator_to_raw_pointer(p), ::boost::forward<Args>(get<IdxPack>(this->args_))... );
@@ -285,7 +277,6 @@ struct insert_emplace_proxy
typedef insert_nonmovable_emplace_proxy<Allocator, Iterator, Args...> base_t;
typedef boost::container::allocator_traits<Allocator> alloc_traits;
typedef typename base_t::value_type value_type;
typedef typename base_t::size_type size_type;
typedef typename base_t::index_tuple_t index_tuple_t;
static const bool single_value = true;
@@ -294,13 +285,13 @@ struct insert_emplace_proxy
: base_t(::boost::forward<Args>(args)...)
{}
BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &a, Iterator p, size_type n)
BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &a, Iterator p, std::size_t n)
{ this->priv_copy_some_and_update(a, index_tuple_t(), p, n); }
private:
template<std::size_t ...IdxPack>
BOOST_CONTAINER_FORCEINLINE void priv_copy_some_and_update(Allocator &a, const index_tuple<IdxPack...>&, Iterator p, size_type n)
BOOST_CONTAINER_FORCEINLINE void priv_copy_some_and_update(Allocator &a, const index_tuple<IdxPack...>&, Iterator p, std::size_t n)
{
BOOST_ASSERT(n ==1); (void)n;
typename dtl::aligned_storage<sizeof(value_type), dtl::alignment_of<value_type>::value>::type v;
@@ -386,7 +377,6 @@ template< class Allocator, class Iterator BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\
struct insert_nonmovable_emplace_proxy##N\
{\
typedef boost::container::allocator_traits<Allocator> alloc_traits;\
typedef typename alloc_traits::size_type size_type;\
typedef typename alloc_traits::value_type value_type;\
\
static const bool single_value = true;\
@@ -394,13 +384,13 @@ struct insert_nonmovable_emplace_proxy##N\
BOOST_CONTAINER_FORCEINLINE explicit insert_nonmovable_emplace_proxy##N(BOOST_MOVE_UREF##N)\
BOOST_MOVE_COLON##N BOOST_MOVE_FWD_INIT##N {}\
\
BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, size_type n)\
BOOST_CONTAINER_FORCEINLINE void uninitialized_copy_n_and_update(Allocator &a, Iterator p, std::size_t n)\
{\
BOOST_ASSERT(n == 1); (void)n;\
alloc_traits::construct(a, boost::movelib::iterator_to_raw_pointer(p) BOOST_MOVE_I##N BOOST_MOVE_MFWD##N);\
}\
\
BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &, Iterator, size_type)\
BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &, Iterator, std::size_t)\
{ BOOST_ASSERT(false); }\
\
protected:\
@@ -414,7 +404,6 @@ struct insert_emplace_proxy_arg##N\
typedef insert_nonmovable_emplace_proxy##N\
< Allocator, Iterator BOOST_MOVE_I##N BOOST_MOVE_TARG##N > base_t;\
typedef typename base_t::value_type value_type;\
typedef typename base_t::size_type size_type;\
typedef boost::container::allocator_traits<Allocator> alloc_traits;\
\
static const bool single_value = true;\
@@ -422,7 +411,7 @@ struct insert_emplace_proxy_arg##N\
BOOST_CONTAINER_FORCEINLINE explicit insert_emplace_proxy_arg##N(BOOST_MOVE_UREF##N)\
: base_t(BOOST_MOVE_FWD##N){}\
\
BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &a, Iterator p, size_type n)\
BOOST_CONTAINER_FORCEINLINE void copy_n_and_update(Allocator &a, Iterator p, std::size_t n)\
{\
BOOST_ASSERT(n == 1); (void)n;\
typename dtl::aligned_storage<sizeof(value_type), dtl::alignment_of<value_type>::value>::type v;\

View File

@@ -34,26 +34,26 @@ template<class Allocator, class T, class InpIt>
BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T* dest, InpIt source)
{ boost::container::allocator_traits<Allocator>::construct(a, dest, *source); }
template<class Allocator, class T, class U, class D>
BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, value_init_construct_iterator<U, D>)
template<class Allocator, class T, class U>
BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, value_init_construct_iterator<U>)
{
boost::container::allocator_traits<Allocator>::construct(a, dest);
}
template <class T, class Difference>
template <class T>
class default_init_construct_iterator;
template<class Allocator, class T, class U, class D>
BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, default_init_construct_iterator<U, D>)
template<class Allocator, class T, class U>
BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, default_init_construct_iterator<U>)
{
boost::container::allocator_traits<Allocator>::construct(a, dest, default_init);
}
template <class T, class EmplaceFunctor, class Difference>
template <class T, class EmplaceFunctor>
class emplace_iterator;
template<class Allocator, class T, class U, class EF, class D>
BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, emplace_iterator<U, EF, D> ei)
template<class Allocator, class T, class U, class EF>
BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, emplace_iterator<U, EF> ei)
{
ei.construct_in_place(a, dest);
}
@@ -64,28 +64,28 @@ template<class DstIt, class InpIt>
BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, InpIt source)
{ *dest = *source; }
template<class DstIt, class U, class D>
BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, value_init_construct_iterator<U, D>)
template<class DstIt, class U>
BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, value_init_construct_iterator<U>)
{
dtl::value_init<U> val;
*dest = boost::move(val.get());
}
template <class DstIt, class Difference>
template <class DstIt>
class default_init_construct_iterator;
template<class DstIt, class U, class D>
BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, default_init_construct_iterator<U, D>)
BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, default_init_construct_iterator<U>)
{
U u;
*dest = boost::move(u);
}
template <class T, class EmplaceFunctor, class Difference>
template <class T, class EmplaceFunctor>
class emplace_iterator;
template<class DstIt, class U, class EF, class D>
BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, emplace_iterator<U, EF, D> ei)
template<class DstIt, class U, class EF>
BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, emplace_iterator<U, EF> ei)
{
ei.assign_in_place(dest);
}

View File

@@ -174,14 +174,15 @@ template
typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE F memmove(I f, I l, F r) BOOST_NOEXCEPT_OR_NOTHROW
{
typedef typename boost::container::iterator_traits<I>::value_type value_type;
typedef typename boost::container::iterator_traits<I>::value_type value_type;
typedef typename boost::container::iterator_traits<F>::difference_type r_difference_type;
value_type *const dest_raw = boost::movelib::iterator_to_raw_pointer(r);
const value_type *const beg_raw = boost::movelib::iterator_to_raw_pointer(f);
const value_type *const end_raw = boost::movelib::iterator_to_raw_pointer(l);
if(BOOST_LIKELY(beg_raw != end_raw && dest_raw && beg_raw)){
const typename boost::container::iterator_traits<I>::difference_type n = end_raw - beg_raw;
const std::size_t n = std::size_t(end_raw - beg_raw) ;
std::memmove(dest_raw, beg_raw, sizeof(value_type)*n);
r += n;
r += static_cast<r_difference_type>(n);
}
return r;
}
@@ -193,9 +194,10 @@ template
BOOST_CONTAINER_FORCEINLINE F memmove_n(I f, U n, F r) BOOST_NOEXCEPT_OR_NOTHROW
{
typedef typename boost::container::iterator_traits<I>::value_type value_type;
if(BOOST_LIKELY(n)){
typedef typename boost::container::iterator_traits<F>::difference_type r_difference_type;
if(BOOST_LIKELY(n != 0)){
std::memmove(boost::movelib::iterator_to_raw_pointer(r), boost::movelib::iterator_to_raw_pointer(f), sizeof(value_type)*n);
r += n;
r += static_cast<r_difference_type>(n);
}
return r;
@@ -203,29 +205,31 @@ BOOST_CONTAINER_FORCEINLINE F memmove_n(I f, U n, F r) BOOST_NOEXCEPT_OR_NOTHROW
template
<typename I, // I models InputIterator
typename U, // U models unsigned integral constant
typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE I memmove_n_source(I f, U n, F r) BOOST_NOEXCEPT_OR_NOTHROW
BOOST_CONTAINER_FORCEINLINE I memmove_n_source(I f, std::size_t n, F r) BOOST_NOEXCEPT_OR_NOTHROW
{
if(BOOST_LIKELY(n)){
if(BOOST_LIKELY(n != 0)){
typedef typename boost::container::iterator_traits<I>::value_type value_type;
typedef typename boost::container::iterator_traits<I>::difference_type i_difference_type;
std::memmove(boost::movelib::iterator_to_raw_pointer(r), boost::movelib::iterator_to_raw_pointer(f), sizeof(value_type)*n);
f += n;
f += static_cast<i_difference_type>(n);
}
return f;
}
template
<typename I, // I models InputIterator
typename U, // U models unsigned integral constant
typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE I memmove_n_source_dest(I f, U n, F &r) BOOST_NOEXCEPT_OR_NOTHROW
BOOST_CONTAINER_FORCEINLINE I memmove_n_source_dest(I f, std::size_t n, F &r) BOOST_NOEXCEPT_OR_NOTHROW
{
typedef typename boost::container::iterator_traits<I>::value_type value_type;
if(BOOST_LIKELY(n)){
typedef typename boost::container::iterator_traits<F>::difference_type i_difference_type;
typedef typename boost::container::iterator_traits<F>::difference_type f_difference_type;
if(BOOST_LIKELY(n != 0)){
std::memmove(boost::movelib::iterator_to_raw_pointer(r), boost::movelib::iterator_to_raw_pointer(f), sizeof(value_type)*n);
f += n;
r += n;
f += i_difference_type(n);
r += f_difference_type(n);
}
return f;
}
@@ -338,7 +342,7 @@ template
typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename dtl::disable_if_memtransfer_copy_constructible<I, F, F>::type
uninitialized_move_alloc_n(Allocator &a, I f, typename boost::container::allocator_traits<Allocator>::size_type n, F r)
uninitialized_move_alloc_n(Allocator &a, I f, std::size_t n, F r)
{
F back = r;
BOOST_TRY{
@@ -363,7 +367,7 @@ template
typename I, // I models InputIterator
typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_constructible<I, F, F>::type
uninitialized_move_alloc_n(Allocator &, I f, typename boost::container::allocator_traits<Allocator>::size_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW
uninitialized_move_alloc_n(Allocator &, I f, std::size_t n, F r) BOOST_NOEXCEPT_OR_NOTHROW
{ return dtl::memmove_n(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
@@ -384,7 +388,7 @@ template
typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename dtl::disable_if_memtransfer_copy_constructible<I, F, I>::type
uninitialized_move_alloc_n_source(Allocator &a, I f, typename boost::container::allocator_traits<Allocator>::size_type n, F r)
uninitialized_move_alloc_n_source(Allocator &a, I f, std::size_t n, F r)
{
F back = r;
BOOST_TRY{
@@ -409,7 +413,7 @@ template
typename I, // I models InputIterator
typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_constructible<I, F, I>::type
uninitialized_move_alloc_n_source(Allocator &, I f, typename boost::container::allocator_traits<Allocator>::size_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW
uninitialized_move_alloc_n_source(Allocator &, I f, std::size_t n, F r) BOOST_NOEXCEPT_OR_NOTHROW
{ return dtl::memmove_n_source(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
@@ -475,7 +479,7 @@ template
typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename dtl::disable_if_memtransfer_copy_constructible<I, F, F>::type
uninitialized_copy_alloc_n(Allocator &a, I f, typename boost::container::allocator_traits<Allocator>::size_type n, F r)
uninitialized_copy_alloc_n(Allocator &a, I f, std::size_t n, F r)
{
F back = r;
BOOST_TRY{
@@ -500,7 +504,7 @@ template
typename I, // I models InputIterator
typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_constructible<I, F, F>::type
uninitialized_copy_alloc_n(Allocator &, I f, typename boost::container::allocator_traits<Allocator>::size_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW
uninitialized_copy_alloc_n(Allocator &, I f, std::size_t n, F r) BOOST_NOEXCEPT_OR_NOTHROW
{ return dtl::memmove_n(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
@@ -521,7 +525,7 @@ template
typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename dtl::disable_if_memtransfer_copy_constructible<I, F, I>::type
uninitialized_copy_alloc_n_source(Allocator &a, I f, typename boost::container::allocator_traits<Allocator>::size_type n, F r)
uninitialized_copy_alloc_n_source(Allocator &a, I f, std::size_t n, F r)
{
F back = r;
BOOST_TRY{
@@ -545,7 +549,7 @@ template
typename I, // I models InputIterator
typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_constructible<I, F, I>::type
uninitialized_copy_alloc_n_source(Allocator &, I f, typename boost::container::allocator_traits<Allocator>::size_type n, F r) BOOST_NOEXCEPT_OR_NOTHROW
uninitialized_copy_alloc_n_source(Allocator &, I f, std::size_t n, F r) BOOST_NOEXCEPT_OR_NOTHROW
{ return dtl::memmove_n_source(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
@@ -565,7 +569,7 @@ template
<typename Allocator,
typename F> // F models ForwardIterator
inline typename dtl::disable_if_memzero_initializable<F, F>::type
uninitialized_value_init_alloc_n(Allocator &a, typename boost::container::allocator_traits<Allocator>::size_type n, F r)
uninitialized_value_init_alloc_n(Allocator &a, std::size_t n, F r)
{
F back = r;
BOOST_TRY{
@@ -589,12 +593,14 @@ template
<typename Allocator,
typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memzero_initializable<F, F>::type
uninitialized_value_init_alloc_n(Allocator &, typename boost::container::allocator_traits<Allocator>::size_type n, F r)
uninitialized_value_init_alloc_n(Allocator &, std::size_t n, F r)
{
typedef typename boost::container::iterator_traits<F>::value_type value_type;
if (BOOST_LIKELY(n)){
typedef typename boost::container::iterator_traits<F>::difference_type r_difference_type;
if (BOOST_LIKELY(n != 0)){
std::memset((void*)boost::movelib::iterator_to_raw_pointer(r), 0, sizeof(value_type)*n);
r += n;
r += static_cast<r_difference_type>(n);
}
return r;
}
@@ -615,7 +621,7 @@ BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memzero_initializable<F, F>:
template
<typename Allocator,
typename F> // F models ForwardIterator
inline F uninitialized_default_init_alloc_n(Allocator &a, typename boost::container::allocator_traits<Allocator>::size_type n, F r)
inline F uninitialized_default_init_alloc_n(Allocator &a, std::size_t n, F r)
{
F back = r;
BOOST_TRY{
@@ -688,7 +694,7 @@ template
<typename Allocator,
typename T,
typename F> // F models ForwardIterator
inline F uninitialized_fill_alloc_n(Allocator &a, const T &v, typename boost::container::allocator_traits<Allocator>::size_type n, F r)
inline F uninitialized_fill_alloc_n(Allocator &a, const T &v, std::size_t n, F r)
{
F back = r;
BOOST_TRY{
@@ -786,10 +792,9 @@ inline typename dtl::disable_if_memtransfer_copy_assignable<I, F, I>::type
template
<typename I, // I models InputIterator
typename U, // U models unsigned integral constant
typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_assignable<I, F, I>::type
copy_n_source(I f, U n, F r) BOOST_NOEXCEPT_OR_NOTHROW
copy_n_source(I f, std::size_t n, F r) BOOST_NOEXCEPT_OR_NOTHROW
{ return dtl::memmove_n_source(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
@@ -800,10 +805,9 @@ BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_assignable<
template
<typename I, // I models InputIterator
typename U, // U models unsigned integral constant
typename F> // F models ForwardIterator
inline typename dtl::disable_if_memtransfer_copy_assignable<I, F, I>::type
copy_n_source_dest(I f, U n, F &r)
copy_n_source_dest(I f, std::size_t n, F &r)
{
while (n) {
--n;
@@ -815,10 +819,9 @@ inline typename dtl::disable_if_memtransfer_copy_assignable<I, F, I>::type
template
<typename I, // I models InputIterator
typename U, // U models unsigned integral constant
typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_assignable<I, F, I>::type
copy_n_source_dest(I f, U n, F &r) BOOST_NOEXCEPT_OR_NOTHROW
copy_n_source_dest(I f, std::size_t n, F &r) BOOST_NOEXCEPT_OR_NOTHROW
{ return dtl::memmove_n_source_dest(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
@@ -903,8 +906,8 @@ BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_assignable<
move_backward(I f, I l, F r) BOOST_NOEXCEPT_OR_NOTHROW
{
typedef typename boost::container::iterator_traits<I>::value_type value_type;
const typename boost::container::iterator_traits<I>::difference_type n = boost::container::iterator_distance(f, l);
if (BOOST_LIKELY(n)){
const std::size_t n = boost::container::iterator_udistance(f, l);
if (BOOST_LIKELY(n != 0)){
r -= n;
std::memmove((boost::movelib::iterator_to_raw_pointer)(r), (boost::movelib::iterator_to_raw_pointer)(f), sizeof(value_type)*n);
}
@@ -934,10 +937,9 @@ inline typename dtl::disable_if_memtransfer_copy_assignable<I, F, I>::type
template
<typename I // I models InputIterator
,typename U // U models unsigned integral constant
,typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_assignable<I, F, I>::type
move_n_source_dest(I f, U n, F &r) BOOST_NOEXCEPT_OR_NOTHROW
move_n_source_dest(I f, std::size_t n, F &r) BOOST_NOEXCEPT_OR_NOTHROW
{ return dtl::memmove_n_source_dest(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
@@ -963,10 +965,9 @@ inline typename dtl::disable_if_memtransfer_copy_assignable<I, F, I>::type
template
<typename I // I models InputIterator
,typename U // U models unsigned integral constant
,typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_assignable<I, F, I>::type
move_n_source(I f, U n, F r) BOOST_NOEXCEPT_OR_NOTHROW
move_n_source(I f, std::size_t n, F r) BOOST_NOEXCEPT_OR_NOTHROW
{ return dtl::memmove_n_source(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
@@ -1010,15 +1011,14 @@ template
,typename G // G models ForwardIterator
>
inline typename dtl::disable_if_memtransfer_copy_assignable<F, G, void>::type
deep_swap_alloc_n( Allocator &a, F short_range_f, typename allocator_traits<Allocator>::size_type n_i
, G large_range_f, typename allocator_traits<Allocator>::size_type n_j)
deep_swap_alloc_n( Allocator &a, F short_range_f, std::size_t n_i, G large_range_f, std::size_t n_j)
{
typename allocator_traits<Allocator>::size_type n = 0;
std::size_t n = 0;
for (; n != n_i ; ++short_range_f, ++large_range_f, ++n){
boost::adl_move_swap(*short_range_f, *large_range_f);
}
boost::container::uninitialized_move_alloc_n(a, large_range_f, n_j - n_i, short_range_f); // may throw
boost::container::destroy_alloc_n(a, large_range_f, n_j - n_i);
boost::container::uninitialized_move_alloc_n(a, large_range_f, std::size_t(n_j - n_i), short_range_f); // may throw
boost::container::destroy_alloc_n(a, large_range_f, std::size_t(n_j - n_i));
}
static const std::size_t DeepSwapAllocNMaxStorage = std::size_t(1) << std::size_t(11); //2K bytes
@@ -1032,8 +1032,7 @@ template
inline typename dtl::enable_if_c
< dtl::is_memtransfer_copy_assignable<F, G>::value && (MaxTmpBytes <= DeepSwapAllocNMaxStorage) && false
, void>::type
deep_swap_alloc_n( Allocator &a, F short_range_f, typename allocator_traits<Allocator>::size_type n_i
, G large_range_f, typename allocator_traits<Allocator>::size_type n_j)
deep_swap_alloc_n( Allocator &a, F short_range_f, std::size_t n_i, G large_range_f, std::size_t n_j)
{
typedef typename allocator_traits<Allocator>::value_type value_type;
typedef typename dtl::aligned_storage
@@ -1047,10 +1046,10 @@ inline typename dtl::enable_if_c
std::memcpy(stora_ptr, large_ptr, n_i_bytes);
std::memcpy(large_ptr, short_ptr, n_i_bytes);
std::memcpy(short_ptr, stora_ptr, n_i_bytes);
boost::container::iterator_advance(large_range_f, n_i);
boost::container::iterator_advance(short_range_f, n_i);
boost::container::uninitialized_move_alloc_n(a, large_range_f, n_j - n_i, short_range_f); // may throw
boost::container::destroy_alloc_n(a, large_range_f, n_j - n_i);
boost::container::iterator_uadvance(large_range_f, n_i);
boost::container::iterator_uadvance(short_range_f, n_i);
boost::container::uninitialized_move_alloc_n(a, large_range_f, std::size_t(n_j - n_i), short_range_f); // may throw
boost::container::destroy_alloc_n(a, large_range_f, std::size_t(n_j - n_i));
}
template
@@ -1062,8 +1061,7 @@ template
inline typename dtl::enable_if_c
< dtl::is_memtransfer_copy_assignable<F, G>::value && true//(MaxTmpBytes > DeepSwapAllocNMaxStorage)
, void>::type
deep_swap_alloc_n( Allocator &a, F short_range_f, typename allocator_traits<Allocator>::size_type n_i
, G large_range_f, typename allocator_traits<Allocator>::size_type n_j)
deep_swap_alloc_n( Allocator &a, F short_range_f, std::size_t n_i, G large_range_f, std::size_t n_j)
{
typedef typename allocator_traits<Allocator>::value_type value_type;
typedef typename dtl::aligned_storage
@@ -1118,10 +1116,10 @@ inline typename dtl::enable_if_c
std::memcpy(stora_ptr, large_ptr, szt_rem);
std::memcpy(large_ptr, short_ptr, szt_rem);
std::memcpy(short_ptr, stora_ptr, szt_rem);
boost::container::iterator_advance(large_range_f, n_i);
boost::container::iterator_advance(short_range_f, n_i);
boost::container::uninitialized_move_alloc_n(a, large_range_f, n_j - n_i, short_range_f); // may throw
boost::container::destroy_alloc_n(a, large_range_f, n_j - n_i);
boost::container::iterator_uadvance(large_range_f, n_i);
boost::container::iterator_uadvance(short_range_f, n_i);
boost::container::uninitialized_move_alloc_n(a, large_range_f, std::size_t(n_j - n_i), short_range_f); // may throw
boost::container::destroy_alloc_n(a, large_range_f, std::size_t(n_j - n_i));
}
@@ -1136,16 +1134,15 @@ template
,typename I // F models InputIterator
,typename O // G models OutputIterator
>
void copy_assign_range_alloc_n( Allocator &a, I inp_start, typename allocator_traits<Allocator>::size_type n_i
, O out_start, typename allocator_traits<Allocator>::size_type n_o )
void copy_assign_range_alloc_n( Allocator &a, I inp_start, std::size_t n_i, O out_start, std::size_t n_o )
{
if (n_o < n_i){
inp_start = boost::container::copy_n_source_dest(inp_start, n_o, out_start); // may throw
boost::container::uninitialized_copy_alloc_n(a, inp_start, n_i - n_o, out_start);// may throw
boost::container::uninitialized_copy_alloc_n(a, inp_start, std::size_t(n_i - n_o), out_start);// may throw
}
else{
out_start = boost::container::copy_n(inp_start, n_i, out_start); // may throw
boost::container::destroy_alloc_n(a, out_start, n_o - n_i);
boost::container::destroy_alloc_n(a, out_start, std::size_t(n_o - n_i));
}
}
@@ -1160,16 +1157,15 @@ template
,typename I // F models InputIterator
,typename O // G models OutputIterator
>
void move_assign_range_alloc_n( Allocator &a, I inp_start, typename allocator_traits<Allocator>::size_type n_i
, O out_start, typename allocator_traits<Allocator>::size_type n_o )
void move_assign_range_alloc_n( Allocator &a, I inp_start, std::size_t n_i, O out_start, std::size_t n_o )
{
if (n_o < n_i){
inp_start = boost::container::move_n_source_dest(inp_start, n_o, out_start); // may throw
boost::container::uninitialized_move_alloc_n(a, inp_start, n_i - n_o, out_start); // may throw
boost::container::uninitialized_move_alloc_n(a, inp_start, std::size_t(n_i - n_o), out_start); // may throw
}
else{
out_start = boost::container::move_n(inp_start, n_i, out_start); // may throw
boost::container::destroy_alloc_n(a, out_start, n_o - n_i);
boost::container::destroy_alloc_n(a, out_start, std::size_t(n_o - n_i));
}
}
@@ -1196,7 +1192,7 @@ void uninitialized_move_and_insert_alloc
, F pos
, F last
, O d_first
, typename allocator_traits<Allocator>::size_type n
, std::size_t n
, InsertionProxy insert_range_proxy)
{
typedef typename array_destructor<Allocator, F>::type array_destructor_t;
@@ -1228,7 +1224,7 @@ void expand_forward_and_insert_alloc
( Allocator &a
, F pos
, F last
, typename allocator_traits<Allocator>::size_type n
, std::size_t n
, InsertionProxy insert_range_proxy)
{
typedef typename array_destructor<Allocator, F>::type array_destructor_t;
@@ -1240,8 +1236,7 @@ void expand_forward_and_insert_alloc
insert_range_proxy.uninitialized_copy_n_and_update(a, last, n);
}
else{
typedef typename allocator_traits<Allocator>::size_type alloc_size_type;
const alloc_size_type elems_after = static_cast<alloc_size_type>(last - pos);
const std::size_t elems_after = static_cast<std::size_t>(last - pos);
if(elems_after >= n){
//New elements can be just copied.
//Move to uninitialized memory last objects
@@ -1261,7 +1256,7 @@ void expand_forward_and_insert_alloc
//Copy first new elements in pos (gap is still there)
insert_range_proxy.copy_n_and_update(a, pos, elems_after);
//Copy to the beginning of the unallocated zone the last new elements (the gap is closed).
insert_range_proxy.uninitialized_copy_n_and_update(a, last, n - elems_after);
insert_range_proxy.uninitialized_copy_n_and_update(a, last, std::size_t(n - elems_after));
on_exception.release();
}
}

View File

@@ -83,9 +83,8 @@ struct null_scoped_deallocator
{
typedef boost::container::allocator_traits<Allocator> AllocTraits;
typedef typename AllocTraits::pointer pointer;
typedef typename AllocTraits::size_type size_type;
null_scoped_deallocator(pointer, Allocator&, size_type)
null_scoped_deallocator(pointer, Allocator&, std::size_t)
{}
void release()
@@ -107,11 +106,11 @@ struct scoped_array_deallocator
typedef typename AllocTraits::pointer pointer;
typedef typename AllocTraits::size_type size_type;
scoped_array_deallocator(pointer p, Allocator& a, size_type length)
scoped_array_deallocator(pointer p, Allocator& a, std::size_t length)
: m_ptr(p), m_alloc(a), m_length(length) {}
~scoped_array_deallocator()
{ if (m_ptr) m_alloc.deallocate(m_ptr, m_length); }
{ if (m_ptr) m_alloc.deallocate(m_ptr, size_type(m_length)); }
void release()
{ m_ptr = 0; }
@@ -119,7 +118,7 @@ struct scoped_array_deallocator
private:
pointer m_ptr;
Allocator& m_alloc;
size_type m_length;
std::size_t m_length;
};
template <class Allocator>
@@ -127,9 +126,8 @@ struct null_scoped_array_deallocator
{
typedef boost::container::allocator_traits<Allocator> AllocTraits;
typedef typename AllocTraits::pointer pointer;
typedef typename AllocTraits::size_type size_type;
null_scoped_array_deallocator(pointer, Allocator&, size_type)
null_scoped_array_deallocator(pointer, Allocator&, std::size_t)
{}
void release()
@@ -141,7 +139,6 @@ struct scoped_destroy_deallocator
{
typedef boost::container::allocator_traits<Allocator> AllocTraits;
typedef typename AllocTraits::pointer pointer;
typedef typename AllocTraits::size_type size_type;
typedef dtl::integral_constant<unsigned,
boost::container::dtl::
version<Allocator>::value> alloc_version;
@@ -181,23 +178,22 @@ struct scoped_destructor_n
typedef boost::container::allocator_traits<Allocator> AllocTraits;
typedef typename AllocTraits::pointer pointer;
typedef typename AllocTraits::value_type value_type;
typedef typename AllocTraits::size_type size_type;
BOOST_CONTAINER_FORCEINLINE scoped_destructor_n(pointer p, Allocator& a, size_type n)
BOOST_CONTAINER_FORCEINLINE scoped_destructor_n(pointer p, Allocator& a, std::size_t n)
: m_p(p), m_a(a), m_n(n)
{}
BOOST_CONTAINER_FORCEINLINE void release()
{ m_p = 0; m_n = 0; }
BOOST_CONTAINER_FORCEINLINE void increment_size(size_type inc)
BOOST_CONTAINER_FORCEINLINE void increment_size(std::size_t inc)
{ m_n += inc; }
BOOST_CONTAINER_FORCEINLINE void increment_size_backwards(size_type inc)
{ m_n += inc; m_p -= inc; }
BOOST_CONTAINER_FORCEINLINE void increment_size_backwards(std::size_t inc)
{ m_n += inc; m_p -= std::ptrdiff_t(inc); }
BOOST_CONTAINER_FORCEINLINE void shrink_forward(size_type inc)
{ m_n -= inc; m_p += inc; }
BOOST_CONTAINER_FORCEINLINE void shrink_forward(std::size_t inc)
{ m_n -= inc; m_p += std::ptrdiff_t(inc); }
~scoped_destructor_n()
{
@@ -214,7 +210,7 @@ struct scoped_destructor_n
private:
pointer m_p;
Allocator & m_a;
size_type m_n;
std::size_t m_n;
};
//!A deleter for scoped_ptr that destroys
@@ -224,18 +220,17 @@ struct null_scoped_destructor_n
{
typedef boost::container::allocator_traits<Allocator> AllocTraits;
typedef typename AllocTraits::pointer pointer;
typedef typename AllocTraits::size_type size_type;
BOOST_CONTAINER_FORCEINLINE null_scoped_destructor_n(pointer, Allocator&, size_type)
BOOST_CONTAINER_FORCEINLINE null_scoped_destructor_n(pointer, Allocator&, std::size_t)
{}
BOOST_CONTAINER_FORCEINLINE void increment_size(size_type)
BOOST_CONTAINER_FORCEINLINE void increment_size(std::size_t)
{}
BOOST_CONTAINER_FORCEINLINE void increment_size_backwards(size_type)
BOOST_CONTAINER_FORCEINLINE void increment_size_backwards(std::size_t)
{}
BOOST_CONTAINER_FORCEINLINE void shrink_forward(size_type)
BOOST_CONTAINER_FORCEINLINE void shrink_forward(std::size_t)
{}
BOOST_CONTAINER_FORCEINLINE void release()

View File

@@ -212,15 +212,16 @@ template<class SequenceContainer, class Iterator, class Compare>
BOOST_CONTAINER_FORCEINLINE void flat_tree_merge_unique //has_merge_unique == false
(SequenceContainer& dest, Iterator first, Iterator last, Compare comp, dtl::false_)
{
typedef typename SequenceContainer::iterator iterator;
typedef typename SequenceContainer::size_type size_type;
typedef typename SequenceContainer::iterator iterator;
typedef typename SequenceContainer::size_type size_type;
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 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;
(flat_tree_container_inplace_merge)(dest, dest.begin()+old_sz, comp, contiguous_tag);
(flat_tree_container_inplace_merge)(dest, dest.begin() + difference_type(old_sz), comp, contiguous_tag);
}
///////////////////////////////////////
@@ -263,7 +264,7 @@ BOOST_CONTAINER_FORCEINLINE Iterator
flat_tree_nth // has_nth == false
(SequenceContainer& cont, typename SequenceContainer::size_type n, dtl::false_)
{
return cont.begin()+ n;
return cont.begin()+ typename SequenceContainer::difference_type(n);
}
///////////////////////////////////////
@@ -1013,7 +1014,7 @@ class flat_tree
: this->priv_insert_unique_prepare(hint, k, data);
if(!ret.second){
ret.first = this->nth(data.position - this->cbegin());
ret.first = this->nth(size_type(data.position - this->cbegin()));
}
else{
ret.first = this->m_data.m_seq.emplace(data.position, try_emplace_t(), ::boost::forward<KeyType>(key), ::boost::forward<Args>(args)...);
@@ -1079,7 +1080,7 @@ class flat_tree
: this->priv_insert_unique_prepare(hint, k, data);\
\
if(!ret.second){\
ret.first = this->nth(data.position - this->cbegin());\
ret.first = this->nth(size_type(data.position - this->cbegin()));\
}\
else{\
ret.first = this->m_data.m_seq.emplace(data.position, try_emplace_t(), ::boost::forward<KeyType>(key) BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
@@ -1102,7 +1103,7 @@ class flat_tree
? this->priv_insert_unique_prepare(k, data)
: this->priv_insert_unique_prepare(hint, k, data);
if(!ret.second){
ret.first = this->nth(data.position - this->cbegin());
ret.first = this->nth(size_type(data.position - this->cbegin()));
ret.first->second = boost::forward<M>(obj);
}
else{
@@ -1234,7 +1235,7 @@ class flat_tree
size_type count(const key_type& k) const
{
std::pair<const_iterator, const_iterator> p = this->equal_range(k);
size_type n = p.second - p.first;
size_type n = size_type(p.second - p.first);
return n;
}
@@ -1244,7 +1245,7 @@ class flat_tree
count(const K& k) const
{
std::pair<const_iterator, const_iterator> p = this->equal_range(k);
size_type n = p.second - p.first;
size_type n = size_type(p.second - p.first);
return n;
}
@@ -1588,7 +1589,7 @@ class flat_tree
while (len) {
size_type step = len >> 1;
middle = first;
middle += step;
middle += difference_type(step);
if (key_cmp(key_extract(*middle), key)) {
first = ++middle;
@@ -1613,7 +1614,7 @@ class flat_tree
while (len) {
size_type step = len >> 1;
middle = first;
middle += step;
middle += difference_type(step);
if (key_cmp(key, key_extract(*middle))) {
len = step;
@@ -1638,7 +1639,7 @@ class flat_tree
while (len) {
size_type step = len >> 1;
middle = first;
middle += step;
middle += difference_type(step);
if (key_cmp(key_extract(*middle), key)){
first = ++middle;
@@ -1650,7 +1651,7 @@ class flat_tree
else {
//Middle is equal to key
last = first;
last += len;
last += difference_type(len);
RanIt const first_ret = this->priv_lower_bound(first, middle, key);
return std::pair<RanIt, RanIt>
( first_ret, this->priv_upper_bound(++middle, last, key));

View File

@@ -30,7 +30,9 @@ namespace container {
using ::boost::intrusive::iterator_traits;
using ::boost::intrusive::iterator_distance;
using ::boost::intrusive::iterator_udistance;
using ::boost::intrusive::iterator_advance;
using ::boost::intrusive::iterator_uadvance;
using ::boost::intrusive::iterator;
using ::boost::intrusive::iterator_enable_if_tag;
using ::boost::intrusive::iterator_disable_if_tag;

View File

@@ -41,15 +41,15 @@
namespace boost {
namespace container {
template <class T, class Difference = std::ptrdiff_t>
template <class T>
class constant_iterator
: public ::boost::container::iterator
<std::random_access_iterator_tag, T, Difference, const T*, const T &>
<std::random_access_iterator_tag, T, std::ptrdiff_t, const T*, const T &>
{
typedef constant_iterator<T, Difference> this_type;
typedef constant_iterator<T> this_type;
public:
BOOST_CONTAINER_FORCEINLINE explicit constant_iterator(const T &ref, Difference range_size)
BOOST_CONTAINER_FORCEINLINE explicit constant_iterator(const T &ref, std::size_t range_size)
: m_ptr(&ref), m_num(range_size){}
//Constructors
@@ -94,41 +94,60 @@ class constant_iterator
BOOST_CONTAINER_FORCEINLINE friend bool operator>= (const constant_iterator& i, const constant_iterator& i2)
{ return !(i < i2); }
BOOST_CONTAINER_FORCEINLINE friend Difference operator- (const constant_iterator& i, const constant_iterator& i2)
BOOST_CONTAINER_FORCEINLINE friend std::ptrdiff_t operator- (const constant_iterator& i, const constant_iterator& i2)
{ return i2.distance_to(i); }
//Arithmetic
BOOST_CONTAINER_FORCEINLINE constant_iterator& operator+=(Difference off)
//Arithmetic signed
BOOST_CONTAINER_FORCEINLINE constant_iterator& operator+=(std::ptrdiff_t off)
{ this->advance(off); return *this; }
BOOST_CONTAINER_FORCEINLINE constant_iterator operator+(Difference off) const
BOOST_CONTAINER_FORCEINLINE constant_iterator operator+(std::ptrdiff_t off) const
{
constant_iterator other(*this);
other.advance(off);
return other;
}
BOOST_CONTAINER_FORCEINLINE friend constant_iterator operator+(Difference off, const constant_iterator& right)
BOOST_CONTAINER_FORCEINLINE friend constant_iterator operator+(std::ptrdiff_t off, const constant_iterator& right)
{ return right + off; }
BOOST_CONTAINER_FORCEINLINE constant_iterator& operator-=(Difference off)
BOOST_CONTAINER_FORCEINLINE constant_iterator& operator-=(std::ptrdiff_t off)
{ this->advance(-off); return *this; }
BOOST_CONTAINER_FORCEINLINE constant_iterator operator-(Difference off) const
BOOST_CONTAINER_FORCEINLINE constant_iterator operator-(std::ptrdiff_t off) const
{ return *this + (-off); }
BOOST_CONTAINER_FORCEINLINE const T& operator*() const
BOOST_CONTAINER_FORCEINLINE const T& operator[] (std::ptrdiff_t ) const
{ return dereference(); }
BOOST_CONTAINER_FORCEINLINE const T& operator[] (Difference ) const
BOOST_CONTAINER_FORCEINLINE const T& operator*() const
{ return dereference(); }
BOOST_CONTAINER_FORCEINLINE const T* operator->() const
{ return &(dereference()); }
//Arithmetic unsigned
BOOST_CONTAINER_FORCEINLINE constant_iterator& operator+=(std::size_t off)
{ return *this += std::ptrdiff_t(off); }
BOOST_CONTAINER_FORCEINLINE constant_iterator operator+(std::size_t off) const
{ return *this + std::ptrdiff_t(off); }
BOOST_CONTAINER_FORCEINLINE friend constant_iterator operator+(std::size_t off, const constant_iterator& right)
{ return std::ptrdiff_t(off) + right; }
BOOST_CONTAINER_FORCEINLINE constant_iterator& operator-=(std::size_t off)
{ return *this -= std::ptrdiff_t(off); }
BOOST_CONTAINER_FORCEINLINE constant_iterator operator-(std::size_t off) const
{ return *this - std::ptrdiff_t(off); }
BOOST_CONTAINER_FORCEINLINE const T& operator[] (std::size_t off) const
{ return (*this)[std::ptrdiff_t(off)]; }
private:
const T * m_ptr;
Difference m_num;
std::size_t m_num;
BOOST_CONTAINER_FORCEINLINE void increment()
{ --m_num; }
@@ -145,22 +164,22 @@ class constant_iterator
BOOST_CONTAINER_FORCEINLINE const T & dereference() const
{ return *m_ptr; }
BOOST_CONTAINER_FORCEINLINE void advance(Difference n)
{ m_num -= n; }
BOOST_CONTAINER_FORCEINLINE void advance(std::ptrdiff_t n)
{ m_num = std::size_t(std::ptrdiff_t(m_num) - n); }
BOOST_CONTAINER_FORCEINLINE Difference distance_to(const this_type &other)const
{ return m_num - other.m_num; }
BOOST_CONTAINER_FORCEINLINE std::ptrdiff_t distance_to(const this_type &other)const
{ return std::ptrdiff_t(m_num - other.m_num); }
};
template <class T, class Difference>
template <class T>
class value_init_construct_iterator
: public ::boost::container::iterator
<std::random_access_iterator_tag, T, Difference, const T*, const T &>
<std::random_access_iterator_tag, T, std::ptrdiff_t, const T*, const T &>
{
typedef value_init_construct_iterator<T, Difference> this_type;
typedef value_init_construct_iterator<T> this_type;
public:
BOOST_CONTAINER_FORCEINLINE explicit value_init_construct_iterator(Difference range_size)
BOOST_CONTAINER_FORCEINLINE explicit value_init_construct_iterator(std::size_t range_size)
: m_num(range_size){}
//Constructors
@@ -205,27 +224,27 @@ class value_init_construct_iterator
BOOST_CONTAINER_FORCEINLINE friend bool operator>= (const value_init_construct_iterator& i, const value_init_construct_iterator& i2)
{ return !(i < i2); }
BOOST_CONTAINER_FORCEINLINE friend Difference operator- (const value_init_construct_iterator& i, const value_init_construct_iterator& i2)
BOOST_CONTAINER_FORCEINLINE friend std::ptrdiff_t operator- (const value_init_construct_iterator& i, const value_init_construct_iterator& i2)
{ return i2.distance_to(i); }
//Arithmetic
BOOST_CONTAINER_FORCEINLINE value_init_construct_iterator& operator+=(Difference off)
BOOST_CONTAINER_FORCEINLINE value_init_construct_iterator& operator+=(std::ptrdiff_t off)
{ this->advance(off); return *this; }
BOOST_CONTAINER_FORCEINLINE value_init_construct_iterator operator+(Difference off) const
BOOST_CONTAINER_FORCEINLINE value_init_construct_iterator operator+(std::ptrdiff_t off) const
{
value_init_construct_iterator other(*this);
other.advance(off);
return other;
}
BOOST_CONTAINER_FORCEINLINE friend value_init_construct_iterator operator+(Difference off, const value_init_construct_iterator& right)
BOOST_CONTAINER_FORCEINLINE friend value_init_construct_iterator operator+(std::ptrdiff_t off, const value_init_construct_iterator& right)
{ return right + off; }
BOOST_CONTAINER_FORCEINLINE value_init_construct_iterator& operator-=(Difference off)
BOOST_CONTAINER_FORCEINLINE value_init_construct_iterator& operator-=(std::ptrdiff_t off)
{ this->advance(-off); return *this; }
BOOST_CONTAINER_FORCEINLINE value_init_construct_iterator operator-(Difference off) const
BOOST_CONTAINER_FORCEINLINE value_init_construct_iterator operator-(std::ptrdiff_t off) const
{ return *this + (-off); }
//This pseudo-iterator's dereference operations have no sense since value is not
@@ -236,7 +255,7 @@ class value_init_construct_iterator
//const T* operator->() const;
private:
Difference m_num;
std::size_t m_num;
BOOST_CONTAINER_FORCEINLINE void increment()
{ --m_num; }
@@ -256,22 +275,22 @@ class value_init_construct_iterator
return dummy;
}
BOOST_CONTAINER_FORCEINLINE void advance(Difference n)
{ m_num -= n; }
BOOST_CONTAINER_FORCEINLINE void advance(std::ptrdiff_t n)
{ m_num = std::size_t(std::ptrdiff_t(m_num) - n); }
BOOST_CONTAINER_FORCEINLINE Difference distance_to(const this_type &other)const
{ return m_num - other.m_num; }
BOOST_CONTAINER_FORCEINLINE std::ptrdiff_t distance_to(const this_type &other)const
{ return std::ptrdiff_t(m_num - other.m_num); }
};
template <class T, class Difference>
template <class T>
class default_init_construct_iterator
: public ::boost::container::iterator
<std::random_access_iterator_tag, T, Difference, const T*, const T &>
<std::random_access_iterator_tag, T, std::ptrdiff_t, const T*, const T &>
{
typedef default_init_construct_iterator<T, Difference> this_type;
typedef default_init_construct_iterator<T> this_type;
public:
BOOST_CONTAINER_FORCEINLINE explicit default_init_construct_iterator(Difference range_size)
BOOST_CONTAINER_FORCEINLINE explicit default_init_construct_iterator(std::size_t range_size)
: m_num(range_size){}
//Constructors
@@ -316,27 +335,27 @@ class default_init_construct_iterator
BOOST_CONTAINER_FORCEINLINE friend bool operator>= (const default_init_construct_iterator& i, const default_init_construct_iterator& i2)
{ return !(i < i2); }
BOOST_CONTAINER_FORCEINLINE friend Difference operator- (const default_init_construct_iterator& i, const default_init_construct_iterator& i2)
BOOST_CONTAINER_FORCEINLINE friend std::ptrdiff_t operator- (const default_init_construct_iterator& i, const default_init_construct_iterator& i2)
{ return i2.distance_to(i); }
//Arithmetic
BOOST_CONTAINER_FORCEINLINE default_init_construct_iterator& operator+=(Difference off)
BOOST_CONTAINER_FORCEINLINE default_init_construct_iterator& operator+=(std::ptrdiff_t off)
{ this->advance(off); return *this; }
BOOST_CONTAINER_FORCEINLINE default_init_construct_iterator operator+(Difference off) const
BOOST_CONTAINER_FORCEINLINE default_init_construct_iterator operator+(std::ptrdiff_t off) const
{
default_init_construct_iterator other(*this);
other.advance(off);
return other;
}
BOOST_CONTAINER_FORCEINLINE friend default_init_construct_iterator operator+(Difference off, const default_init_construct_iterator& right)
BOOST_CONTAINER_FORCEINLINE friend default_init_construct_iterator operator+(std::ptrdiff_t off, const default_init_construct_iterator& right)
{ return right + off; }
BOOST_CONTAINER_FORCEINLINE default_init_construct_iterator& operator-=(Difference off)
BOOST_CONTAINER_FORCEINLINE default_init_construct_iterator& operator-=(std::ptrdiff_t off)
{ this->advance(-off); return *this; }
BOOST_CONTAINER_FORCEINLINE default_init_construct_iterator operator-(Difference off) const
BOOST_CONTAINER_FORCEINLINE default_init_construct_iterator operator-(std::ptrdiff_t off) const
{ return *this + (-off); }
//This pseudo-iterator's dereference operations have no sense since value is not
@@ -347,7 +366,7 @@ class default_init_construct_iterator
//const T* operator->() const;
private:
Difference m_num;
std::size_t m_num;
BOOST_CONTAINER_FORCEINLINE void increment()
{ --m_num; }
@@ -367,22 +386,22 @@ class default_init_construct_iterator
return dummy;
}
BOOST_CONTAINER_FORCEINLINE void advance(Difference n)
{ m_num -= n; }
BOOST_CONTAINER_FORCEINLINE void advance(std::ptrdiff_t n)
{ m_num = std::size_t(std::ptrdiff_t(m_num) - n); }
BOOST_CONTAINER_FORCEINLINE Difference distance_to(const this_type &other) const
{ return m_num - other.m_num; }
BOOST_CONTAINER_FORCEINLINE std::ptrdiff_t distance_to(const this_type &other) const
{ return std::ptrdiff_t(m_num - other.m_num); }
};
template <class T, class Difference = std::ptrdiff_t>
template <class T>
class repeat_iterator
: public ::boost::container::iterator
<std::random_access_iterator_tag, T, Difference, T*, T&>
<std::random_access_iterator_tag, T, std::ptrdiff_t, T*, T&>
{
typedef repeat_iterator<T, Difference> this_type;
typedef repeat_iterator<T> this_type;
public:
BOOST_CONTAINER_FORCEINLINE explicit repeat_iterator(T &ref, Difference range_size)
BOOST_CONTAINER_FORCEINLINE explicit repeat_iterator(T &ref, std::size_t range_size)
: m_ptr(&ref), m_num(range_size){}
//Constructors
@@ -427,33 +446,33 @@ class repeat_iterator
BOOST_CONTAINER_FORCEINLINE friend bool operator>= (const this_type& i, const this_type& i2)
{ return !(i < i2); }
BOOST_CONTAINER_FORCEINLINE friend Difference operator- (const this_type& i, const this_type& i2)
BOOST_CONTAINER_FORCEINLINE friend std::ptrdiff_t operator- (const this_type& i, const this_type& i2)
{ return i2.distance_to(i); }
//Arithmetic
BOOST_CONTAINER_FORCEINLINE this_type& operator+=(Difference off)
BOOST_CONTAINER_FORCEINLINE this_type& operator+=(std::ptrdiff_t off)
{ this->advance(off); return *this; }
BOOST_CONTAINER_FORCEINLINE this_type operator+(Difference off) const
BOOST_CONTAINER_FORCEINLINE this_type operator+(std::ptrdiff_t off) const
{
this_type other(*this);
other.advance(off);
return other;
}
BOOST_CONTAINER_FORCEINLINE friend this_type operator+(Difference off, const this_type& right)
BOOST_CONTAINER_FORCEINLINE friend this_type operator+(std::ptrdiff_t off, const this_type& right)
{ return right + off; }
BOOST_CONTAINER_FORCEINLINE this_type& operator-=(Difference off)
BOOST_CONTAINER_FORCEINLINE this_type& operator-=(std::ptrdiff_t off)
{ this->advance(-off); return *this; }
BOOST_CONTAINER_FORCEINLINE this_type operator-(Difference off) const
BOOST_CONTAINER_FORCEINLINE this_type operator-(std::ptrdiff_t off) const
{ return *this + (-off); }
BOOST_CONTAINER_FORCEINLINE T& operator*() const
{ return dereference(); }
BOOST_CONTAINER_FORCEINLINE T& operator[] (Difference ) const
BOOST_CONTAINER_FORCEINLINE T& operator[] (std::ptrdiff_t ) const
{ return dereference(); }
BOOST_CONTAINER_FORCEINLINE T *operator->() const
@@ -461,7 +480,7 @@ class repeat_iterator
private:
T * m_ptr;
Difference m_num;
std::size_t m_num;
BOOST_CONTAINER_FORCEINLINE void increment()
{ --m_num; }
@@ -478,22 +497,22 @@ class repeat_iterator
BOOST_CONTAINER_FORCEINLINE T & dereference() const
{ return *m_ptr; }
BOOST_CONTAINER_FORCEINLINE void advance(Difference n)
{ m_num -= n; }
BOOST_CONTAINER_FORCEINLINE void advance(std::ptrdiff_t n)
{ m_num = std::size_t(std::ptrdiff_t(m_num - n)); }
BOOST_CONTAINER_FORCEINLINE Difference distance_to(const this_type &other)const
{ return m_num - other.m_num; }
BOOST_CONTAINER_FORCEINLINE std::ptrdiff_t distance_to(const this_type &other)const
{ return std::ptrdiff_t(m_num - other.m_num); }
};
template <class T, class EmplaceFunctor, class Difference /*= std::ptrdiff_t*/>
template <class T, class EmplaceFunctor>
class emplace_iterator
: public ::boost::container::iterator
<std::random_access_iterator_tag, T, Difference, const T*, const T &>
<std::random_access_iterator_tag, T, std::ptrdiff_t, const T*, const T &>
{
typedef emplace_iterator this_type;
public:
typedef Difference difference_type;
typedef std::ptrdiff_t difference_type;
BOOST_CONTAINER_FORCEINLINE explicit emplace_iterator(EmplaceFunctor&e)
: m_num(1), m_pe(&e){}
@@ -579,7 +598,7 @@ class emplace_iterator
{ (*m_pe)(dest); }
private:
difference_type m_num;
std::size_t m_num;
EmplaceFunctor * m_pe;
BOOST_CONTAINER_FORCEINLINE void increment()

View File

@@ -153,8 +153,8 @@ class basic_multiallocation_chain
char_ptr elem = char_pointer_traits::static_cast_from(b);
if(num_units){
char_ptr prev_elem = elem;
elem += unit_bytes;
for(size_type i = 0; i != num_units-1; ++i, elem += unit_bytes){
elem += difference_type(unit_bytes);
for(size_type i = 0; i != num_units-1u; ++i, elem += difference_type(unit_bytes)){
::new (boost::movelib::to_raw_pointer(prev_elem), boost_container_new_t()) void_pointer(elem);
prev_elem = elem;
}

View File

@@ -48,13 +48,13 @@ struct grow_factor_ratio
SizeType new_cap = 0;
if(cur_cap <= overflow_limit){
new_cap = cur_cap * Numerator / Denominator;
new_cap = SizeType(cur_cap * Numerator / Denominator);
}
else if(Denominator == 1 || (SizeType(new_cap = cur_cap) / Denominator) > overflow_limit){
new_cap = (SizeType)-1;
}
else{
new_cap *= Numerator;
new_cap = SizeType(new_cap*Numerator);
}
return max_value<SizeType>
( SizeType(Minimum)

View File

@@ -329,7 +329,7 @@ struct node_alloc_holder
template<class FwdIterator, class Inserter>
void allocate_many_and_construct
(FwdIterator beg, difference_type n, Inserter inserter)
(FwdIterator beg, size_type n, Inserter inserter)
{
if(n){
typedef typename node_allocator_version_traits_type::multiallocation_chain multiallocation_chain_t;

View File

@@ -711,7 +711,7 @@ class tree
{
//Optimized allocation and construction
this->allocate_many_and_construct
( first, boost::container::iterator_distance(first, last)
( first, boost::container::iterator_udistance(first, last)
, insert_equal_end_hint_functor<Node, Icont>(this->icont()));
}
@@ -728,7 +728,7 @@ class tree
{
//Optimized allocation and construction
this->allocate_many_and_construct
( first, boost::container::iterator_distance(first, last)
( first, boost::container::iterator_udistance(first, last)
, dtl::push_back_functor<Node, Icont>(this->icont()));
//AllocHolder clears in case of exception
}

View File

@@ -179,7 +179,7 @@ class devector
typedef typename detail::allocation_guard<allocator_type> allocation_guard;
// Random access pseudo iterator always yielding to the same result
typedef constant_iterator<T, difference_type> cvalue_iterator;
typedef constant_iterator<T> cvalue_iterator;
#endif // ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
@@ -348,7 +348,7 @@ class devector
)
: m_(allocator, pointer(), 0u, 0u, 0u)
{
const size_type n = boost::container::iterator_distance(first, last);
const size_type n = boost::container::iterator_udistance(first, last);
m_.buffer = n ? allocate(n) : pointer();
m_.front_idx = 0u;
//this->allocate(n) will take care of overflows
@@ -703,7 +703,7 @@ class devector
>::type * = 0)
)
{
const size_type n = boost::container::iterator_distance(first, last);
const size_type n = boost::container::iterator_udistance(first, last);
if (capacity() >= n)
{
@@ -943,7 +943,7 @@ class devector
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
size_type size() const BOOST_NOEXCEPT
{
return m_.back_idx - m_.front_idx;
return size_type(m_.back_idx - m_.front_idx);
}
/**
@@ -991,7 +991,7 @@ class devector
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
size_type back_free_capacity() const BOOST_NOEXCEPT
{
return m_.capacity - m_.back_idx;
return size_type(m_.capacity - m_.back_idx);
}
/** **Equivalent to**: `resize_back(sz)` */
@@ -1643,7 +1643,7 @@ class devector
}
else
{
size_type new_elem_index = position - begin();
size_type new_elem_index = size_type(position - begin());
return this->emplace_slow_path(new_elem_index, boost::forward<Args>(args)...);
}
}
@@ -1668,7 +1668,7 @@ class devector
return begin();\
}\
else{\
size_type new_elem_index = position - begin();\
size_type new_elem_index = size_type(position - begin());\
return this->emplace_slow_path(new_elem_index BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
}\
}\
@@ -1900,9 +1900,9 @@ class devector
*/
iterator erase(iterator first, iterator last)
{
size_type front_distance = last - begin();
size_type back_distance = end() - first;
size_type n = boost::container::iterator_distance(first, last);
size_type front_distance = size_type(last - begin());
size_type back_distance = size_type(end() - first);
size_type n = boost::container::iterator_udistance(first, last);
if (front_distance < back_distance)
{
@@ -2152,7 +2152,7 @@ class devector
BOOST_CONTAINER_FORCEINLINE size_type back_capacity() const
{
return m_.capacity - m_.front_idx;
return size_type(m_.capacity - m_.front_idx);
}
size_type calculate_new_capacity(size_type requested_capacity)
@@ -2671,7 +2671,7 @@ class devector
m_.buffer = new_buffer;
//Safe cast, allocate() will handle stored_size_type overflow
m_.set_capacity(new_capacity);
m_.set_back_idx(m_.back_idx - m_.front_idx + buffer_offset);
m_.set_back_idx(size_type(m_.back_idx - m_.front_idx) + buffer_offset);
m_.set_front_idx(buffer_offset);
BOOST_ASSERT(invariants_ok());
@@ -2680,7 +2680,7 @@ class devector
template <typename ForwardIterator>
iterator insert_range(const_iterator position, ForwardIterator first, ForwardIterator last)
{
size_type n = boost::container::iterator_distance(first, last);
size_type n = boost::container::iterator_udistance(first, last);
if (position == end() && back_free_capacity() >= n) {// fast path
iterator r(this->end());
@@ -2701,8 +2701,8 @@ class devector
template <typename ForwardIterator>
iterator insert_range_slow_path(const_iterator position, ForwardIterator first, ForwardIterator last)
{
size_type n = boost::container::iterator_distance(first, last);
size_type index = position - begin();
size_type n = boost::container::iterator_udistance(first, last);
size_type index = size_type(position - begin());
if (front_free_capacity() + back_free_capacity() >= n) {
// if we move enough, it can be done without reallocation
@@ -2834,7 +2834,7 @@ class devector
template <typename ForwardIterator>
void allocate_and_copy_range(ForwardIterator first, ForwardIterator last)
{
size_type n = boost::container::iterator_distance(first, last);
size_type n = boost::container::iterator_udistance(first, last);
pointer new_buffer = n ? allocate(n) : pointer();
allocation_guard new_buffer_guard(new_buffer, n, get_allocator_ref());
@@ -2861,7 +2861,7 @@ class devector
template <typename ForwardIterator>
void overwrite_buffer_impl(ForwardIterator first, ForwardIterator last, dtl::true_)
{
const size_type n = boost::container::iterator_distance(first, last);
const size_type n = boost::container::iterator_udistance(first, last);
BOOST_ASSERT(capacity() >= n);
boost::container::uninitialized_copy_alloc_n
@@ -2901,7 +2901,7 @@ class devector
back_guard.release();
m_.front_idx = 0;
m_.set_back_idx(pos - begin());
m_.set_back_idx(size_type(pos - begin()));
return first;
}

View File

@@ -444,7 +444,7 @@ class list
//! <b>Complexity</b>: Linear to n.
BOOST_CONTAINER_FORCEINLINE void assign(size_type n, const T& val)
{
typedef constant_iterator<value_type, difference_type> cvalue_iterator;
typedef constant_iterator<value_type> cvalue_iterator;
return this->assign(cvalue_iterator(val, n), cvalue_iterator());
}
@@ -676,7 +676,7 @@ class list
void resize(size_type new_size)
{
if(!priv_try_shrink(new_size)){
typedef value_init_construct_iterator<value_type, difference_type> value_init_iterator;
typedef value_init_construct_iterator<value_type> value_init_iterator;
this->insert(this->cend(), value_init_iterator(new_size - this->size()), value_init_iterator());
}
}
@@ -911,7 +911,7 @@ class list
iterator insert(const_iterator position, size_type n, const T& x)
{
//range check is done by insert
typedef constant_iterator<value_type, difference_type> cvalue_iterator;
typedef constant_iterator<value_type> cvalue_iterator;
return this->insert(position, cvalue_iterator(x, n), cvalue_iterator());
}
@@ -966,7 +966,7 @@ class list
insertion_functor func(this->icont(), position.get());
iterator before_p(position.get());
--before_p;
this->allocate_many_and_construct(first, boost::container::iterator_distance(first, last), func);
this->allocate_many_and_construct(first, boost::container::iterator_udistance(first, last), func);
return ++before_p;
}
#endif

View File

@@ -471,7 +471,7 @@ class slist
//! <b>Complexity</b>: Linear to n.
void assign(size_type n, const T& val)
{
typedef constant_iterator<value_type, difference_type> cvalue_iterator;
typedef constant_iterator<value_type> cvalue_iterator;
return this->assign(cvalue_iterator(val, n), cvalue_iterator());
}
@@ -709,7 +709,7 @@ class slist
{
const_iterator last_pos;
if(!priv_try_shrink(new_size, last_pos)){
typedef value_init_construct_iterator<value_type, difference_type> value_init_iterator;
typedef value_init_construct_iterator<value_type> value_init_iterator;
this->insert_after(last_pos, value_init_iterator(new_size - this->size()), value_init_iterator());
}
}
@@ -887,7 +887,7 @@ class slist
//! previous values.
iterator insert_after(const_iterator prev_p, size_type n, const value_type& x)
{
typedef constant_iterator<value_type, difference_type> cvalue_iterator;
typedef constant_iterator<value_type> cvalue_iterator;
return this->insert_after(prev_p, cvalue_iterator(x, n), cvalue_iterator());
}
@@ -955,7 +955,7 @@ class slist
{
//Optimized allocation and construction
insertion_functor func(this->icont(), prev.get());
this->allocate_many_and_construct(first, boost::container::iterator_distance(first, last), func);
this->allocate_many_and_construct(first, boost::container::iterator_udistance(first, last), func);
return iterator(func.inserted_first());
}
#endif

View File

@@ -289,6 +289,7 @@ class stable_vector_iterator
typedef std::random_access_iterator_tag iterator_category;
typedef typename non_const_ptr_traits::element_type value_type;
typedef typename non_const_ptr_traits::difference_type difference_type;
typedef typename non_const_ptr_traits::size_type size_type;
typedef typename ::boost::container::dtl::if_c
< IsConst
, typename non_const_ptr_traits::template
@@ -383,6 +384,7 @@ class stable_vector_iterator
reference operator[](difference_type off) const BOOST_NOEXCEPT_OR_NOTHROW
{ return node_ptr_traits::static_cast_from(this->m_pn->up[off])->get_data(); }
//Arithmetic
BOOST_CONTAINER_FORCEINLINE stable_vector_iterator& operator+=(difference_type off) BOOST_NOEXCEPT_OR_NOTHROW
{
if(off) this->m_pn = this->m_pn->up[off];
@@ -416,6 +418,7 @@ class stable_vector_iterator
return tmp;
}
//Difference
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
friend difference_type operator-(const stable_vector_iterator &left, const stable_vector_iterator &right) BOOST_NOEXCEPT_OR_NOTHROW
{ return left.m_pn->up - right.m_pn->up; }
@@ -916,7 +919,7 @@ class stable_vector
//! <b>Complexity</b>: Linear to n.
BOOST_CONTAINER_FORCEINLINE void assign(size_type n, const T& t)
{
typedef constant_iterator<value_type, difference_type> cvalue_iterator;
typedef constant_iterator<value_type> cvalue_iterator;
this->assign(cvalue_iterator(t, n), cvalue_iterator());
}
@@ -1155,12 +1158,13 @@ class stable_vector
//! <b>Complexity</b>: Linear to the difference between size() and new_size.
void resize(size_type n)
{
typedef value_init_construct_iterator<value_type, difference_type> value_init_iterator;
typedef value_init_construct_iterator<value_type> value_init_iterator;
BOOST_CONTAINER_STABLE_VECTOR_CHECK_INVARIANT;
if(n > this->size())
this->insert(this->cend(), value_init_iterator(n - this->size()), value_init_iterator());
this->insert( this->cend()
, value_init_iterator(n - this->size()), value_init_iterator());
else if(n < this->size())
this->erase(this->cbegin() + n, this->cend());
this->erase(this->cbegin() + difference_type(n), this->cend());
}
//! <b>Effects</b>: Inserts or erases elements at the end such that
@@ -1173,12 +1177,12 @@ class stable_vector
//! <b>Note</b>: Non-standard extension
void resize(size_type n, default_init_t)
{
typedef default_init_construct_iterator<value_type, difference_type> default_init_iterator;
typedef default_init_construct_iterator<value_type> default_init_iterator;
BOOST_CONTAINER_STABLE_VECTOR_CHECK_INVARIANT;
if(n > this->size())
this->insert(this->cend(), default_init_iterator(n - this->size()), default_init_iterator());
else if(n < this->size())
this->erase(this->cbegin() + n, this->cend());
this->erase(this->cbegin() + difference_type(n), this->cend());
}
//! <b>Effects</b>: Inserts or erases elements at the end such that
@@ -1193,7 +1197,7 @@ class stable_vector
if(n > this->size())
this->insert(this->cend(), n - this->size(), t);
else if(n < this->size())
this->erase(this->cbegin() + n, this->cend());
this->erase(this->cbegin() + difference_type(n), this->cend());
}
//! <b>Effects</b>: Number of elements for which memory has been allocated.
@@ -1490,7 +1494,7 @@ class stable_vector
reference emplace_back(Args &&...args)
{
typedef emplace_functor<Args...> EmplaceFunctor;
typedef emplace_iterator<value_type, EmplaceFunctor, difference_type> EmplaceIterator;
typedef emplace_iterator<value_type, EmplaceFunctor> EmplaceIterator;
EmplaceFunctor &&ef = EmplaceFunctor(boost::forward<Args>(args)...);
return *this->insert(this->cend(), EmplaceIterator(ef), EmplaceIterator());
}
@@ -1508,9 +1512,9 @@ class stable_vector
iterator emplace(const_iterator p, Args && ...args)
{
BOOST_ASSERT(this->priv_in_range_or_end(p));
size_type pos_n = p - cbegin();
difference_type pos_n = p - cbegin();
typedef emplace_functor<Args...> EmplaceFunctor;
typedef emplace_iterator<value_type, EmplaceFunctor, difference_type> EmplaceIterator;
typedef emplace_iterator<value_type, EmplaceFunctor> EmplaceIterator;
EmplaceFunctor &&ef = EmplaceFunctor(boost::forward<Args>(args)...);
this->insert(p, EmplaceIterator(ef), EmplaceIterator());
return iterator(this->begin() + pos_n);
@@ -1524,7 +1528,7 @@ class stable_vector
{\
typedef emplace_functor##N\
BOOST_MOVE_LT##N BOOST_MOVE_TARG##N BOOST_MOVE_GT##N EmplaceFunctor;\
typedef emplace_iterator<value_type, EmplaceFunctor, difference_type> EmplaceIterator;\
typedef emplace_iterator<value_type, EmplaceFunctor> EmplaceIterator;\
EmplaceFunctor ef BOOST_MOVE_LP##N BOOST_MOVE_FWD##N BOOST_MOVE_RP##N;\
return *this->insert(this->cend() , EmplaceIterator(ef), EmplaceIterator());\
}\
@@ -1535,11 +1539,11 @@ class stable_vector
BOOST_ASSERT(this->priv_in_range_or_end(p));\
typedef emplace_functor##N\
BOOST_MOVE_LT##N BOOST_MOVE_TARG##N BOOST_MOVE_GT##N EmplaceFunctor;\
typedef emplace_iterator<value_type, EmplaceFunctor, difference_type> EmplaceIterator;\
typedef emplace_iterator<value_type, EmplaceFunctor> EmplaceIterator;\
EmplaceFunctor ef BOOST_MOVE_LP##N BOOST_MOVE_FWD##N BOOST_MOVE_RP##N;\
const size_type pos_n = p - this->cbegin();\
const size_type pos_n = size_type(p - this->cbegin());\
this->insert(p, EmplaceIterator(ef), EmplaceIterator());\
return this->begin() += pos_n;\
return this->begin() += difference_type(pos_n);\
}\
//
BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_STABLE_VECTOR_EMPLACE_CODE)
@@ -1608,7 +1612,7 @@ class stable_vector
{
BOOST_ASSERT(this->priv_in_range_or_end(p));
BOOST_CONTAINER_STABLE_VECTOR_CHECK_INVARIANT;
typedef constant_iterator<value_type, difference_type> cvalue_iterator;
typedef constant_iterator<value_type> cvalue_iterator;
return this->insert(p, cvalue_iterator(t, n), cvalue_iterator());
}
@@ -1654,11 +1658,11 @@ class stable_vector
{
BOOST_ASSERT(this->priv_in_range_or_end(p));
BOOST_CONTAINER_STABLE_VECTOR_CHECK_INVARIANT;
const size_type pos_n = p - this->cbegin();
const difference_type pos_n = p - this->cbegin();
for(; first != last; ++first){
this->emplace(p, *first);
}
return this->begin() + pos_n;
return this->begin() + difference_type(pos_n);
}
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1671,7 +1675,7 @@ class stable_vector
insert(const_iterator p, FwdIt first, FwdIt last)
{
BOOST_ASSERT(this->priv_in_range_or_end(p));
const size_type num_new = static_cast<size_type>(boost::container::iterator_distance(first, last));
const size_type num_new = boost::container::iterator_udistance(first, last);
const size_type idx = static_cast<size_type>(p - this->cbegin());
if(num_new){
//Fills the node pool and inserts num_new null pointers in idx.
@@ -1679,7 +1683,7 @@ class stable_vector
//past-new nodes are not aligned until the end of this function
//or in a rollback in case of exception
index_iterator it_past_newly_constructed(this->priv_insert_forward_non_templated(idx, num_new));
const index_iterator it_past_new(it_past_newly_constructed + num_new);
const index_iterator it_past_new(it_past_newly_constructed + difference_type(num_new));
{
//Prepare rollback
insert_rollback rollback(*this, it_past_newly_constructed, it_past_new);
@@ -1699,7 +1703,7 @@ class stable_vector
//nodes before insertion p in priv_insert_forward_non_templated(...)
index_traits_type::fix_up_pointers_from(this->index, it_past_newly_constructed);
}
return this->begin() + idx;
return this->begin() + static_cast<difference_type>(idx);
}
#endif
@@ -1724,7 +1728,7 @@ class stable_vector
{
BOOST_ASSERT(this->priv_in_range(p));
BOOST_CONTAINER_STABLE_VECTOR_CHECK_INVARIANT;
const size_type d = p - this->cbegin();
const difference_type d = p - this->cbegin();
index_iterator it = this->index.begin() + d;
this->priv_delete_node(p.node_pointer());
it = this->index.erase(it);
@@ -1749,10 +1753,11 @@ class stable_vector
size_type d_dif = d2 - d1;
if(d_dif){
multiallocation_chain holder;
const index_iterator it1(this->index.begin() + d1);
const index_iterator it2(it1 + d_dif);
const index_iterator it1(this->index.begin() + difference_type(d1));
const index_iterator it2(it1 + difference_type(d_dif));
index_iterator it(it1);
while(d_dif--){
while(d_dif){
--d_dif;
node_base_ptr &nb = *it;
++it;
node_type &n = *node_ptr_traits::static_cast_from(nb);
@@ -1861,7 +1866,7 @@ class stable_vector
//Check range
BOOST_ASSERT(this->index.empty() || (this->index.data() <= p->up));
BOOST_ASSERT(this->index.empty() || p->up <= (this->index.data() + this->index.size()));
return this->index.empty() ? 0 : p->up - this->index.data();
return this->index.empty() ? 0u : size_type(p->up - this->index.data());
}
class insert_rollback
@@ -1920,15 +1925,15 @@ class stable_vector
//Now try to make room in the vector
const node_base_ptr_ptr old_buffer = this->index.data();
this->index.insert(this->index.begin() + idx, num_new, node_ptr());
this->index.insert(this->index.begin() + (difference_type)idx, num_new, node_ptr());
bool new_buffer = this->index.data() != old_buffer;
//Fix the pointers for the newly allocated buffer
const index_iterator index_beg = this->index.begin();
if(new_buffer){
index_traits_type::fix_up_pointers(index_beg, index_beg + idx);
index_traits_type::fix_up_pointers(index_beg, index_beg + (difference_type)idx);
}
return index_beg + idx;
return index_beg + (difference_type)idx;
}
BOOST_CONTAINER_FORCEINLINE bool priv_capacity_bigger_than_size() const
@@ -1962,14 +1967,14 @@ class stable_vector
iterator priv_insert(const_iterator p, const value_type &t)
{
BOOST_ASSERT(this->priv_in_range_or_end(p));
typedef constant_iterator<value_type, difference_type> cvalue_iterator;
typedef constant_iterator<value_type> cvalue_iterator;
return this->insert(p, cvalue_iterator(t, 1), cvalue_iterator());
}
iterator priv_insert(const_iterator p, BOOST_RV_REF(T) x)
{
BOOST_ASSERT(this->priv_in_range_or_end(p));
typedef repeat_iterator<T, difference_type> repeat_it;
typedef repeat_iterator<T> repeat_it;
typedef boost::move_iterator<repeat_it> repeat_move_it;
//Just call more general insert(p, size, value) and return iterator
return this->insert(p, repeat_move_it(repeat_it(x, 1)), repeat_move_it(repeat_it()));

View File

@@ -88,11 +88,13 @@ class basic_string_base
typedef Allocator allocator_type;
public:
typedef allocator_traits<allocator_type> allocator_traits_type;
typedef allocator_type stored_allocator_type;
typedef typename allocator_traits_type::pointer pointer;
typedef typename allocator_traits_type::value_type value_type;
typedef typename allocator_traits_type::size_type size_type;
typedef allocator_traits<allocator_type> allocator_traits_type;
typedef allocator_type stored_allocator_type;
typedef typename allocator_traits_type::pointer pointer;
typedef typename allocator_traits_type::value_type value_type;
typedef typename allocator_traits_type::size_type size_type;
typedef typename allocator_traits_type::difference_type difference_type;
typedef ::boost::intrusive::pointer_traits<pointer> pointer_traits;
BOOST_CONTAINER_FORCEINLINE basic_string_base()
@@ -414,8 +416,8 @@ class basic_string_base
BOOST_CONTAINER_FORCEINLINE pointer priv_end_addr() const
{
return this->is_short()
? this->priv_short_addr() + this->priv_short_size()
: this->priv_long_addr() + this->priv_long_size()
? this->priv_short_addr() + difference_type(this->priv_short_size())
: this->priv_long_addr() + difference_type(this->priv_long_size())
;
}
@@ -460,11 +462,21 @@ class basic_string_base
}
BOOST_CONTAINER_FORCEINLINE void priv_short_size(size_type sz)
{ this->members_.pshort_repr()->h.length = (unsigned char)sz; }
{
typedef unsigned char uchar_type;
static const uchar_type mask = uchar_type(uchar_type(-1) >> 1U);
BOOST_ASSERT( sz <= mask );
//Make -Wconversion happy
this->members_.pshort_repr()->h.length = uchar_type(uchar_type(sz) & mask);
}
BOOST_CONTAINER_FORCEINLINE void priv_long_size(size_type sz)
{ this->members_.plong_repr()->length = sz; }
{
static const size_type mask = size_type(-1) >> 1U;
BOOST_ASSERT( sz <= mask );
//Make -Wconversion happy
this->members_.plong_repr()->length = sz & mask;
}
#if defined(BOOST_GCC) && (BOOST_GCC >= 40700)
#pragma GCC diagnostic pop
#endif
@@ -611,7 +623,7 @@ class basic_string
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
private:
typedef constant_iterator<CharT, difference_type> cvalue_iterator;
typedef constant_iterator<CharT> cvalue_iterator;
typedef typename base_t::alloc_version alloc_version;
typedef ::boost::intrusive::pointer_traits<pointer> pointer_traits;
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
@@ -751,7 +763,7 @@ class basic_string
: base_t()
{
this->priv_terminate_string();
this->assign(s, s + n);
this->assign(s, s + difference_type(n));
}
//! <b>Effects</b>: Constructs a basic_string taking the allocator as parameter,
@@ -760,7 +772,7 @@ class basic_string
: base_t(a)
{
this->priv_terminate_string();
this->assign(s, s + n);
this->assign(s, s + difference_type(n));
}
//! <b>Effects</b>: Constructs a basic_string with a default-constructed allocator,
@@ -1147,7 +1159,7 @@ class basic_string
void resize(size_type n, CharT c)
{
if (n <= this->size())
this->erase(this->begin() + n, this->end());
this->erase(this->begin() + difference_type(n), this->end());
else
this->append(n - this->size(), c);
}
@@ -1172,7 +1184,7 @@ class basic_string
void resize(size_type n, default_init_t)
{
if (n <= this->size())
this->erase(this->begin() + n, this->end());
this->erase(this->begin() + difference_type(n), this->end());
else{
this->priv_reserve(n, false);
this->priv_size(n);
@@ -1310,7 +1322,7 @@ class basic_string
reference operator[](size_type n) BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(this->size() > n);
return *(this->priv_addr() + n);
return *(this->priv_addr() + difference_type(n));
}
//! <b>Requires</b>: size() > n.
@@ -1325,7 +1337,7 @@ class basic_string
const_reference operator[](size_type n) const BOOST_NOEXCEPT_OR_NOTHROW
{
BOOST_ASSERT(this->size() > n);
return *(this->priv_addr() + n);
return *(this->priv_addr() + difference_type(n));
}
//! <b>Requires</b>: size() > n.
@@ -1341,7 +1353,7 @@ class basic_string
{
if (n >= this->size())
throw_out_of_range("basic_string::at invalid subscript");
return *(this->priv_addr() + n);
return *(this->priv_addr() + difference_type(n));
}
//! <b>Requires</b>: size() > n.
@@ -1356,7 +1368,7 @@ class basic_string
const_reference at(size_type n) const {
if (n >= this->size())
throw_out_of_range("basic_string::at invalid subscript");
return *(this->priv_addr() + n);
return *(this->priv_addr() + difference_type(n));
}
//////////////////////////////////////////////
@@ -1439,7 +1451,7 @@ class basic_string
//!
//! <b>Returns</b>: *this
basic_string& append(const CharT* s, size_type n)
{ return this->append(s, s + n); }
{ return this->append(s, s + difference_type(n)); }
//! <b>Requires</b>: s points to an array of at least traits::length(s) + 1 elements of CharT.
//!
@@ -1480,9 +1492,9 @@ class basic_string
const size_type old_size = this->priv_size();
if (old_size < this->capacity()){
const pointer addr = this->priv_addr();
this->priv_construct_null(addr + old_size + 1);
Traits::assign(addr[old_size], c);
this->priv_size(old_size+1);
this->priv_construct_null(addr + difference_type(old_size + 1u));
Traits::assign(addr[difference_type(old_size)], c);
this->priv_size(old_size+1u);
}
else{
//No enough memory, insert a new object at the end
@@ -1538,7 +1550,7 @@ class basic_string
//!
//! <b>Returns</b>: *this
basic_string& assign(const CharT* s, size_type n)
{ return this->assign(s, s + n); }
{ return this->assign(s, s + difference_type(n)); }
//! <b>Requires</b>: s points to an array of at least traits::length(s) + 1 elements of CharT.
//!
@@ -1563,7 +1575,7 @@ class basic_string
this->reserve(n);
CharT* ptr = boost::movelib::to_raw_pointer(this->priv_addr());
Traits::copy(ptr, first, n);
this->priv_construct_null(ptr + n);
this->priv_construct_null(ptr + difference_type(n));
this->priv_size(n);
return *this;
}
@@ -1589,7 +1601,7 @@ class basic_string
++ptr;
}
if (first == last)
this->erase(addr + cur, addr + old_size);
this->erase(addr + difference_type(cur), addr + difference_type(old_size));
else
this->append(first, last);
return *this;
@@ -1662,7 +1674,7 @@ class basic_string
throw_out_of_range("basic_string::insert out of range position");
if (this->size() > this->max_size() - n)
throw_length_error("basic_string::insert max_size() exceeded");
this->insert(this->priv_addr() + pos, s, s + n);
this->insert(this->priv_addr() + pos, s, s + difference_type(n));
return *this;
}
@@ -1714,7 +1726,7 @@ class basic_string
//! <b>Returns</b>: An iterator which refers to the copy of the inserted character.
iterator insert(const_iterator p, CharT c)
{
size_type new_offset = p - this->priv_addr();
size_type new_offset = size_type(p - this->priv_addr());
this->insert(p, cvalue_iterator(c, 1), cvalue_iterator());
return this->priv_addr() + new_offset;
}
@@ -1747,7 +1759,7 @@ class basic_string
for ( ; first != last; ++first, ++p) {
p = this->insert(p, *first);
}
return this->begin() + n_pos;
return this->begin() + difference_type(n_pos);
}
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1760,9 +1772,9 @@ class basic_string
>::type * = 0
)
{
const size_type n_pos = p - this->cbegin();
const size_type n_pos = size_type(p - this->cbegin());
if (first != last) {
const size_type n = boost::container::iterator_distance(first, last);
const size_type n = boost::container::iterator_udistance(first, last);
const size_type old_size = this->priv_size();
const size_type remaining = this->capacity() - old_size;
const pointer old_start = this->priv_addr();
@@ -1780,7 +1792,7 @@ class basic_string
new_cap = this->next_capacity(n);
hint = old_start;
allocation_ret = this->allocation_command
(allocate_new | expand_fwd | expand_bwd, old_size + n + 1, new_cap, hint);
(allocate_new | expand_fwd | expand_bwd, old_size + n + 1u, new_cap, hint);
//Check forward expansion
if(old_start == allocation_ret){
@@ -1791,29 +1803,29 @@ class basic_string
//Reuse same buffer
if(enough_capacity){
const size_type elems_after = old_size - (p - old_start);
const size_type elems_after = old_size - size_type(p - old_start);
const size_type old_length = old_size;
if (elems_after >= n) {
const pointer pointer_past_last = old_start + old_size + 1;
priv_uninitialized_copy(old_start + (old_size - n + 1),
const pointer pointer_past_last = old_start + difference_type(old_size + 1u);
priv_uninitialized_copy(old_start + difference_type(old_size - n + 1u),
pointer_past_last, pointer_past_last);
this->priv_size(old_size+n);
Traits::move(const_cast<CharT*>(boost::movelib::to_raw_pointer(p + n)),
Traits::move(const_cast<CharT*>(boost::movelib::to_raw_pointer(p + difference_type(n))),
boost::movelib::to_raw_pointer(p),
(elems_after - n) + 1);
(elems_after - n) + 1u);
this->priv_copy(first, last, const_cast<CharT*>(boost::movelib::to_raw_pointer(p)));
}
else {
ForwardIter mid = first;
boost::container::iterator_advance(mid, elems_after + 1);
boost::container::iterator_uadvance(mid, elems_after + 1u);
priv_uninitialized_copy(mid, last, old_start + old_size + 1);
priv_uninitialized_copy(mid, last, old_start + difference_type(old_size + 1u));
const size_type newer_size = old_size + (n - elems_after);
this->priv_size(newer_size);
priv_uninitialized_copy
(p, const_iterator(old_start + old_length + 1),
old_start + newer_size);
(p, const_iterator(old_start + difference_type(old_length + 1u)),
old_start + difference_type(newer_size));
this->priv_size(newer_size + elems_after);
this->priv_copy(first, mid, const_cast<CharT*>(boost::movelib::to_raw_pointer(p)));
}
@@ -1827,11 +1839,11 @@ class basic_string
new_length += priv_uninitialized_copy
(const_iterator(old_start), p, new_start);
new_length += priv_uninitialized_copy
(first, last, new_start + new_length);
(first, last, new_start + difference_type(new_length));
new_length += priv_uninitialized_copy
(p, const_iterator(old_start + old_size),
new_start + new_length);
this->priv_construct_null(new_start + new_length);
(p, const_iterator(old_start + difference_type(old_size)),
new_start + difference_type(new_length));
this->priv_construct_null(new_start + difference_type(new_length));
this->deallocate_block();
this->assure_long();
@@ -1845,14 +1857,14 @@ class basic_string
value_type * const oldbuf = boost::movelib::to_raw_pointer(old_start);
value_type * const newbuf = boost::movelib::to_raw_pointer(new_start);
const value_type *const pos = boost::movelib::to_raw_pointer(p);
const size_type before = pos - oldbuf;
const size_type before = size_type(pos - oldbuf);
//First move old data
Traits::move(newbuf, oldbuf, before);
Traits::move(newbuf + before + n, pos, old_size - before);
Traits::move(newbuf + difference_type(before + n), pos, old_size - before);
//Now initialize the new data
priv_uninitialized_copy(first, last, new_start + before);
this->priv_construct_null(new_start + (old_size + n));
priv_uninitialized_copy(first, last, new_start + difference_type(before));
this->priv_construct_null(new_start + difference_type(old_size + n));
this->assure_long();
this->priv_long_addr(new_start);
this->priv_long_size(old_size + n);
@@ -1860,7 +1872,7 @@ class basic_string
}
}
}
return this->begin() + n_pos;
return this->begin() + difference_type(n_pos);
}
#endif
@@ -1903,7 +1915,7 @@ class basic_string
if (pos > this->size())
throw_out_of_range("basic_string::erase out of range position");
const pointer addr = this->priv_addr();
erase(addr + pos, addr + pos + dtl::min_value(n, this->size() - pos));
erase(addr + difference_type(pos), addr + difference_type(pos) + dtl::min_value(n, this->size() - pos));
return *this;
}
@@ -1920,8 +1932,8 @@ class basic_string
const size_type old_size = this->priv_size();
Traits::move(ptr,
boost::movelib::to_raw_pointer(p + 1),
old_size - (p - this->priv_addr()));
this->priv_size(old_size-1);
old_size - size_type(p - this->priv_addr()));
this->priv_size(old_size-1u);
return iterator(ptr);
}
@@ -1937,11 +1949,11 @@ class basic_string
{
CharT * f = const_cast<CharT*>(boost::movelib::to_raw_pointer(first));
if (first != last) { // The move includes the terminating null.
const size_type num_erased = last - first;
const size_type num_erased = size_type(last - first);
const size_type old_size = this->priv_size();
Traits::move(f,
boost::movelib::to_raw_pointer(last),
(old_size + 1)-(last - this->priv_addr()));
old_size + 1u - size_type(last - this->priv_addr()));
const size_type new_length = old_size - num_erased;
this->priv_size(new_length);
}
@@ -1980,8 +1992,8 @@ class basic_string
if (this->size() - len >= this->max_size() - str.size())
throw_length_error("basic_string::replace max_size() exceeded");
const pointer addr = this->priv_addr();
return this->replace( const_iterator(addr + pos1)
, const_iterator(addr + pos1 + len)
return this->replace( const_iterator(addr + difference_type(pos1))
, const_iterator(addr + difference_type(pos1 + len))
, str.begin(), str.end());
}
@@ -2048,7 +2060,7 @@ class basic_string
if (n2 > max_size || (this->size() - len) >= (max_size - n2))
throw_length_error("basic_string::replace max_size() exceeded");
const pointer addr = this->priv_addr() + pos1;
return this->replace(addr, addr + len, s, s + n2);
return this->replace(addr, addr + difference_type(len), s, s + difference_type(n2));
}
//! <b>Requires</b>: pos1 <= size() and s points to an array of at least n2 elements of CharT.
@@ -2086,7 +2098,7 @@ class basic_string
if (n2 > this->max_size() || this->size() - len >= this->max_size() - n2)
throw_length_error("basic_string::replace max_size() exceeded");
const pointer addr = this->priv_addr();
return this->replace(addr + pos1, addr + pos1 + len, n2, c);
return this->replace(addr + difference_type(pos1), addr + difference_type(pos1 + len), n2, c);
}
//! <b>Requires</b>: [begin(),i1) and [i1,i2) are valid ranges.
@@ -2108,7 +2120,7 @@ class basic_string
//!
//! <b>Returns</b>: *this
BOOST_CONTAINER_FORCEINLINE basic_string& replace(const_iterator i1, const_iterator i2, const CharT* s, size_type n)
{ return this->replace(i1, i2, s, s + n); }
{ return this->replace(i1, i2, s, s + difference_type(n)); }
//! <b>Requires</b>: [begin(),i1) and [i1,i2) are valid ranges and s points to an
//! array of at least traits::length(s) + 1 elements of CharT.
@@ -2133,7 +2145,7 @@ class basic_string
const size_type len = static_cast<size_type>(i2 - i1);
if (len >= n) {
Traits::assign(const_cast<CharT*>(boost::movelib::to_raw_pointer(i1)), n, c);
erase(i1 + n, i2);
erase(i1 + difference_type(n), i2);
}
else {
Traits::assign(const_cast<CharT*>(boost::movelib::to_raw_pointer(i1)), len, c);
@@ -2185,7 +2197,7 @@ class basic_string
const difference_type len = i2 - i1;
if (len >= n) {
this->priv_copy(j1, j2, const_cast<CharT*>(boost::movelib::to_raw_pointer(i1)));
this->erase(i1 + n, i2);
this->erase(i1 + difference_type(n), i2);
}
else {
ForwardIter m = j1;
@@ -2350,12 +2362,12 @@ class basic_string
return npos;
else {
const pointer addr = this->priv_addr();
pointer finish = addr + this->priv_size();
pointer finish = addr + difference_type(this->priv_size());
const const_iterator result =
boost::container::search(boost::movelib::to_raw_pointer(addr + pos),
boost::container::search(boost::movelib::to_raw_pointer(addr + difference_type(pos)),
boost::movelib::to_raw_pointer(finish),
s, s + n, Eq_traits<Traits>());
return result != finish ? result - begin() : npos;
s, s + difference_type(n), Eq_traits<Traits>());
return result != finish ? size_type(result - begin()) : npos;
}
}
@@ -2379,11 +2391,11 @@ class basic_string
return npos;
else {
const pointer addr = this->priv_addr();
pointer finish = addr + sz;
pointer finish = addr + difference_type(sz);
const const_iterator result =
boost::container::find_if(addr + pos, finish,
boost::container::find_if(addr + difference_type(pos), finish,
boost::container::bind2nd(Eq_traits<Traits>(), c));
return result != finish ? result - begin() : npos;
return result != finish ? size_type(result - begin()) : npos;
}
}
@@ -2427,10 +2439,10 @@ class basic_string
else if (n == 0)
return dtl::min_value(len, pos);
else {
const const_iterator last = begin() + dtl::min_value(len - n, pos) + n;
const const_iterator last = begin() + difference_type(dtl::min_value(len - n, pos + n));
const const_iterator result = boost::container::find_end
(begin(), last, s, s + n, Eq_traits<Traits>());
return result != last ? result - begin() : npos;
(begin(), last, s, s + difference_type(n), Eq_traits<Traits>());
return result != last ? size_type(result - begin()) : npos;
}
}
@@ -2459,7 +2471,7 @@ class basic_string
const_reverse_iterator rresult =
boost::container::find_if(const_reverse_iterator(last), rend(),
boost::container::bind2nd(Eq_traits<Traits>(), c));
return rresult != rend() ? (rresult.base() - 1) - begin() : npos;
return rresult != rend() ? size_type((rresult.base() - 1) - begin()) : npos;
}
}
@@ -2499,10 +2511,10 @@ class basic_string
return npos;
else {
const pointer addr = this->priv_addr();
pointer finish = addr + sz;
pointer finish = addr + difference_type(sz);
const_iterator result = boost::container::find_first_of
(addr + pos, finish, s, s + n, Eq_traits<Traits>());
return result != finish ? result - this->begin() : npos;
(addr + difference_type(pos), finish, s, s + difference_type(n), Eq_traits<Traits>());
return result != finish ? size_type(result - this->begin()) : npos;
}
}
@@ -2561,11 +2573,11 @@ class basic_string
return npos;
else {
const pointer addr = this->priv_addr();
const const_iterator last = addr + dtl::min_value(len - 1, pos) + 1;
const const_iterator last = addr + difference_type(dtl::min_value(len - 1, pos) + 1);
const const_reverse_iterator rresult =
boost::container::find_first_of(const_reverse_iterator(last), rend(),
s, s + n, Eq_traits<Traits>());
return rresult != rend() ? (rresult.base() - 1) - addr : npos;
s, s + difference_type(n), Eq_traits<Traits>());
return rresult != rend() ? size_type((rresult.base() - 1) - addr) : npos;
}
}
@@ -2622,10 +2634,10 @@ class basic_string
return npos;
else {
const pointer addr = this->priv_addr();
const pointer finish = addr + this->priv_size();
const pointer finish = addr + difference_type(this->priv_size());
const const_iterator result = boost::container::find_if
(addr + pos, finish, Not_within_traits<Traits>(s, s + n));
return result != finish ? result - addr : npos;
(addr + difference_type(pos), finish, Not_within_traits<Traits>(s, s + difference_type(n)));
return result != finish ? size_type(result - addr) : npos;
}
}
@@ -2648,11 +2660,11 @@ class basic_string
return npos;
else {
const pointer addr = this->priv_addr();
const pointer finish = addr + this->priv_size();
const pointer finish = addr + difference_type(this->priv_size());
const const_iterator result
= boost::container::find_if(addr + pos, finish,
= boost::container::find_if(addr + difference_type(pos), finish,
boost::container::not1(boost::container::bind2nd(Eq_traits<Traits>(), c)));
return result != finish ? result - begin() : npos;
return result != finish ? size_type(result - begin()) : npos;
}
}
@@ -2695,8 +2707,8 @@ class basic_string
const const_iterator last = begin() + dtl::min_value(len - 1, pos) + 1;
const const_reverse_iterator rresult =
boost::container::find_if(const_reverse_iterator(last), rend(),
Not_within_traits<Traits>(s, s + n));
return rresult != rend() ? (rresult.base() - 1) - begin() : npos;
Not_within_traits<Traits>(s, s + difference_type(n)));
return rresult != rend() ? size_type((rresult.base() - 1) - begin()) : npos;
}
}
@@ -2724,7 +2736,7 @@ class basic_string
const const_reverse_iterator rresult =
boost::container::find_if(const_reverse_iterator(last), rend(),
boost::container::not1(boost::container::bind2nd(Eq_traits<Traits>(), c)));
return rresult != rend() ? (rresult.base() - 1) - begin() : npos;
return rresult != rend() ? size_type((rresult.base() - 1) - begin()) : npos;
}
}
@@ -2742,8 +2754,8 @@ class basic_string
if (pos > this->size())
throw_out_of_range("basic_string::substr out of range position");
const pointer addr = this->priv_addr();
return basic_string(addr + pos,
addr + pos + dtl::min_value(n, size() - pos), this->alloc());
return basic_string(addr + difference_type(pos),
addr + difference_type(pos + dtl::min_value(n, size() - pos)), this->alloc());
}
//! <b>Effects</b>: Determines the effective length rlen of the string to compare as
@@ -2760,7 +2772,7 @@ class basic_string
{
const pointer addr = this->priv_addr();
const pointer str_addr = str.priv_addr();
return this->s_compare(addr, addr + this->priv_size(), str_addr, str_addr + str.priv_size());
return this->s_compare(addr, addr + difference_type(this->priv_size()), str_addr, str_addr + difference_type(str.priv_size()));
}
//! <b>Throws</b>: Nothing
@@ -2771,7 +2783,7 @@ class basic_string
int compare(BasicStringView<CharT,Traits> sv) const
{
const pointer addr = this->priv_addr();
return this->s_compare(addr, addr + this->priv_size(), sv.data(), sv.data() + sv.size());
return this->s_compare(addr, addr + difference_type(this->priv_size()), sv.data(), sv.data() + difference_type(sv.size()));
}
//! <b>Requires</b>: pos1 <= size()
@@ -2790,9 +2802,9 @@ class basic_string
throw_out_of_range("basic_string::compare out of range position");
const pointer addr = this->priv_addr();
const pointer str_addr = str.priv_addr();
return this->s_compare(addr + pos1,
addr + pos1 + dtl::min_value(n1, this->size() - pos1),
str_addr, str_addr + str.priv_size());
return this->s_compare(addr + difference_type(pos1),
addr + difference_type(pos1 + dtl::min_value(n1, this->size() - pos1)),
str_addr, str_addr + difference_type(str.priv_size()));
}
//! <b>Requires</b>: pos1 <= size()
@@ -2808,7 +2820,7 @@ class basic_string
throw_out_of_range("basic_string::compare out of range position");
const pointer addr = this->priv_addr() + pos1;
const CharT* str_addr = sv.data();
return this->s_compare(addr, addr + dtl::min_value(n1, this->size() - pos1),
return this->s_compare(addr, addr + difference_type(dtl::min_value(n1, this->size() - pos1)),
str_addr, str_addr + sv.size());
}
@@ -2827,8 +2839,8 @@ class basic_string
throw_out_of_range("basic_string::compare out of range position");
const pointer addr = this->priv_addr() + pos1;
const pointer str_addr = str.priv_addr() + pos2;
return this->s_compare(addr, addr + dtl::min_value(n1, this->size() - pos1),
str_addr, str_addr + dtl::min_value(n2, str.size() - pos2));
return this->s_compare(addr, addr + difference_type(dtl::min_value(n1, this->size() - pos1)),
str_addr, str_addr + difference_type(dtl::min_value(n2, str.size() - pos2)));
}
//! <b>Requires</b>: pos1 <= size() and pos2 <= str.size()
@@ -2847,8 +2859,8 @@ class basic_string
throw_out_of_range("basic_string::compare out of range position");
const pointer addr = this->priv_addr() + pos1;
const CharT * str_addr = sv.data() + pos2;
return this->s_compare(addr, addr + dtl::min_value(n1, this->size() - pos1),
str_addr, str_addr + dtl::min_value(n2, sv.size() - pos2));
return this->s_compare(addr, addr + difference_type(dtl::min_value(n1, this->size() - pos1)),
str_addr, str_addr + difference_type(dtl::min_value(n2, sv.size() - pos2)));
}
//! <b>Throws</b>: Nothing
@@ -2858,7 +2870,7 @@ class basic_string
int compare(const CharT* s) const
{
const pointer addr = this->priv_addr();
return this->s_compare(addr, addr + this->priv_size(), s, s + Traits::length(s));
return this->s_compare(addr, addr + difference_type(this->priv_size()), s, s + Traits::length(s));
}
//! <b>Requires</b>: pos1 > size() and s points to an array of at least n2 elements of CharT.
@@ -2872,9 +2884,9 @@ class basic_string
if (pos1 > this->size())
throw_out_of_range("basic_string::compare out of range position");
const pointer addr = this->priv_addr();
return this->s_compare( addr + pos1,
addr + pos1 + dtl::min_value(n1, this->size() - pos1),
s, s + n2);
return this->s_compare( addr + difference_type(pos1),
addr + difference_type(pos1 + dtl::min_value(n1, this->size() - pos1)),
s, s + difference_type(n2));
}
//! <b>Requires</b>: pos1 > size() and s points to an array of at least traits::length(s) + 1 elements of CharT.
@@ -2903,9 +2915,9 @@ class basic_string
const pointer addr = this->priv_addr();
new_length += priv_uninitialized_copy
(addr, addr + this->priv_size(), new_start);
(addr, addr + difference_type(this->priv_size()), new_start);
if(null_terminate){
this->priv_construct_null(new_start + new_length);
this->priv_construct_null(new_start + difference_type(new_length));
}
this->deallocate_block();
this->assure_long();
@@ -2918,8 +2930,8 @@ class basic_string
template<class It1, class It2>
static int s_compare(It1 f1, It1 l1, It2 f2, It2 l2)
{
const difference_type n1 = l1 - f1;
const difference_type n2 = l2 - f2;
const std::size_t n1 = std::size_t(l1 - f1);
const std::size_t n2 = std::size_t(l2 - f2);
const int cmp = Traits::compare(boost::movelib::to_raw_pointer(f1),
boost::movelib::to_raw_pointer(f2),
dtl::min_value(n1, n2));
@@ -3031,7 +3043,7 @@ class basic_string
}
BOOST_CONTAINER_FORCEINLINE void priv_copy(const CharT* first, const CharT* last, CharT* result)
{ Traits::copy(result, first, last - first); }
{ Traits::copy(result, first, std::size_t(last - first)); }
template <class Integer>
BOOST_CONTAINER_FORCEINLINE basic_string& priv_replace_dispatch(const_iterator first, const_iterator last,

View File

@@ -94,6 +94,7 @@ class vec_iterator
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
@@ -194,6 +195,7 @@ class vec_iterator
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; }
@@ -417,10 +419,10 @@ struct vector_alloc_holder
{ 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); }
@@ -450,7 +452,7 @@ struct vector_alloc_holder
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);
@@ -470,8 +472,8 @@ struct vector_alloc_holder
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");
@@ -647,10 +649,10 @@ struct vector_alloc_holder<Allocator, StoredSizeType, version_0>
{ 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)
{
@@ -813,7 +815,7 @@ private:
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:
@@ -1290,9 +1292,10 @@ private:
>::type * = 0)
)
{
typedef typename iterator_traits<FwdIt>::size_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");
}
@@ -1400,7 +1403,7 @@ private:
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)
}
@@ -1464,7 +1467,7 @@ private:
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)
}
@@ -1621,7 +1624,7 @@ private:
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()
@@ -1649,7 +1652,7 @@ private:
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.
@@ -1682,7 +1685,7 @@ private:
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.
@@ -1700,7 +1703,7 @@ private:
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().
@@ -1990,13 +1993,13 @@ private:
)
{
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)
@@ -2009,8 +2012,9 @@ private:
>::type * = 0
)
{
typedef typename iterator_traits<FwdIt>::size_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");
}
@@ -2041,7 +2045,7 @@ private:
{
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);
@@ -2223,7 +2227,7 @@ private:
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!
@@ -2247,7 +2251,7 @@ private:
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{
@@ -2433,12 +2437,12 @@ private:
{ 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());
}
@@ -2622,7 +2626,7 @@ private:
++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
@@ -2750,7 +2754,7 @@ private:
++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>
@@ -2758,14 +2762,14 @@ private:
(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){
@@ -2797,7 +2801,7 @@ private:
( 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>
@@ -2843,10 +2847,10 @@ private:
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));
}
}
@@ -2922,7 +2926,9 @@ private:
//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{
@@ -3024,7 +3030,7 @@ private:
//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;
@@ -3039,7 +3045,7 @@ private:
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){
@@ -3174,7 +3180,7 @@ private:
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
@@ -3216,11 +3222,11 @@ private:
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){
@@ -3229,7 +3235,7 @@ private:
}
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;
@@ -3240,7 +3246,7 @@ private:
//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);
}
@@ -3267,8 +3273,8 @@ private:
//| 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){
@@ -3308,7 +3314,7 @@ private:
//|__________________________|_______________|________|_________|
//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);