summaryrefslogtreecommitdiff
path: root/boost/container/deque.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/container/deque.hpp')
-rw-r--r--boost/container/deque.hpp220
1 files changed, 115 insertions, 105 deletions
diff --git a/boost/container/deque.hpp b/boost/container/deque.hpp
index f2413f046a..dafcaa0c21 100644
--- a/boost/container/deque.hpp
+++ b/boost/container/deque.hpp
@@ -50,7 +50,6 @@
#include <boost/move/detail/move_helpers.hpp>
// other
#include <boost/assert.hpp>
-#include <boost/core/no_exceptions_support.hpp>
// std
#include <cstddef>
@@ -114,6 +113,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 +151,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 +190,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 +242,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 +273,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 +302,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 +354,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 +366,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,40 +430,39 @@ 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 {
+ BOOST_CONTAINER_TRY {
this->priv_create_nodes(nstart, nfinish);
}
- BOOST_CATCH(...){
+ BOOST_CONTAINER_CATCH(...){
this->priv_deallocate_map(this->members_.m_map, this->members_.m_map_size);
this->members_.m_map = 0;
this->members_.m_map_size = 0;
- BOOST_RETHROW
+ BOOST_CONTAINER_RETHROW
}
- BOOST_CATCH_END
+ BOOST_CONTAINER_CATCH_END
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());
// }
}
void priv_create_nodes(ptr_alloc_ptr nstart, ptr_alloc_ptr nfinish)
{
ptr_alloc_ptr cur = nstart;
- BOOST_TRY {
+ BOOST_CONTAINER_TRY {
for (; cur < nfinish; ++cur)
*cur = this->priv_allocate_node();
}
- BOOST_CATCH(...){
+ BOOST_CONTAINER_CATCH(...){
this->priv_destroy_nodes(nstart, cur);
- BOOST_RETHROW
+ BOOST_CONTAINER_RETHROW
}
- BOOST_CATCH_END
+ BOOST_CONTAINER_CATCH_END
}
void priv_destroy_nodes(ptr_alloc_ptr nstart, ptr_alloc_ptr nfinish) BOOST_NOEXCEPT_OR_NOTHROW
@@ -538,6 +549,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 +582,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;
+
//////////////////////////////////////////////
//
@@ -610,7 +624,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
BOOST_CONTAINER_FORCEINLINE explicit deque(size_type n)
: Base(n, allocator_type())
{
- dtl::insert_value_initialized_n_proxy<ValAllocator, iterator> proxy;
+ dtl::insert_value_initialized_n_proxy<ValAllocator> proxy;
proxy.uninitialized_copy_n_and_update(this->alloc(), this->begin(), n);
//deque_base will deallocate in case of exception...
}
@@ -627,7 +641,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
BOOST_CONTAINER_FORCEINLINE deque(size_type n, default_init_t)
: Base(n, allocator_type())
{
- dtl::insert_default_initialized_n_proxy<ValAllocator, iterator> proxy;
+ dtl::insert_default_initialized_n_proxy<ValAllocator> proxy;
proxy.uninitialized_copy_n_and_update(this->alloc(), this->begin(), n);
//deque_base will deallocate in case of exception...
}
@@ -642,7 +656,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
BOOST_CONTAINER_FORCEINLINE explicit deque(size_type n, const allocator_type &a)
: Base(n, a)
{
- dtl::insert_value_initialized_n_proxy<ValAllocator, iterator> proxy;
+ dtl::insert_value_initialized_n_proxy<ValAllocator> proxy;
proxy.uninitialized_copy_n_and_update(this->alloc(), this->begin(), n);
//deque_base will deallocate in case of exception...
}
@@ -659,7 +673,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
BOOST_CONTAINER_FORCEINLINE deque(size_type n, default_init_t, const allocator_type &a)
: Base(n, a)
{
- dtl::insert_default_initialized_n_proxy<ValAllocator, iterator> proxy;
+ dtl::insert_default_initialized_n_proxy<ValAllocator> proxy;
proxy.uninitialized_copy_n_and_update(this->alloc(), this->begin(), n);
//deque_base will deallocate in case of exception...
}
@@ -903,7 +917,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 +959,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 +1156,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.
//!
@@ -1167,7 +1180,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
this->priv_erase_last_n(len - new_size);
else{
const size_type n = new_size - this->size();
- dtl::insert_value_initialized_n_proxy<ValAllocator, iterator> proxy;
+ dtl::insert_value_initialized_n_proxy<ValAllocator> proxy;
priv_insert_back_aux_impl(n, proxy);
}
}
@@ -1187,7 +1200,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
this->priv_erase_last_n(len - new_size);
else{
const size_type n = new_size - this->size();
- dtl::insert_default_initialized_n_proxy<ValAllocator, iterator> proxy;
+ dtl::insert_default_initialized_n_proxy<ValAllocator> proxy;
priv_insert_back_aux_impl(n, proxy);
}
}
@@ -1202,7 +1215,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 +1348,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 +1366,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().
@@ -1449,7 +1462,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
return r;
}
else{
- typedef dtl::insert_nonmovable_emplace_proxy<ValAllocator, iterator, Args...> type;
+ typedef dtl::insert_nonmovable_emplace_proxy<ValAllocator, Args...> type;
return *this->priv_insert_front_aux_impl(1, type(boost::forward<Args>(args)...));
}
}
@@ -1475,7 +1488,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
return r;
}
else{
- typedef dtl::insert_nonmovable_emplace_proxy<ValAllocator, iterator, Args...> type;
+ typedef dtl::insert_nonmovable_emplace_proxy<ValAllocator, Args...> type;
return *this->priv_insert_back_aux_impl(1, type(boost::forward<Args>(args)...));
}
}
@@ -1502,7 +1515,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
return (this->end()-1);
}
else{
- typedef dtl::insert_emplace_proxy<ValAllocator, iterator, Args...> type;
+ typedef dtl::insert_emplace_proxy<ValAllocator, Args...> type;
return this->priv_insert_aux_impl(p, 1, type(boost::forward<Args>(args)...));
}
}
@@ -1522,7 +1535,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
}\
else{\
typedef dtl::insert_nonmovable_emplace_proxy##N\
- <ValAllocator, iterator BOOST_MOVE_I##N BOOST_MOVE_TARG##N> type;\
+ <ValAllocator BOOST_MOVE_I##N BOOST_MOVE_TARG##N> type;\
return *priv_insert_front_aux_impl(1, type(BOOST_MOVE_FWD##N));\
}\
}\
@@ -1539,7 +1552,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
}\
else{\
typedef dtl::insert_nonmovable_emplace_proxy##N\
- <ValAllocator, iterator BOOST_MOVE_I##N BOOST_MOVE_TARG##N> type;\
+ <ValAllocator BOOST_MOVE_I##N BOOST_MOVE_TARG##N> type;\
return *priv_insert_back_aux_impl(1, type(BOOST_MOVE_FWD##N));\
}\
}\
@@ -1558,7 +1571,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
}\
else{\
typedef dtl::insert_emplace_proxy_arg##N\
- <ValAllocator, iterator BOOST_MOVE_I##N BOOST_MOVE_TARG##N> type;\
+ <ValAllocator BOOST_MOVE_I##N BOOST_MOVE_TARG##N> type;\
return this->priv_insert_aux_impl(p, 1, type(BOOST_MOVE_FWD##N));\
}\
}
@@ -1649,7 +1662,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 +1693,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;
}
@@ -1716,8 +1728,8 @@ 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);
+ dtl::insert_range_proxy<ValAllocator, FwdIt> proxy(first);
+ return priv_insert_aux_impl(p, boost::container::iterator_udistance(first, last), proxy);
}
#endif
@@ -1772,7 +1784,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 +1793,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 +1817,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 +1860,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 +1941,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 +2063,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 +2079,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 +2109,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,21 +2121,21 @@ 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);
- BOOST_TRY{
+ (this->alloc(), pos, old_finish, old_finish + difference_type(raw_gap));
+ BOOST_CONTAINER_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);
- BOOST_RETHROW
+ BOOST_CONTAINER_CATCH(...){
+ this->priv_destroy_range(old_finish, old_finish + difference_type(elemsafter));
+ BOOST_CONTAINER_RETHROW
}
- BOOST_CATCH_END
+ BOOST_CONTAINER_CATCH_END
this->members_.m_finish = new_finish;
}
}
}
- return this->begin() + pos_n;
+ return this->begin() + difference_type(pos_n);
}
template <class InsertProxy>
@@ -2137,7 +2149,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 +2167,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());
}
@@ -2164,58 +2175,58 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
void priv_fill_initialize(const value_type& value)
{
index_pointer cur = this->members_.m_start.m_node;
- BOOST_TRY {
+ BOOST_CONTAINER_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);
}
- BOOST_CATCH(...){
+ BOOST_CONTAINER_CATCH(...){
this->priv_destroy_range(this->members_.m_start, iterator(*cur, cur, get_block_size()));
- BOOST_RETHROW
+ BOOST_CONTAINER_RETHROW
}
- BOOST_CATCH_END
+ BOOST_CONTAINER_CATCH_END
}
template <class InIt>
void priv_range_initialize(InIt first, InIt last, typename iterator_enable_if_tag<InIt, std::input_iterator_tag>::type* =0)
{
this->priv_initialize_map(0);
- BOOST_TRY {
+ BOOST_CONTAINER_TRY {
for ( ; first != last; ++first)
this->emplace_back(*first);
}
- BOOST_CATCH(...){
+ BOOST_CONTAINER_CATCH(...){
this->clear();
- BOOST_RETHROW
+ BOOST_CONTAINER_RETHROW
}
- BOOST_CATCH_END
+ BOOST_CONTAINER_CATCH_END
}
template <class FwdIt>
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 {
+ BOOST_CONTAINER_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;
}
::boost::container::uninitialized_copy_alloc(this->alloc(), first, last, this->members_.m_finish.m_first);
}
- BOOST_CATCH(...){
+ BOOST_CONTAINER_CATCH(...){
this->priv_destroy_range(this->members_.m_start, iterator(*cur_node, cur_node, get_block_size()));
- BOOST_RETHROW
+ BOOST_CONTAINER_RETHROW
}
- BOOST_CATCH_END
+ BOOST_CONTAINER_CATCH_END
}
// Called only if this->members_.m_finish.m_cur == this->members_.m_finish.m_first.
@@ -2247,77 +2258,76 @@ 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);
}
size_type i = 1;
- BOOST_TRY {
+ BOOST_CONTAINER_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(...) {
+ BOOST_CONTAINER_CATCH(...) {
for (size_type j = 1; j < i; ++j)
- this->priv_deallocate_node(*(this->members_.m_start.m_node - j));
- BOOST_RETHROW
+ this->priv_deallocate_node(*(this->members_.m_start.m_node - difference_type(j)));
+ BOOST_CONTAINER_RETHROW
}
- BOOST_CATCH_END
+ BOOST_CONTAINER_CATCH_END
}
return this->members_.m_start - difference_type(n);
}
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 {
+ BOOST_CONTAINER_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(...) {
+ BOOST_CONTAINER_CATCH(...) {
for (size_type j = 1; j < i; ++j)
- this->priv_deallocate_node(*(this->members_.m_finish.m_node + j));
- BOOST_RETHROW
+ this->priv_deallocate_node(*(this->members_.m_finish.m_node + difference_type(j)));
+ BOOST_CONTAINER_RETHROW
}
- BOOST_CATCH_END
+ BOOST_CONTAINER_CATCH_END
}
return this->members_.m_finish + difference_type(n);
}
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 +2336,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
};