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

@@ -194,17 +194,17 @@ void list_test_template(std::size_t num_iterations, std::size_t num_elements, bo
<< ";" << ";"
<< num_elements << num_elements
<< ";" << ";"
<< float(tinsert)/(num_iterations*num_elements) << float(tinsert)/float(num_iterations*num_elements)
<< ";" << ";"
<< (unsigned int)insert_stats.system_bytes << (unsigned int)insert_stats.system_bytes
<< ";" << ";"
<< float(insert_stats.system_bytes)/(num_iterations*num_elements*sizeof_node)*100.0-100.0 << float(insert_stats.system_bytes)/float(num_iterations*num_elements*sizeof_node)*100.0-100.0
<< ";" << ";"
<< (unsigned int)insert_inuse << (unsigned int)insert_inuse
<< ";" << ";"
<< (float(insert_inuse)/(num_iterations*num_elements*sizeof_node)*100.0)-100.0 << (float(insert_inuse)/float(num_iterations*num_elements*sizeof_node)*100.0)-100.0
<< ";"; << ";";
std::cout << float(terase)/(num_iterations*num_elements) std::cout << float(terase)/float(num_iterations*num_elements)
<< ";" << ";"
<< (unsigned int)erase_stats.system_bytes << (unsigned int)erase_stats.system_bytes
<< ";" << ";"
@@ -215,11 +215,11 @@ void list_test_template(std::size_t num_iterations, std::size_t num_elements, bo
std::cout << std::endl std::cout << std::endl
<< "Allocator: " << get_allocator_name<Allocator>::get() << "Allocator: " << get_allocator_name<Allocator>::get()
<< std::endl << std::endl
<< " allocation/deallocation(ns): " << float(tinsert)/(num_iterations*num_elements) << '\t' << float(terase)/(num_iterations*num_elements) << " allocation/deallocation(ns): " << float(tinsert)/float(num_iterations*num_elements) << '\t' << float(terase)/float(num_iterations*num_elements)
<< std::endl << std::endl
<< " Sys MB(overh.)/Inuse MB(overh.): " << (float)insert_stats.system_bytes/(1024*1024) << "(" << float(insert_stats.system_bytes)/(num_iterations*num_elements*sizeof_node)*100.0-100.0 << "%)" << " Sys MB(overh.)/Inuse MB(overh.): " << (float)insert_stats.system_bytes/(1024*1024) << "(" << float(insert_stats.system_bytes)/float(num_iterations*num_elements*sizeof_node)*100.0-100.0 << "%)"
<< " / " << " / "
<< (float)insert_inuse/(1024*1024) << "(" << (float(insert_inuse)/(num_iterations*num_elements*sizeof_node)*100.0)-100.0 << "%)" << (float)insert_inuse/(1024*1024) << "(" << (float(insert_inuse)/float(num_iterations*num_elements*sizeof_node)*100.0)-100.0 << "%)"
<< std::endl << std::endl
<< " system MB/inuse bytes after: " << (float)erase_stats.system_bytes/(1024*1024) << '\t' << bc::dlmalloc_in_use_memory() << " system MB/inuse bytes after: " << (float)erase_stats.system_bytes/(1024*1024) << '\t' << bc::dlmalloc_in_use_memory()
<< std::endl << std::endl; << std::endl << std::endl;

View File

@@ -120,12 +120,12 @@ void allocation_timing_test(unsigned int num_iterations, unsigned int num_elemen
std::cout << " Malloc type: " << malloc_name std::cout << " Malloc type: " << malloc_name
<< std::endl << std::endl
<< " allocation ns: " << " allocation ns: "
<< float(nseconds)/(num_iterations*num_elements) << float(nseconds)/float(num_iterations*num_elements)
<< std::endl << std::endl
<< " capacity - alloc calls (new/expand): " << " capacity - alloc calls (new/expand): "
<< (unsigned int)capacity << " - " << (unsigned int)capacity << " - "
<< (float(numalloc) + float(numexpand))/num_iterations << (float(numalloc) + float(numexpand))/float(num_iterations)
<< "(" << float(numalloc)/num_iterations << "/" << float(numexpand)/num_iterations << ")" << "(" << float(numalloc)/float(num_iterations) << "/" << float(numexpand)/float(num_iterations) << ")"
<< std::endl << std::endl; << std::endl << std::endl;
dlmalloc_trim(0); dlmalloc_trim(0);
} }

View File

@@ -147,13 +147,13 @@ void vector_test_template(unsigned int num_iterations, unsigned int num_elements
<< ";" << ";"
<< capacity << capacity
<< ";" << ";"
<< float(nseconds)/(num_iterations*num_elements) << float(nseconds)/float(num_iterations*num_elements)
<< ";" << ";"
<< (float(numalloc) + float(numexpand))/num_iterations << (float(numalloc) + float(numexpand))/float(num_iterations)
<< ";" << ";"
<< float(numalloc)/num_iterations << float(numalloc)/float(num_iterations)
<< ";" << ";"
<< float(numexpand)/num_iterations << float(numexpand)/float(num_iterations)
<< std::endl; << std::endl;
} }
else{ else{
@@ -161,12 +161,12 @@ void vector_test_template(unsigned int num_iterations, unsigned int num_elements
<< "Allocator: " << get_allocator_name<Allocator>::get() << "Allocator: " << get_allocator_name<Allocator>::get()
<< std::endl << std::endl
<< " push_back ns: " << " push_back ns: "
<< float(nseconds)/(num_iterations*num_elements) << float(nseconds)/float(num_iterations*num_elements)
<< std::endl << std::endl
<< " capacity - alloc calls (new/expand): " << " capacity - alloc calls (new/expand): "
<< (unsigned int)capacity << " - " << (unsigned int)capacity << " - "
<< (float(numalloc) + float(numexpand))/num_iterations << (float(numalloc) + float(numexpand))/float(num_iterations)
<< "(" << float(numalloc)/num_iterations << "/" << float(numexpand)/num_iterations << ")" << "(" << float(numalloc)/float(num_iterations) << "/" << float(numexpand)/float(num_iterations) << ")"
<< std::endl; << std::endl;
std::cout << '\n' std::cout << '\n'
<< " ----------------------------------- " << " ----------------------------------- "

View File

@@ -151,12 +151,12 @@ void vector_test_template(unsigned int num_iterations, unsigned int num_elements
<< "Allocator: " << typeid(typename Container::allocator_type).name() << "Allocator: " << typeid(typename Container::allocator_type).name()
<< std::endl << std::endl
<< " push_back ns: " << " push_back ns: "
<< float(nseconds)/(num_iterations*num_elements) << float(nseconds)/float(num_iterations*num_elements)
<< std::endl << std::endl
<< " capacity - alloc calls (new/expand): " << " capacity - alloc calls (new/expand): "
<< (unsigned int)capacity << " - " << (unsigned int)capacity << " - "
<< (float(numalloc) + float(numexpand))/num_iterations << (float(numalloc) + float(numexpand))/float(num_iterations)
<< "(" << float(numalloc)/num_iterations << "/" << float(numexpand)/num_iterations << ")" << "(" << float(numalloc)/float(num_iterations) << "/" << float(numexpand)/float(num_iterations) << ")"
<< std::endl << std::endl; << std::endl << std::endl;
bc::dlmalloc_trim(0); bc::dlmalloc_trim(0);
} }

View File

@@ -114,7 +114,7 @@ void vector_test_template(unsigned int num_iterations, unsigned int num_elements
<< ";" << ";"
<< num_shrink << num_shrink
<< ";" << ";"
<< float(nseconds)/(num_iterations*num_elements) << float(nseconds)/float(num_iterations*num_elements)
<< std::endl; << std::endl;
} }
else{ else{
@@ -124,7 +124,7 @@ void vector_test_template(unsigned int num_iterations, unsigned int num_elements
<< " num_shrink: " << num_shrink << " num_shrink: " << num_shrink
<< std::endl << std::endl
<< " shrink_to_fit ns: " << " shrink_to_fit ns: "
<< float(nseconds)/(num_iterations*num_elements) << float(nseconds)/float(num_iterations*num_elements)
<< std::endl << std::endl; << std::endl << std::endl;
} }
bc::dlmalloc_trim(0); bc::dlmalloc_trim(0);

View File

@@ -123,7 +123,7 @@ void stable_vector_test_template(unsigned int num_iterations, unsigned int num_e
<< ";" << ";"
<< num_elements << num_elements
<< ";" << ";"
<< float(nseconds)/(num_iterations*num_elements) << float(nseconds)/float(num_iterations*num_elements)
<< ";"; << ";";
} }
else{ else{
@@ -132,7 +132,7 @@ void stable_vector_test_template(unsigned int num_iterations, unsigned int num_e
<< GetContainer<Allocator>::vector_name() << GetContainer<Allocator>::vector_name()
<< std::endl << std::endl
<< " allocation ns: " << " allocation ns: "
<< float(nseconds)/(num_iterations*num_elements); << float(nseconds)/float(num_iterations*num_elements);
} }
// top_capacity = l.capacity(); // top_capacity = l.capacity();
//Now preprocess ranges to erase //Now preprocess ranges to erase
@@ -160,13 +160,13 @@ void stable_vector_test_template(unsigned int num_iterations, unsigned int num_e
} }
if(csv_output){ if(csv_output){
std::cout << float(nseconds)/(num_iterations*num_elements) std::cout << float(nseconds)/float(num_iterations*num_elements)
<< std::endl; << std::endl;
} }
else{ else{
std::cout << '\t' std::cout << '\t'
<< " deallocation ns: " << " deallocation ns: "
<< float(nseconds)/(num_iterations*num_elements)/* << float(nseconds)/float(num_iterations*num_elements)/*
<< std::endl << std::endl
<< " max capacity: " << " max capacity: "
<< static_cast<unsigned int>(top_capacity) << static_cast<unsigned int>(top_capacity)

View File

@@ -241,7 +241,7 @@ void vector_test_template(std::size_t num_iterations, std::size_t num_elements,
nanosecond_type nseconds = timer.elapsed().wall; nanosecond_type nseconds = timer.elapsed().wall;
std::cout << cont_name << "->" << op.name() <<" ns: " std::cout << cont_name << "->" << op.name() <<" ns: "
<< float(nseconds)/(num_iterations*num_elements) << float(nseconds)/float(num_iterations*num_elements)
<< '\t' << '\t'
<< "Capacity: " << capacity << "Capacity: " << capacity
<< "\n"; << "\n";

View File

@@ -1617,7 +1617,7 @@ private:
// Linear O(N). // Linear O(N).
void swap_dispatch_impl(iterator first_sm, iterator last_sm, iterator first_la, iterator last_la, true_type const& /*use_memop*/) void swap_dispatch_impl(iterator first_sm, iterator last_sm, iterator first_la, iterator last_la, true_type const& /*use_memop*/)
{ {
//BOOST_ASSERT_MSG(boost::container::iterator_distance(first_sm, last_sm) <= boost::container::iterator_distance(first_la, last_la)); //BOOST_ASSERT_MSG(boost::container::iterator_udistance(first_sm, last_sm) <= boost::container::iterator_udistance(first_la, last_la));
namespace sv = varray_detail; namespace sv = varray_detail;
for (; first_sm != last_sm ; ++first_sm, ++first_la) for (; first_sm != last_sm ; ++first_sm, ++first_la)
@@ -1632,7 +1632,7 @@ private:
::memcpy((addressof)(*first_la), temp_ptr, sizeof(value_type)); ::memcpy((addressof)(*first_la), temp_ptr, sizeof(value_type));
} }
::memcpy(first_sm, first_la, sizeof(value_type) * boost::container::iterator_distance(first_la, last_la)); ::memcpy(first_sm, first_la, sizeof(value_type) * boost::container::iterator_udistance(first_la, last_la));
} }
// @par Throws // @par Throws
@@ -1641,7 +1641,7 @@ private:
// Linear O(N). // Linear O(N).
void swap_dispatch_impl(iterator first_sm, iterator last_sm, iterator first_la, iterator last_la, false_type const& /*use_memop*/) void swap_dispatch_impl(iterator first_sm, iterator last_sm, iterator first_la, iterator last_la, false_type const& /*use_memop*/)
{ {
//BOOST_ASSERT_MSG(boost::container::iterator_distance(first_sm, last_sm) <= boost::container::iterator_distance(first_la, last_la)); //BOOST_ASSERT_MSG(boost::container::iterator_udistance(first_sm, last_sm) <= boost::container::iterator_udistance(first_la, last_la));
namespace sv = varray_detail; namespace sv = varray_detail;
for (; first_sm != last_sm ; ++first_sm, ++first_la) for (; first_sm != last_sm ; ++first_sm, ++first_la)
@@ -1704,7 +1704,7 @@ private:
{ {
errh::check_iterator_end_eq(*this, position); errh::check_iterator_end_eq(*this, position);
size_type count = boost::container::iterator_distance(first, last); size_type count = boost::container::iterator_udistance(first, last);
errh::check_capacity(*this, m_size + count); // may throw errh::check_capacity(*this, m_size + count); // may throw
@@ -1736,16 +1736,16 @@ private:
{ {
namespace sv = varray_detail; namespace sv = varray_detail;
std::ptrdiff_t d = boost::container::iterator_distance(position, this->begin() + Capacity); std::size_t d = boost::container::iterator_udistance(position, this->begin() + Capacity);
std::size_t count = sv::uninitialized_copy_s(first, last, position, d); // may throw std::size_t count = sv::uninitialized_copy_s(first, last, position, d); // may throw
errh::check_capacity(*this, count <= static_cast<std::size_t>(d) ? m_size + count : Capacity + 1); // may throw errh::check_capacity(*this, count <= d ? m_size + count : Capacity + 1); // may throw
m_size += count; m_size += count;
} }
else else
{ {
size_type count = boost::container::iterator_distance(first, last); size_type count = boost::container::iterator_udistance(first, last);
errh::check_capacity(*this, m_size + count); // may throw errh::check_capacity(*this, m_size + count); // may throw
@@ -1799,7 +1799,7 @@ private:
{ {
namespace sv = varray_detail; namespace sv = varray_detail;
size_type s = boost::container::iterator_distance(first, last); size_type s = boost::container::iterator_udistance(first, last);
errh::check_capacity(*this, s); // may throw errh::check_capacity(*this, s); // may throw
@@ -1835,11 +1835,11 @@ private:
sv::destroy(it, this->end()); sv::destroy(it, this->end());
std::ptrdiff_t d = boost::container::iterator_distance(it, this->begin() + Capacity); std::size_t d = boost::container::iterator_udistance(it, this->begin() + Capacity);
std::size_t count = sv::uninitialized_copy_s(first, last, it, d); // may throw std::size_t count = sv::uninitialized_copy_s(first, last, it, d); // may throw
s += count; s += count;
errh::check_capacity(*this, count <= static_cast<std::size_t>(d) ? s : Capacity + 1); // may throw errh::check_capacity(*this, count <= d ? s : Capacity + 1); // may throw
m_size = s; // update end m_size = s; // update end
} }

View File

@@ -175,7 +175,7 @@ template <typename I, typename O>
inline O copy_dispatch(I first, I last, O dst, bcd::true_type const& /*use_memmove*/) inline O copy_dispatch(I first, I last, O dst, bcd::true_type const& /*use_memmove*/)
{ {
typedef typename ::boost::container::iterator_traits<I>::value_type value_type; typedef typename ::boost::container::iterator_traits<I>::value_type value_type;
const std::size_t d = boost::container::iterator_distance(first, last); const std::size_t d = boost::container::iterator_udistance(first, last);
::memmove(boost::container::dtl::addressof(*dst), boost::container::dtl::addressof(*first), sizeof(value_type) * d); ::memmove(boost::container::dtl::addressof(*dst), boost::container::dtl::addressof(*first), sizeof(value_type) * d);
return dst + d; return dst + d;
} }
@@ -205,7 +205,7 @@ O uninitialized_copy_dispatch(I first, I last, O dst,
bcd::true_type const& /*use_memcpy*/) bcd::true_type const& /*use_memcpy*/)
{ {
typedef typename ::boost::container::iterator_traits<I>::value_type value_type; typedef typename ::boost::container::iterator_traits<I>::value_type value_type;
const std::size_t d = boost::container::iterator_distance(first, last); const std::size_t d = boost::container::iterator_udistance(first, last);
::memcpy(boost::container::dtl::addressof(*dst), boost::container::dtl::addressof(*first), sizeof(value_type) * d); ::memcpy(boost::container::dtl::addressof(*dst), boost::container::dtl::addressof(*first), sizeof(value_type) * d);
return dst + d; return dst + d;
} }
@@ -237,7 +237,7 @@ O uninitialized_move_dispatch(I first, I last, O dst,
bcd::true_type const& /*use_memcpy*/) bcd::true_type const& /*use_memcpy*/)
{ {
typedef typename ::boost::container::iterator_traits<I>::value_type value_type; typedef typename ::boost::container::iterator_traits<I>::value_type value_type;
const std::size_t d = boost::container::iterator_distance(first, last); const std::size_t d = boost::container::iterator_udistance(first, last);
::memcpy(boost::container::dtl::addressof(*dst), boost::container::dtl::addressof(*first), sizeof(value_type) * d); ::memcpy(boost::container::dtl::addressof(*dst), boost::container::dtl::addressof(*first), sizeof(value_type) * d);
return dst + d; return dst + d;
} }
@@ -288,7 +288,7 @@ O move_dispatch(I first, I last, O dst,
bcd::true_type const& /*use_memmove*/) bcd::true_type const& /*use_memmove*/)
{ {
typedef typename ::boost::container::iterator_traits<I>::value_type value_type; typedef typename ::boost::container::iterator_traits<I>::value_type value_type;
const std::size_t d = boost::container::iterator_distance(first, last); const std::size_t d = boost::container::iterator_udistance(first, last);
::memmove(boost::container::dtl::addressof(*dst), boost::container::dtl::addressof(*first), sizeof(value_type)*d ); ::memmove(boost::container::dtl::addressof(*dst), boost::container::dtl::addressof(*first), sizeof(value_type)*d );
return dst + d; return dst + d;
} }
@@ -320,7 +320,7 @@ BDO move_backward_dispatch(BDI first, BDI last, BDO dst,
bcd::true_type const& /*use_memmove*/) bcd::true_type const& /*use_memmove*/)
{ {
typedef typename ::boost::container::iterator_traits<BDI>::value_type value_type; typedef typename ::boost::container::iterator_traits<BDI>::value_type value_type;
const std::size_t d = boost::container::iterator_distance(first, last); const std::size_t d = boost::container::iterator_udistance(first, last);
BDO foo(dst - d); BDO foo(dst - d);
::memmove(boost::container::dtl::addressof(*foo), boost::container::dtl::addressof(*first), sizeof(value_type) * d); ::memmove(boost::container::dtl::addressof(*foo), boost::container::dtl::addressof(*first), sizeof(value_type) * d);
return foo; return foo;

View File

@@ -114,6 +114,7 @@ class deque_iterator
typedef std::random_access_iterator_tag iterator_category; 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>::element_type value_type;
typedef typename boost::intrusive::pointer_traits<Pointer>::difference_type difference_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 typedef typename if_c
< IsConst < IsConst
, typename boost::intrusive::pointer_traits<Pointer>::template , 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) : 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 BOOST_CONTAINER_FORCEINLINE deque_iterator() BOOST_NOEXCEPT_OR_NOTHROW
: m_cur(), m_first(), m_last(), m_node() //Value initialization to achieve "null iterators" (N3644) : 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){ if(!this->m_cur && !x.m_cur){
return 0; 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); BOOST_ASSERT(block_size);
return block_size * (this->m_node - x.m_node - 1) + return block_size * (this->m_node - x.m_node - 1) +
(this->m_cur - this->m_first) + (x.m_last - x.m_cur); (this->m_cur - this->m_first) + (x.m_last - x.m_cur);
@@ -238,15 +243,15 @@ class deque_iterator
return *this; return *this;
BOOST_ASSERT(!!m_cur); BOOST_ASSERT(!!m_cur);
difference_type offset = n + (this->m_cur - this->m_first); 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); BOOST_ASSERT(block_size);
if (offset >= 0 && offset < block_size) if (offset >= 0 && offset < block_size)
this->m_cur += n; this->m_cur += difference_type(n);
else { else {
difference_type node_offset = difference_type node_offset =
offset > 0 ? (offset / block_size) offset > 0 ? (offset / block_size)
: (-difference_type((-offset - 1) / block_size) - 1); : (-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 + this->m_cur = this->m_first +
(offset - node_offset * block_size); (offset - node_offset * block_size);
} }
@@ -269,6 +274,7 @@ class deque_iterator
reference operator[](difference_type n) const BOOST_NOEXCEPT_OR_NOTHROW reference operator[](difference_type n) const BOOST_NOEXCEPT_OR_NOTHROW
{ return *(*this + n); } { return *(*this + n); }
//Comparisons
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
friend bool operator==(const deque_iterator& l, const deque_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW friend bool operator==(const deque_iterator& l, const deque_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW
{ return l.m_cur == r.m_cur; } { 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 friend deque_iterator operator+(difference_type n, deque_iterator x) BOOST_NOEXCEPT_OR_NOTHROW
{ return x += n; } { 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 BOOST_CONTAINER_FORCEINLINE void priv_set_node(index_pointer new_node, difference_type block_size) BOOST_NOEXCEPT_OR_NOTHROW
{ {
this->m_node = new_node; this->m_node = new_node;
@@ -346,6 +355,7 @@ class deque_base
typedef Allocator allocator_type; typedef Allocator allocator_type;
typedef allocator_type stored_allocator_type; typedef allocator_type stored_allocator_type;
typedef val_alloc_size size_type; typedef val_alloc_size size_type;
typedef val_alloc_diff difference_type;
private: private:
typedef typename get_deque_opt<Options>::type options_type; 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 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; } { 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 deque_value_traits<val_alloc_val> traits_t;
typedef ptr_alloc_t map_allocator_type; 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_size = dtl::max_value((size_type) InitialMapSize, num_nodes + 2);
this->members_.m_map = this->priv_allocate_map(this->members_.m_map_size); 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 nstart = this->members_.m_map + difference_type(this->members_.m_map_size - num_nodes) / 2;
ptr_alloc_ptr nfinish = nstart + num_nodes; ptr_alloc_ptr nfinish = nstart + difference_type(num_nodes);
BOOST_TRY { BOOST_TRY {
this->priv_create_nodes(nstart, nfinish); 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_start.priv_set_node(nstart, get_block_size());
this->members_.m_finish.priv_set_node(nfinish - 1, 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_start.m_cur = this->members_.m_start.m_first;
this->members_.m_finish.m_cur = this->members_.m_finish.m_first + this->members_.m_finish.m_cur = this->members_.m_finish.m_first + difference_type(num_elements % get_block_size());
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; typedef deque_base<typename real_allocator<T, Allocator>::type, Options> Base;
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
typedef typename real_allocator<T, Allocator>::type ValAllocator; typedef typename real_allocator<T, Allocator>::type ValAllocator;
typedef constant_iterator<T> c_it;
public: public:
@@ -570,10 +583,12 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
using Base::get_block_ssize;
public: public:
BOOST_CONSTEXPR BOOST_CONTAINER_FORCEINLINE static size_type get_block_size() BOOST_NOEXCEPT_OR_NOTHROW using Base::get_block_size;
{ return 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. //! <b>Complexity</b>: Linear to n.
BOOST_CONTAINER_FORCEINLINE void assign(size_type n, const T& val) 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()); 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 >::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()) { if (len > size()) {
FwdIt mid = first; FwdIt mid = first;
boost::container::iterator_advance(mid, this->size()); boost::container::iterator_uadvance(mid, this->size());
boost::container::copy(first, mid, begin()); boost::container::copy(first, mid, begin());
this->insert(this->cend(), mid, last); 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. //! <b>Complexity</b>: Constant.
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
size_type size() const BOOST_NOEXCEPT_OR_NOTHROW 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. //! <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(); const size_type len = size();
if (new_size < len) 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 else
this->insert(this->members_.m_finish, new_size - len, x); 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 iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW
{ {
BOOST_ASSERT(this->size() >= n); BOOST_ASSERT(this->size() >= n);
return iterator(this->begin()+n); return iterator(this->begin()+difference_type(n));
} }
//! <b>Requires</b>: size() >= 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 const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW
{ {
BOOST_ASSERT(this->size() >= n); 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(). //! <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) BOOST_CONTAINER_FORCEINLINE iterator insert(const_iterator pos, size_type n, const value_type& x)
{ {
//Range check of p is done by insert() //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()); 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 = this->emplace(it, *first);
++it; ++it;
} }
it -= n; it -= difference_type(n);
return it; 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)); BOOST_ASSERT(this->priv_in_range_or_end(p));
dtl::insert_range_proxy<ValAllocator, FwdIt, iterator> proxy(first); 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 #endif
@@ -1772,7 +1785,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
BOOST_ASSERT(this->priv_in_range(pos)); BOOST_ASSERT(this->priv_in_range(pos));
iterator next = pos.unconst(); iterator next = pos.unconst();
++next; ++next;
size_type index = pos - this->members_.m_start; size_type index = size_type(pos - this->members_.m_start);
if (index < (this->size()/2)) { if (index < (this->size()/2)) {
boost::container::move_backward(this->begin(), pos.unconst(), next); boost::container::move_backward(this->begin(), pos.unconst(), next);
pop_front(); 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()); boost::container::move(next, this->end(), pos.unconst());
pop_back(); 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). //! <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); const size_type elems_before = static_cast<size_type>(first - this->members_.m_start);
if (elems_before < (this->size() - n) - elems_before) { if (elems_before < (this->size() - n) - elems_before) {
boost::container::move_backward(begin(), first.unconst(), last.unconst()); 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_range(this->members_.m_start, new_start);
this->priv_destroy_nodes(this->members_.m_start.m_node, new_start.m_node); this->priv_destroy_nodes(this->members_.m_start.m_node, new_start.m_node);
this->members_.m_start = new_start; this->members_.m_start = new_start;
} }
else { else {
boost::container::move(last.unconst(), end(), first.unconst()); 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_range(new_finish, this->members_.m_finish);
this->priv_destroy_nodes(new_finish.m_node + 1, this->members_.m_finish.m_node + 1); this->priv_destroy_nodes(new_finish.m_node + 1, this->members_.m_finish.m_node + 1);
this->members_.m_finish = new_finish; 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; for (index_pointer node = this->members_.m_start.m_node + 1;
node < this->members_.m_finish.m_node; node < this->members_.m_finish.m_node;
++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); this->priv_deallocate_node(*node);
} }
@@ -1929,7 +1942,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
this->clear(); this->clear();
} }
else { 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_range(new_finish, this->members_.m_finish);
this->priv_destroy_nodes(new_finish.m_node + 1, this->members_.m_finish.m_node + 1); this->priv_destroy_nodes(new_finish.m_node + 1, this->members_.m_finish.m_node + 1);
this->members_.m_finish = new_finish; 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 priv_insert_aux_impl(const_iterator p, size_type n, InsertProxy proxy)
{ {
iterator pos(p.unconst()); 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){ if(!this->members_.m_map){
this->priv_initialize_map(0); this->priv_initialize_map(0);
pos = this->begin(); pos = this->begin();
@@ -2067,18 +2080,18 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
this->members_.m_start = new_start; this->members_.m_start = new_start;
} }
else{ else{
pos = this->members_.m_start + elemsbefore; pos = this->members_.m_start + difference_type(elemsbefore);
if (elemsbefore >= n) { 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 ::boost::container::uninitialized_move_alloc
(this->alloc(), this->members_.m_start, start_n, new_start); (this->alloc(), this->members_.m_start, start_n, new_start);
this->members_.m_start = new_start; this->members_.m_start = new_start;
boost::container::move(start_n, pos, old_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 { else {
const size_type mid_count = n - elemsbefore; 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); proxy.uninitialized_copy_n_and_update(this->alloc(), mid_start, mid_count);
this->members_.m_start = mid_start; this->members_.m_start = mid_start;
::boost::container::uninitialized_move_alloc ::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; this->members_.m_finish = new_finish;
} }
else{ else{
pos = old_finish - elemsafter; pos = old_finish - difference_type(elemsafter);
if (elemsafter >= n) { if (elemsafter >= n) {
iterator finish_n = old_finish - difference_type(n); iterator finish_n = old_finish - difference_type(n);
::boost::container::uninitialized_move_alloc ::boost::container::uninitialized_move_alloc
@@ -2109,13 +2122,13 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
else { else {
const size_type raw_gap = n - elemsafter; const size_type raw_gap = n - elemsafter;
::boost::container::uninitialized_move_alloc ::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{ BOOST_TRY{
proxy.copy_n_and_update(this->alloc(), pos, elemsafter); proxy.copy_n_and_update(this->alloc(), pos, elemsafter);
proxy.uninitialized_copy_n_and_update(this->alloc(), old_finish, raw_gap); proxy.uninitialized_copy_n_and_update(this->alloc(), old_finish, raw_gap);
} }
BOOST_CATCH(...){ 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_RETHROW
} }
BOOST_CATCH_END 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> 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; iterator old_finish = this->members_.m_finish;
proxy.uninitialized_copy_n_and_update(this->alloc(), old_finish, n); proxy.uninitialized_copy_n_and_update(this->alloc(), old_finish, n);
this->members_.m_finish = new_finish; 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> 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) 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()); 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 { BOOST_TRY {
for ( ; cur < this->members_.m_finish.m_node; ++cur){ for ( ; cur < this->members_.m_finish.m_node; ++cur){
boost::container::uninitialized_fill_alloc 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 boost::container::uninitialized_fill_alloc
(this->alloc(), this->members_.m_finish.m_first, this->members_.m_finish.m_cur, value); (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) void priv_range_initialize(FwdIt first, FwdIt last, typename iterator_disable_if_tag<FwdIt, std::input_iterator_tag>::type* =0)
{ {
size_type n = 0; size_type n = 0;
n = boost::container::iterator_distance(first, last); n = boost::container::iterator_udistance(first, last);
this->priv_initialize_map(n); this->priv_initialize_map(n);
index_pointer cur_node = this->members_.m_start.m_node; index_pointer cur_node = this->members_.m_start.m_node;
BOOST_TRY { BOOST_TRY {
for (; cur_node < this->members_.m_finish.m_node; ++cur_node) { for (; cur_node < this->members_.m_finish.m_node; ++cur_node) {
FwdIt mid = first; 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); ::boost::container::uninitialized_copy_alloc(this->alloc(), first, mid, *cur_node);
first = mid; 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) 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){ if (n > vacancies){
size_type new_elems = n-vacancies; size_type new_elems = n-vacancies;
size_type new_nodes = (new_elems + get_block_size() - 1) / size_type new_nodes = (new_elems + get_block_size() - 1u) / get_block_size();
get_block_size();
size_type s = (size_type)(this->members_.m_start.m_node - this->members_.m_map); size_type s = (size_type)(this->members_.m_start.m_node - this->members_.m_map);
if (new_nodes > s){ if (new_nodes > s){
this->priv_reallocate_map(new_nodes, true); 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; size_type i = 1;
BOOST_TRY { BOOST_TRY {
for (; i <= new_nodes; ++i) 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_CATCH(...) {
for (size_type j = 1; j < i; ++j) 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_RETHROW
} }
BOOST_CATCH_END 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) 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){ if (n > vacancies){
size_type new_elems = n - vacancies; size_type new_elems = size_type(n - vacancies);
size_type new_nodes = (new_elems + get_block_size() - 1)/get_block_size(); 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 - (this->members_.m_finish.m_node - this->members_.m_map)); 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){ if (new_nodes + 1 > s){
this->priv_reallocate_map(new_nodes, false); this->priv_reallocate_map(new_nodes, false);
} }
size_type i = 1; size_type i = 1;
BOOST_TRY { BOOST_TRY {
for (; i <= new_nodes; ++i) 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_CATCH(...) {
for (size_type j = 1; j < i; ++j) 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_RETHROW
} }
BOOST_CATCH_END 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) 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; size_type new_num_nodes = old_num_nodes + nodes_to_add;
index_pointer new_nstart; index_pointer new_nstart;
if (this->members_.m_map_size > 2 * new_num_nodes) { 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 new_nstart = this->members_.m_map + difference_type(this->members_.m_map_size - new_num_nodes) / 2
+ (add_at_front ? nodes_to_add : 0); + difference_type(add_at_front ? nodes_to_add : 0u);
if (new_nstart < this->members_.m_start.m_node) 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); boost::container::move(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1, new_nstart);
else else
boost::container::move_backward 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 { else {
size_type new_map_size = size_type new_map_size =
this->members_.m_map_size + dtl::max_value(this->members_.m_map_size, nodes_to_add) + 2; 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); index_pointer new_map = this->priv_allocate_map(new_map_size);
new_nstart = new_map + (new_map_size - new_num_nodes) / 2 new_nstart = new_map + difference_type(new_map_size - new_num_nodes) / 2
+ (add_at_front ? nodes_to_add : 0); + 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); 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); 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_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 #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 //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); 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) { 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; (void)offset;
BOOST_ASSERT(hdr_off_holder->hdr_offset == offset); BOOST_ASSERT(hdr_off_holder->hdr_offset == offset);
BOOST_ASSERT(0 == (reinterpret_cast<std::size_t>(hdr_off_holder) & (real_block_alignment - 1))); 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> template<class Allocator, class FwdIt, class Iterator>
struct move_insert_range_proxy struct move_insert_range_proxy
{ {
typedef typename allocator_traits<Allocator>::size_type size_type;
typedef typename allocator_traits<Allocator>::value_type value_type; typedef typename allocator_traits<Allocator>::value_type value_type;
BOOST_CONTAINER_FORCEINLINE explicit move_insert_range_proxy(FwdIt first) BOOST_CONTAINER_FORCEINLINE explicit move_insert_range_proxy(FwdIt first)
: first_(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 this->first_ = ::boost::container::uninitialized_move_alloc_n_source
(a, this->first_, n, p); (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); 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> template<class Allocator, class FwdIt, class Iterator>
struct insert_range_proxy struct insert_range_proxy
{ {
typedef typename allocator_traits<Allocator>::size_type size_type;
typedef typename allocator_traits<Allocator>::value_type value_type; typedef typename allocator_traits<Allocator>::value_type value_type;
BOOST_CONTAINER_FORCEINLINE explicit insert_range_proxy(FwdIt first) BOOST_CONTAINER_FORCEINLINE explicit insert_range_proxy(FwdIt first)
: first_(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); 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); this->first_ = ::boost::container::copy_n_source(this->first_, n, p);
} }
@@ -95,17 +93,16 @@ struct insert_range_proxy
template<class Allocator, class Iterator> template<class Allocator, class Iterator>
struct insert_n_copies_proxy struct insert_n_copies_proxy
{ {
typedef typename allocator_traits<Allocator>::size_type size_type;
typedef typename allocator_traits<Allocator>::value_type value_type; typedef typename allocator_traits<Allocator>::value_type value_type;
BOOST_CONTAINER_FORCEINLINE explicit insert_n_copies_proxy(const value_type &v) BOOST_CONTAINER_FORCEINLINE explicit insert_n_copies_proxy(const value_type &v)
: v_(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::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){ while (n){
--n; --n;
@@ -121,14 +118,13 @@ template<class Allocator, class Iterator>
struct insert_value_initialized_n_proxy struct insert_value_initialized_n_proxy
{ {
typedef ::boost::container::allocator_traits<Allocator> alloc_traits; 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 allocator_traits<Allocator>::value_type value_type;
typedef typename dtl::aligned_storage<sizeof(value_type), dtl::alignment_of<value_type>::value>::type storage_t; 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); } { 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){ while (n){
--n; --n;
@@ -146,14 +142,13 @@ template<class Allocator, class Iterator>
struct insert_default_initialized_n_proxy struct insert_default_initialized_n_proxy
{ {
typedef ::boost::container::allocator_traits<Allocator> alloc_traits; 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 allocator_traits<Allocator>::value_type value_type;
typedef typename dtl::aligned_storage<sizeof(value_type), dtl::alignment_of<value_type>::value>::type storage_t; 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); } { 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){ if(!is_pod<value_type>::value){
while (n){ while (n){
@@ -173,7 +168,6 @@ template<class Allocator, class Iterator>
struct insert_copy_proxy struct insert_copy_proxy
{ {
typedef boost::container::allocator_traits<Allocator> alloc_traits; 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 alloc_traits::value_type value_type;
static const bool single_value = true; static const bool single_value = true;
@@ -182,13 +176,13 @@ struct insert_copy_proxy
: v_(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_ASSERT(n == 1); (void)n; BOOST_ASSERT(n == 1); (void)n;
alloc_traits::construct( a, boost::movelib::iterator_to_raw_pointer(p), v_); 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; BOOST_ASSERT(n == 1); (void)n;
*p = v_; *p = v_;
@@ -202,7 +196,6 @@ template<class Allocator, class Iterator>
struct insert_move_proxy struct insert_move_proxy
{ {
typedef boost::container::allocator_traits<Allocator> alloc_traits; 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 alloc_traits::value_type value_type;
static const bool single_value = true; static const bool single_value = true;
@@ -211,13 +204,13 @@ struct insert_move_proxy
: v_(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_ASSERT(n == 1); (void)n; BOOST_ASSERT(n == 1); (void)n;
alloc_traits::construct( a, boost::movelib::iterator_to_raw_pointer(p), ::boost::move(v_) ); 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; BOOST_ASSERT(n == 1); (void)n;
*p = ::boost::move(v_); *p = ::boost::move(v_);
@@ -253,7 +246,6 @@ template<class Allocator, class Iterator, class ...Args>
struct insert_nonmovable_emplace_proxy struct insert_nonmovable_emplace_proxy
{ {
typedef boost::container::allocator_traits<Allocator> alloc_traits; 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 alloc_traits::value_type value_type;
typedef typename build_number_seq<sizeof...(Args)>::type index_tuple_t; typedef typename build_number_seq<sizeof...(Args)>::type index_tuple_t;
@@ -263,12 +255,12 @@ struct insert_nonmovable_emplace_proxy
: args_(args...) : 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); } { this->priv_uninitialized_copy_some_and_update(a, index_tuple_t(), p, n); }
private: private:
template<std::size_t ...IdxPack> 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; BOOST_ASSERT(n == 1); (void)n;
alloc_traits::construct( a, boost::movelib::iterator_to_raw_pointer(p), ::boost::forward<Args>(get<IdxPack>(this->args_))... ); 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 insert_nonmovable_emplace_proxy<Allocator, Iterator, Args...> base_t;
typedef boost::container::allocator_traits<Allocator> alloc_traits; typedef boost::container::allocator_traits<Allocator> alloc_traits;
typedef typename base_t::value_type value_type; 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; typedef typename base_t::index_tuple_t index_tuple_t;
static const bool single_value = true; static const bool single_value = true;
@@ -294,13 +285,13 @@ struct insert_emplace_proxy
: base_t(::boost::forward<Args>(args)...) : 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); } { this->priv_copy_some_and_update(a, index_tuple_t(), p, n); }
private: private:
template<std::size_t ...IdxPack> 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; BOOST_ASSERT(n ==1); (void)n;
typename dtl::aligned_storage<sizeof(value_type), dtl::alignment_of<value_type>::value>::type v; 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\ struct insert_nonmovable_emplace_proxy##N\
{\ {\
typedef boost::container::allocator_traits<Allocator> alloc_traits;\ 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 alloc_traits::value_type value_type;\
\ \
static const bool single_value = true;\ 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_CONTAINER_FORCEINLINE explicit insert_nonmovable_emplace_proxy##N(BOOST_MOVE_UREF##N)\
BOOST_MOVE_COLON##N BOOST_MOVE_FWD_INIT##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;\ 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);\ 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); }\ { BOOST_ASSERT(false); }\
\ \
protected:\ protected:\
@@ -414,7 +404,6 @@ struct insert_emplace_proxy_arg##N\
typedef insert_nonmovable_emplace_proxy##N\ typedef insert_nonmovable_emplace_proxy##N\
< Allocator, Iterator BOOST_MOVE_I##N BOOST_MOVE_TARG##N > base_t;\ < Allocator, Iterator BOOST_MOVE_I##N BOOST_MOVE_TARG##N > base_t;\
typedef typename base_t::value_type value_type;\ typedef typename base_t::value_type value_type;\
typedef typename base_t::size_type size_type;\
typedef boost::container::allocator_traits<Allocator> alloc_traits;\ typedef boost::container::allocator_traits<Allocator> alloc_traits;\
\ \
static const bool single_value = true;\ 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)\ BOOST_CONTAINER_FORCEINLINE explicit insert_emplace_proxy_arg##N(BOOST_MOVE_UREF##N)\
: base_t(BOOST_MOVE_FWD##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;\ BOOST_ASSERT(n == 1); (void)n;\
typename dtl::aligned_storage<sizeof(value_type), dtl::alignment_of<value_type>::value>::type v;\ 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_FORCEINLINE void construct_in_place(Allocator &a, T* dest, InpIt source)
{ boost::container::allocator_traits<Allocator>::construct(a, dest, *source); } { boost::container::allocator_traits<Allocator>::construct(a, dest, *source); }
template<class Allocator, class T, class U, class D> template<class Allocator, class T, class U>
BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, value_init_construct_iterator<U, D>) BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, value_init_construct_iterator<U>)
{ {
boost::container::allocator_traits<Allocator>::construct(a, dest); boost::container::allocator_traits<Allocator>::construct(a, dest);
} }
template <class T, class Difference> template <class T>
class default_init_construct_iterator; class default_init_construct_iterator;
template<class Allocator, class T, class U, class D> template<class Allocator, class T, class U>
BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, default_init_construct_iterator<U, D>) 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); 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; class emplace_iterator;
template<class Allocator, class T, class U, class EF, class D> template<class Allocator, class T, class U, class EF>
BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, emplace_iterator<U, EF, D> ei) BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T *dest, emplace_iterator<U, EF> ei)
{ {
ei.construct_in_place(a, dest); 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) BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, InpIt source)
{ *dest = *source; } { *dest = *source; }
template<class DstIt, class U, class D> template<class DstIt, class U>
BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, value_init_construct_iterator<U, D>) BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, value_init_construct_iterator<U>)
{ {
dtl::value_init<U> val; dtl::value_init<U> val;
*dest = boost::move(val.get()); *dest = boost::move(val.get());
} }
template <class DstIt, class Difference> template <class DstIt>
class default_init_construct_iterator; class default_init_construct_iterator;
template<class DstIt, class U, class D> 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; U u;
*dest = boost::move(u); *dest = boost::move(u);
} }
template <class T, class EmplaceFunctor, class Difference> template <class T, class EmplaceFunctor>
class emplace_iterator; class emplace_iterator;
template<class DstIt, class U, class EF, class D> template<class DstIt, class U, class EF>
BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, emplace_iterator<U, EF, D> ei) BOOST_CONTAINER_FORCEINLINE void assign_in_place(DstIt dest, emplace_iterator<U, EF> ei)
{ {
ei.assign_in_place(dest); ei.assign_in_place(dest);
} }

View File

@@ -174,14 +174,15 @@ template
typename F> // F models ForwardIterator typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE F memmove(I f, I l, F r) BOOST_NOEXCEPT_OR_NOTHROW 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); 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 beg_raw = boost::movelib::iterator_to_raw_pointer(f);
const value_type *const end_raw = boost::movelib::iterator_to_raw_pointer(l); const value_type *const end_raw = boost::movelib::iterator_to_raw_pointer(l);
if(BOOST_LIKELY(beg_raw != end_raw && dest_raw && beg_raw)){ 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); std::memmove(dest_raw, beg_raw, sizeof(value_type)*n);
r += n; r += static_cast<r_difference_type>(n);
} }
return r; return r;
} }
@@ -193,9 +194,10 @@ template
BOOST_CONTAINER_FORCEINLINE F memmove_n(I f, U n, F r) BOOST_NOEXCEPT_OR_NOTHROW 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; 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); 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; return r;
@@ -203,29 +205,31 @@ BOOST_CONTAINER_FORCEINLINE F memmove_n(I f, U n, F r) BOOST_NOEXCEPT_OR_NOTHROW
template template
<typename I, // I models InputIterator <typename I, // I models InputIterator
typename U, // U models unsigned integral constant
typename F> // F models ForwardIterator 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>::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); 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; return f;
} }
template template
<typename I, // I models InputIterator <typename I, // I models InputIterator
typename U, // U models unsigned integral constant
typename F> // F models ForwardIterator 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; 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); std::memmove(boost::movelib::iterator_to_raw_pointer(r), boost::movelib::iterator_to_raw_pointer(f), sizeof(value_type)*n);
f += n; f += i_difference_type(n);
r += n; r += f_difference_type(n);
} }
return f; return f;
} }
@@ -338,7 +342,7 @@ template
typename I, // I models InputIterator typename I, // I models InputIterator
typename F> // F models ForwardIterator typename F> // F models ForwardIterator
inline typename dtl::disable_if_memtransfer_copy_constructible<I, F, F>::type 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; F back = r;
BOOST_TRY{ BOOST_TRY{
@@ -363,7 +367,7 @@ template
typename I, // I models InputIterator typename I, // I models InputIterator
typename F> // F models ForwardIterator typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_constructible<I, F, F>::type 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); } { return dtl::memmove_n(f, n, r); }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@@ -384,7 +388,7 @@ template
typename I, // I models InputIterator typename I, // I models InputIterator
typename F> // F models ForwardIterator typename F> // F models ForwardIterator
inline typename dtl::disable_if_memtransfer_copy_constructible<I, F, I>::type 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; F back = r;
BOOST_TRY{ BOOST_TRY{
@@ -409,7 +413,7 @@ template
typename I, // I models InputIterator typename I, // I models InputIterator
typename F> // F models ForwardIterator typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_constructible<I, F, I>::type 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); } { return dtl::memmove_n_source(f, n, r); }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@@ -475,7 +479,7 @@ template
typename I, // I models InputIterator typename I, // I models InputIterator
typename F> // F models ForwardIterator typename F> // F models ForwardIterator
inline typename dtl::disable_if_memtransfer_copy_constructible<I, F, F>::type 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; F back = r;
BOOST_TRY{ BOOST_TRY{
@@ -500,7 +504,7 @@ template
typename I, // I models InputIterator typename I, // I models InputIterator
typename F> // F models ForwardIterator typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_constructible<I, F, F>::type 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); } { return dtl::memmove_n(f, n, r); }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@@ -521,7 +525,7 @@ template
typename I, // I models InputIterator typename I, // I models InputIterator
typename F> // F models ForwardIterator typename F> // F models ForwardIterator
inline typename dtl::disable_if_memtransfer_copy_constructible<I, F, I>::type 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; F back = r;
BOOST_TRY{ BOOST_TRY{
@@ -545,7 +549,7 @@ template
typename I, // I models InputIterator typename I, // I models InputIterator
typename F> // F models ForwardIterator typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_constructible<I, F, I>::type 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); } { return dtl::memmove_n_source(f, n, r); }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@@ -565,7 +569,7 @@ template
<typename Allocator, <typename Allocator,
typename F> // F models ForwardIterator typename F> // F models ForwardIterator
inline typename dtl::disable_if_memzero_initializable<F, F>::type 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; F back = r;
BOOST_TRY{ BOOST_TRY{
@@ -589,12 +593,14 @@ template
<typename Allocator, <typename Allocator,
typename F> // F models ForwardIterator typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memzero_initializable<F, F>::type 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; 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); 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; return r;
} }
@@ -615,7 +621,7 @@ BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memzero_initializable<F, F>:
template template
<typename Allocator, <typename Allocator,
typename F> // F models ForwardIterator 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; F back = r;
BOOST_TRY{ BOOST_TRY{
@@ -688,7 +694,7 @@ template
<typename Allocator, <typename Allocator,
typename T, typename T,
typename F> // F models ForwardIterator 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; F back = r;
BOOST_TRY{ BOOST_TRY{
@@ -786,10 +792,9 @@ inline typename dtl::disable_if_memtransfer_copy_assignable<I, F, I>::type
template template
<typename I, // I models InputIterator <typename I, // I models InputIterator
typename U, // U models unsigned integral constant
typename F> // F models ForwardIterator typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_assignable<I, F, I>::type 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); } { return dtl::memmove_n_source(f, n, r); }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@@ -800,10 +805,9 @@ BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_assignable<
template template
<typename I, // I models InputIterator <typename I, // I models InputIterator
typename U, // U models unsigned integral constant
typename F> // F models ForwardIterator typename F> // F models ForwardIterator
inline typename dtl::disable_if_memtransfer_copy_assignable<I, F, I>::type 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) { while (n) {
--n; --n;
@@ -815,10 +819,9 @@ inline typename dtl::disable_if_memtransfer_copy_assignable<I, F, I>::type
template template
<typename I, // I models InputIterator <typename I, // I models InputIterator
typename U, // U models unsigned integral constant
typename F> // F models ForwardIterator typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_assignable<I, F, I>::type 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); } { 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 move_backward(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;
const typename boost::container::iterator_traits<I>::difference_type n = boost::container::iterator_distance(f, l); const std::size_t n = boost::container::iterator_udistance(f, l);
if (BOOST_LIKELY(n)){ if (BOOST_LIKELY(n != 0)){
r -= n; r -= n;
std::memmove((boost::movelib::iterator_to_raw_pointer)(r), (boost::movelib::iterator_to_raw_pointer)(f), sizeof(value_type)*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 template
<typename I // I models InputIterator <typename I // I models InputIterator
,typename U // U models unsigned integral constant
,typename F> // F models ForwardIterator ,typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_assignable<I, F, I>::type 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); } { 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 template
<typename I // I models InputIterator <typename I // I models InputIterator
,typename U // U models unsigned integral constant
,typename F> // F models ForwardIterator ,typename F> // F models ForwardIterator
BOOST_CONTAINER_FORCEINLINE typename dtl::enable_if_memtransfer_copy_assignable<I, F, I>::type 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); } { return dtl::memmove_n_source(f, n, r); }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@@ -1010,15 +1011,14 @@ template
,typename G // G models ForwardIterator ,typename G // G models ForwardIterator
> >
inline typename dtl::disable_if_memtransfer_copy_assignable<F, G, void>::type 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 deep_swap_alloc_n( Allocator &a, F short_range_f, std::size_t n_i, G large_range_f, std::size_t n_j)
, G large_range_f, typename allocator_traits<Allocator>::size_type 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){ for (; n != n_i ; ++short_range_f, ++large_range_f, ++n){
boost::adl_move_swap(*short_range_f, *large_range_f); 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::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, n_j - n_i); 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 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 inline typename dtl::enable_if_c
< dtl::is_memtransfer_copy_assignable<F, G>::value && (MaxTmpBytes <= DeepSwapAllocNMaxStorage) && false < dtl::is_memtransfer_copy_assignable<F, G>::value && (MaxTmpBytes <= DeepSwapAllocNMaxStorage) && false
, void>::type , void>::type
deep_swap_alloc_n( Allocator &a, F short_range_f, typename allocator_traits<Allocator>::size_type n_i deep_swap_alloc_n( Allocator &a, F short_range_f, std::size_t n_i, G large_range_f, std::size_t n_j)
, G large_range_f, typename allocator_traits<Allocator>::size_type n_j)
{ {
typedef typename allocator_traits<Allocator>::value_type value_type; typedef typename allocator_traits<Allocator>::value_type value_type;
typedef typename dtl::aligned_storage 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(stora_ptr, large_ptr, n_i_bytes);
std::memcpy(large_ptr, short_ptr, n_i_bytes); std::memcpy(large_ptr, short_ptr, n_i_bytes);
std::memcpy(short_ptr, stora_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_uadvance(large_range_f, n_i);
boost::container::iterator_advance(short_range_f, n_i); boost::container::iterator_uadvance(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::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, n_j - n_i); boost::container::destroy_alloc_n(a, large_range_f, std::size_t(n_j - n_i));
} }
template template
@@ -1062,8 +1061,7 @@ template
inline typename dtl::enable_if_c inline typename dtl::enable_if_c
< dtl::is_memtransfer_copy_assignable<F, G>::value && true//(MaxTmpBytes > DeepSwapAllocNMaxStorage) < dtl::is_memtransfer_copy_assignable<F, G>::value && true//(MaxTmpBytes > DeepSwapAllocNMaxStorage)
, void>::type , void>::type
deep_swap_alloc_n( Allocator &a, F short_range_f, typename allocator_traits<Allocator>::size_type n_i deep_swap_alloc_n( Allocator &a, F short_range_f, std::size_t n_i, G large_range_f, std::size_t n_j)
, G large_range_f, typename allocator_traits<Allocator>::size_type n_j)
{ {
typedef typename allocator_traits<Allocator>::value_type value_type; typedef typename allocator_traits<Allocator>::value_type value_type;
typedef typename dtl::aligned_storage 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(stora_ptr, large_ptr, szt_rem);
std::memcpy(large_ptr, short_ptr, szt_rem); std::memcpy(large_ptr, short_ptr, szt_rem);
std::memcpy(short_ptr, stora_ptr, szt_rem); std::memcpy(short_ptr, stora_ptr, szt_rem);
boost::container::iterator_advance(large_range_f, n_i); boost::container::iterator_uadvance(large_range_f, n_i);
boost::container::iterator_advance(short_range_f, n_i); boost::container::iterator_uadvance(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::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, n_j - n_i); 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 I // F models InputIterator
,typename O // G models OutputIterator ,typename O // G models OutputIterator
> >
void copy_assign_range_alloc_n( Allocator &a, I inp_start, typename allocator_traits<Allocator>::size_type n_i void copy_assign_range_alloc_n( Allocator &a, I inp_start, std::size_t n_i, O out_start, std::size_t n_o )
, O out_start, typename allocator_traits<Allocator>::size_type n_o )
{ {
if (n_o < n_i){ if (n_o < n_i){
inp_start = boost::container::copy_n_source_dest(inp_start, n_o, out_start); // may throw 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{ else{
out_start = boost::container::copy_n(inp_start, n_i, out_start); // may throw 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 I // F models InputIterator
,typename O // G models OutputIterator ,typename O // G models OutputIterator
> >
void move_assign_range_alloc_n( Allocator &a, I inp_start, typename allocator_traits<Allocator>::size_type n_i void move_assign_range_alloc_n( Allocator &a, I inp_start, std::size_t n_i, O out_start, std::size_t n_o )
, O out_start, typename allocator_traits<Allocator>::size_type n_o )
{ {
if (n_o < n_i){ if (n_o < n_i){
inp_start = boost::container::move_n_source_dest(inp_start, n_o, out_start); // may throw 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{ else{
out_start = boost::container::move_n(inp_start, n_i, out_start); // may throw 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 pos
, F last , F last
, O d_first , O d_first
, typename allocator_traits<Allocator>::size_type n , std::size_t n
, InsertionProxy insert_range_proxy) , InsertionProxy insert_range_proxy)
{ {
typedef typename array_destructor<Allocator, F>::type array_destructor_t; typedef typename array_destructor<Allocator, F>::type array_destructor_t;
@@ -1228,7 +1224,7 @@ void expand_forward_and_insert_alloc
( Allocator &a ( Allocator &a
, F pos , F pos
, F last , F last
, typename allocator_traits<Allocator>::size_type n , std::size_t n
, InsertionProxy insert_range_proxy) , InsertionProxy insert_range_proxy)
{ {
typedef typename array_destructor<Allocator, F>::type array_destructor_t; 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); insert_range_proxy.uninitialized_copy_n_and_update(a, last, n);
} }
else{ else{
typedef typename allocator_traits<Allocator>::size_type alloc_size_type; const std::size_t elems_after = static_cast<std::size_t>(last - pos);
const alloc_size_type elems_after = static_cast<alloc_size_type>(last - pos);
if(elems_after >= n){ if(elems_after >= n){
//New elements can be just copied. //New elements can be just copied.
//Move to uninitialized memory last objects //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) //Copy first new elements in pos (gap is still there)
insert_range_proxy.copy_n_and_update(a, pos, elems_after); 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). //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(); on_exception.release();
} }
} }

View File

@@ -83,9 +83,8 @@ struct null_scoped_deallocator
{ {
typedef boost::container::allocator_traits<Allocator> AllocTraits; typedef boost::container::allocator_traits<Allocator> AllocTraits;
typedef typename AllocTraits::pointer pointer; 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() void release()
@@ -107,11 +106,11 @@ struct scoped_array_deallocator
typedef typename AllocTraits::pointer pointer; typedef typename AllocTraits::pointer pointer;
typedef typename AllocTraits::size_type size_type; 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) {} : m_ptr(p), m_alloc(a), m_length(length) {}
~scoped_array_deallocator() ~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() void release()
{ m_ptr = 0; } { m_ptr = 0; }
@@ -119,7 +118,7 @@ struct scoped_array_deallocator
private: private:
pointer m_ptr; pointer m_ptr;
Allocator& m_alloc; Allocator& m_alloc;
size_type m_length; std::size_t m_length;
}; };
template <class Allocator> template <class Allocator>
@@ -127,9 +126,8 @@ struct null_scoped_array_deallocator
{ {
typedef boost::container::allocator_traits<Allocator> AllocTraits; typedef boost::container::allocator_traits<Allocator> AllocTraits;
typedef typename AllocTraits::pointer pointer; 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() void release()
@@ -141,7 +139,6 @@ struct scoped_destroy_deallocator
{ {
typedef boost::container::allocator_traits<Allocator> AllocTraits; typedef boost::container::allocator_traits<Allocator> AllocTraits;
typedef typename AllocTraits::pointer pointer; typedef typename AllocTraits::pointer pointer;
typedef typename AllocTraits::size_type size_type;
typedef dtl::integral_constant<unsigned, typedef dtl::integral_constant<unsigned,
boost::container::dtl:: boost::container::dtl::
version<Allocator>::value> alloc_version; version<Allocator>::value> alloc_version;
@@ -181,23 +178,22 @@ struct scoped_destructor_n
typedef boost::container::allocator_traits<Allocator> AllocTraits; typedef boost::container::allocator_traits<Allocator> AllocTraits;
typedef typename AllocTraits::pointer pointer; typedef typename AllocTraits::pointer pointer;
typedef typename AllocTraits::value_type value_type; 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) : m_p(p), m_a(a), m_n(n)
{} {}
BOOST_CONTAINER_FORCEINLINE void release() BOOST_CONTAINER_FORCEINLINE void release()
{ m_p = 0; m_n = 0; } { 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; } { m_n += inc; }
BOOST_CONTAINER_FORCEINLINE void increment_size_backwards(size_type inc) BOOST_CONTAINER_FORCEINLINE void increment_size_backwards(std::size_t inc)
{ m_n += inc; m_p -= inc; } { m_n += inc; m_p -= std::ptrdiff_t(inc); }
BOOST_CONTAINER_FORCEINLINE void shrink_forward(size_type inc) BOOST_CONTAINER_FORCEINLINE void shrink_forward(std::size_t inc)
{ m_n -= inc; m_p += inc; } { m_n -= inc; m_p += std::ptrdiff_t(inc); }
~scoped_destructor_n() ~scoped_destructor_n()
{ {
@@ -214,7 +210,7 @@ struct scoped_destructor_n
private: private:
pointer m_p; pointer m_p;
Allocator & m_a; Allocator & m_a;
size_type m_n; std::size_t m_n;
}; };
//!A deleter for scoped_ptr that destroys //!A deleter for scoped_ptr that destroys
@@ -224,18 +220,17 @@ struct null_scoped_destructor_n
{ {
typedef boost::container::allocator_traits<Allocator> AllocTraits; typedef boost::container::allocator_traits<Allocator> AllocTraits;
typedef typename AllocTraits::pointer pointer; 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() 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 BOOST_CONTAINER_FORCEINLINE void flat_tree_merge_unique //has_merge_unique == false
(SequenceContainer& dest, Iterator first, Iterator last, Compare comp, dtl::false_) (SequenceContainer& dest, Iterator first, Iterator last, Compare comp, dtl::false_)
{ {
typedef typename SequenceContainer::iterator iterator; typedef typename SequenceContainer::iterator iterator;
typedef typename SequenceContainer::size_type size_type; typedef typename SequenceContainer::size_type size_type;
typedef typename SequenceContainer::difference_type difference_type;
size_type const old_sz = dest.size(); size_type const old_sz = dest.size();
iterator const first_new = dest.insert(dest.cend(), first, last ); iterator const first_new = dest.insert(dest.cend(), first, last );
iterator e = boost::movelib::inplace_set_unique_difference(first_new, dest.end(), dest.begin(), first_new, comp); iterator e = boost::movelib::inplace_set_unique_difference(first_new, dest.end(), dest.begin(), first_new, comp);
dest.erase(e, dest.end()); dest.erase(e, dest.end());
dtl::bool_<is_contiguous_container<SequenceContainer>::value> contiguous_tag; 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 flat_tree_nth // has_nth == false
(SequenceContainer& cont, typename SequenceContainer::size_type n, dtl::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); : this->priv_insert_unique_prepare(hint, k, data);
if(!ret.second){ if(!ret.second){
ret.first = this->nth(data.position - this->cbegin()); ret.first = this->nth(size_type(data.position - this->cbegin()));
} }
else{ else{
ret.first = this->m_data.m_seq.emplace(data.position, try_emplace_t(), ::boost::forward<KeyType>(key), ::boost::forward<Args>(args)...); 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);\ : this->priv_insert_unique_prepare(hint, k, data);\
\ \
if(!ret.second){\ if(!ret.second){\
ret.first = this->nth(data.position - this->cbegin());\ ret.first = this->nth(size_type(data.position - this->cbegin()));\
}\ }\
else{\ 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);\ 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(k, data)
: this->priv_insert_unique_prepare(hint, k, data); : this->priv_insert_unique_prepare(hint, k, data);
if(!ret.second){ 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); ret.first->second = boost::forward<M>(obj);
} }
else{ else{
@@ -1234,7 +1235,7 @@ class flat_tree
size_type count(const key_type& k) const size_type count(const key_type& k) const
{ {
std::pair<const_iterator, const_iterator> p = this->equal_range(k); 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; return n;
} }
@@ -1244,7 +1245,7 @@ class flat_tree
count(const K& k) const count(const K& k) const
{ {
std::pair<const_iterator, const_iterator> p = this->equal_range(k); 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; return n;
} }
@@ -1588,7 +1589,7 @@ class flat_tree
while (len) { while (len) {
size_type step = len >> 1; size_type step = len >> 1;
middle = first; middle = first;
middle += step; middle += difference_type(step);
if (key_cmp(key_extract(*middle), key)) { if (key_cmp(key_extract(*middle), key)) {
first = ++middle; first = ++middle;
@@ -1613,7 +1614,7 @@ class flat_tree
while (len) { while (len) {
size_type step = len >> 1; size_type step = len >> 1;
middle = first; middle = first;
middle += step; middle += difference_type(step);
if (key_cmp(key, key_extract(*middle))) { if (key_cmp(key, key_extract(*middle))) {
len = step; len = step;
@@ -1638,7 +1639,7 @@ class flat_tree
while (len) { while (len) {
size_type step = len >> 1; size_type step = len >> 1;
middle = first; middle = first;
middle += step; middle += difference_type(step);
if (key_cmp(key_extract(*middle), key)){ if (key_cmp(key_extract(*middle), key)){
first = ++middle; first = ++middle;
@@ -1650,7 +1651,7 @@ class flat_tree
else { else {
//Middle is equal to key //Middle is equal to key
last = first; last = first;
last += len; last += difference_type(len);
RanIt const first_ret = this->priv_lower_bound(first, middle, key); RanIt const first_ret = this->priv_lower_bound(first, middle, key);
return std::pair<RanIt, RanIt> return std::pair<RanIt, RanIt>
( first_ret, this->priv_upper_bound(++middle, last, key)); ( 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_traits;
using ::boost::intrusive::iterator_distance; using ::boost::intrusive::iterator_distance;
using ::boost::intrusive::iterator_udistance;
using ::boost::intrusive::iterator_advance; using ::boost::intrusive::iterator_advance;
using ::boost::intrusive::iterator_uadvance;
using ::boost::intrusive::iterator; using ::boost::intrusive::iterator;
using ::boost::intrusive::iterator_enable_if_tag; using ::boost::intrusive::iterator_enable_if_tag;
using ::boost::intrusive::iterator_disable_if_tag; using ::boost::intrusive::iterator_disable_if_tag;

View File

@@ -41,15 +41,15 @@
namespace boost { namespace boost {
namespace container { namespace container {
template <class T, class Difference = std::ptrdiff_t> template <class T>
class constant_iterator class constant_iterator
: public ::boost::container::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: 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){} : m_ptr(&ref), m_num(range_size){}
//Constructors //Constructors
@@ -94,41 +94,60 @@ class constant_iterator
BOOST_CONTAINER_FORCEINLINE friend bool operator>= (const constant_iterator& i, const constant_iterator& i2) BOOST_CONTAINER_FORCEINLINE friend bool operator>= (const constant_iterator& i, const constant_iterator& i2)
{ return !(i < 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); } { return i2.distance_to(i); }
//Arithmetic //Arithmetic signed
BOOST_CONTAINER_FORCEINLINE constant_iterator& operator+=(Difference off) BOOST_CONTAINER_FORCEINLINE constant_iterator& operator+=(std::ptrdiff_t off)
{ this->advance(off); return *this; } { 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); constant_iterator other(*this);
other.advance(off); other.advance(off);
return other; 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; } { 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; } { 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); } { return *this + (-off); }
BOOST_CONTAINER_FORCEINLINE const T& operator*() const BOOST_CONTAINER_FORCEINLINE const T& operator[] (std::ptrdiff_t ) const
{ return dereference(); } { return dereference(); }
BOOST_CONTAINER_FORCEINLINE const T& operator[] (Difference ) const BOOST_CONTAINER_FORCEINLINE const T& operator*() const
{ return dereference(); } { return dereference(); }
BOOST_CONTAINER_FORCEINLINE const T* operator->() const BOOST_CONTAINER_FORCEINLINE const T* operator->() const
{ return &(dereference()); } { 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: private:
const T * m_ptr; const T * m_ptr;
Difference m_num; std::size_t m_num;
BOOST_CONTAINER_FORCEINLINE void increment() BOOST_CONTAINER_FORCEINLINE void increment()
{ --m_num; } { --m_num; }
@@ -145,22 +164,22 @@ class constant_iterator
BOOST_CONTAINER_FORCEINLINE const T & dereference() const BOOST_CONTAINER_FORCEINLINE const T & dereference() const
{ return *m_ptr; } { return *m_ptr; }
BOOST_CONTAINER_FORCEINLINE void advance(Difference n) BOOST_CONTAINER_FORCEINLINE void advance(std::ptrdiff_t n)
{ m_num -= n; } { m_num = std::size_t(std::ptrdiff_t(m_num) - n); }
BOOST_CONTAINER_FORCEINLINE Difference distance_to(const this_type &other)const BOOST_CONTAINER_FORCEINLINE std::ptrdiff_t distance_to(const this_type &other)const
{ return m_num - other.m_num; } { return std::ptrdiff_t(m_num - other.m_num); }
}; };
template <class T, class Difference> template <class T>
class value_init_construct_iterator class value_init_construct_iterator
: public ::boost::container::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: 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){} : m_num(range_size){}
//Constructors //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) BOOST_CONTAINER_FORCEINLINE friend bool operator>= (const value_init_construct_iterator& i, const value_init_construct_iterator& i2)
{ return !(i < 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); } { return i2.distance_to(i); }
//Arithmetic //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; } { 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); value_init_construct_iterator other(*this);
other.advance(off); other.advance(off);
return other; 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; } { 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; } { 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); } { return *this + (-off); }
//This pseudo-iterator's dereference operations have no sense since value is not //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; //const T* operator->() const;
private: private:
Difference m_num; std::size_t m_num;
BOOST_CONTAINER_FORCEINLINE void increment() BOOST_CONTAINER_FORCEINLINE void increment()
{ --m_num; } { --m_num; }
@@ -256,22 +275,22 @@ class value_init_construct_iterator
return dummy; return dummy;
} }
BOOST_CONTAINER_FORCEINLINE void advance(Difference n) BOOST_CONTAINER_FORCEINLINE void advance(std::ptrdiff_t n)
{ m_num -= n; } { m_num = std::size_t(std::ptrdiff_t(m_num) - n); }
BOOST_CONTAINER_FORCEINLINE Difference distance_to(const this_type &other)const BOOST_CONTAINER_FORCEINLINE std::ptrdiff_t distance_to(const this_type &other)const
{ return m_num - other.m_num; } { return std::ptrdiff_t(m_num - other.m_num); }
}; };
template <class T, class Difference> template <class T>
class default_init_construct_iterator class default_init_construct_iterator
: public ::boost::container::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: 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){} : m_num(range_size){}
//Constructors //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) BOOST_CONTAINER_FORCEINLINE friend bool operator>= (const default_init_construct_iterator& i, const default_init_construct_iterator& i2)
{ return !(i < 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); } { return i2.distance_to(i); }
//Arithmetic //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; } { 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); default_init_construct_iterator other(*this);
other.advance(off); other.advance(off);
return other; 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; } { 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; } { 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); } { return *this + (-off); }
//This pseudo-iterator's dereference operations have no sense since value is not //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; //const T* operator->() const;
private: private:
Difference m_num; std::size_t m_num;
BOOST_CONTAINER_FORCEINLINE void increment() BOOST_CONTAINER_FORCEINLINE void increment()
{ --m_num; } { --m_num; }
@@ -367,22 +386,22 @@ class default_init_construct_iterator
return dummy; return dummy;
} }
BOOST_CONTAINER_FORCEINLINE void advance(Difference n) BOOST_CONTAINER_FORCEINLINE void advance(std::ptrdiff_t n)
{ m_num -= n; } { m_num = std::size_t(std::ptrdiff_t(m_num) - n); }
BOOST_CONTAINER_FORCEINLINE Difference distance_to(const this_type &other) const BOOST_CONTAINER_FORCEINLINE std::ptrdiff_t distance_to(const this_type &other) const
{ return m_num - other.m_num; } { return std::ptrdiff_t(m_num - other.m_num); }
}; };
template <class T, class Difference = std::ptrdiff_t> template <class T>
class repeat_iterator class repeat_iterator
: public ::boost::container::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: 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){} : m_ptr(&ref), m_num(range_size){}
//Constructors //Constructors
@@ -427,33 +446,33 @@ class repeat_iterator
BOOST_CONTAINER_FORCEINLINE friend bool operator>= (const this_type& i, const this_type& i2) BOOST_CONTAINER_FORCEINLINE friend bool operator>= (const this_type& i, const this_type& i2)
{ return !(i < 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); } { return i2.distance_to(i); }
//Arithmetic //Arithmetic
BOOST_CONTAINER_FORCEINLINE this_type& operator+=(Difference off) BOOST_CONTAINER_FORCEINLINE this_type& operator+=(std::ptrdiff_t off)
{ this->advance(off); return *this; } { 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); this_type other(*this);
other.advance(off); other.advance(off);
return other; 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; } { 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; } { 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); } { return *this + (-off); }
BOOST_CONTAINER_FORCEINLINE T& operator*() const BOOST_CONTAINER_FORCEINLINE T& operator*() const
{ return dereference(); } { return dereference(); }
BOOST_CONTAINER_FORCEINLINE T& operator[] (Difference ) const BOOST_CONTAINER_FORCEINLINE T& operator[] (std::ptrdiff_t ) const
{ return dereference(); } { return dereference(); }
BOOST_CONTAINER_FORCEINLINE T *operator->() const BOOST_CONTAINER_FORCEINLINE T *operator->() const
@@ -461,7 +480,7 @@ class repeat_iterator
private: private:
T * m_ptr; T * m_ptr;
Difference m_num; std::size_t m_num;
BOOST_CONTAINER_FORCEINLINE void increment() BOOST_CONTAINER_FORCEINLINE void increment()
{ --m_num; } { --m_num; }
@@ -478,22 +497,22 @@ class repeat_iterator
BOOST_CONTAINER_FORCEINLINE T & dereference() const BOOST_CONTAINER_FORCEINLINE T & dereference() const
{ return *m_ptr; } { return *m_ptr; }
BOOST_CONTAINER_FORCEINLINE void advance(Difference n) BOOST_CONTAINER_FORCEINLINE void advance(std::ptrdiff_t n)
{ m_num -= n; } { m_num = std::size_t(std::ptrdiff_t(m_num - n)); }
BOOST_CONTAINER_FORCEINLINE Difference distance_to(const this_type &other)const BOOST_CONTAINER_FORCEINLINE std::ptrdiff_t distance_to(const this_type &other)const
{ return m_num - other.m_num; } { 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 class emplace_iterator
: public ::boost::container::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; typedef emplace_iterator this_type;
public: public:
typedef Difference difference_type; typedef std::ptrdiff_t difference_type;
BOOST_CONTAINER_FORCEINLINE explicit emplace_iterator(EmplaceFunctor&e) BOOST_CONTAINER_FORCEINLINE explicit emplace_iterator(EmplaceFunctor&e)
: m_num(1), m_pe(&e){} : m_num(1), m_pe(&e){}
@@ -579,7 +598,7 @@ class emplace_iterator
{ (*m_pe)(dest); } { (*m_pe)(dest); }
private: private:
difference_type m_num; std::size_t m_num;
EmplaceFunctor * m_pe; EmplaceFunctor * m_pe;
BOOST_CONTAINER_FORCEINLINE void increment() 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); char_ptr elem = char_pointer_traits::static_cast_from(b);
if(num_units){ if(num_units){
char_ptr prev_elem = elem; char_ptr prev_elem = elem;
elem += unit_bytes; elem += difference_type(unit_bytes);
for(size_type i = 0; i != num_units-1; ++i, elem += 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); ::new (boost::movelib::to_raw_pointer(prev_elem), boost_container_new_t()) void_pointer(elem);
prev_elem = elem; prev_elem = elem;
} }

View File

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

View File

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

View File

@@ -711,7 +711,7 @@ class tree
{ {
//Optimized allocation and construction //Optimized allocation and construction
this->allocate_many_and_construct 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())); , insert_equal_end_hint_functor<Node, Icont>(this->icont()));
} }
@@ -728,7 +728,7 @@ class tree
{ {
//Optimized allocation and construction //Optimized allocation and construction
this->allocate_many_and_construct 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())); , dtl::push_back_functor<Node, Icont>(this->icont()));
//AllocHolder clears in case of exception //AllocHolder clears in case of exception
} }

View File

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

View File

@@ -444,7 +444,7 @@ class list
//! <b>Complexity</b>: Linear to n. //! <b>Complexity</b>: Linear to n.
BOOST_CONTAINER_FORCEINLINE void assign(size_type n, const T& val) 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()); return this->assign(cvalue_iterator(val, n), cvalue_iterator());
} }
@@ -676,7 +676,7 @@ class list
void resize(size_type new_size) void resize(size_type new_size)
{ {
if(!priv_try_shrink(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()); 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) iterator insert(const_iterator position, size_type n, const T& x)
{ {
//range check is done by insert //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()); return this->insert(position, cvalue_iterator(x, n), cvalue_iterator());
} }
@@ -966,7 +966,7 @@ class list
insertion_functor func(this->icont(), position.get()); insertion_functor func(this->icont(), position.get());
iterator before_p(position.get()); iterator before_p(position.get());
--before_p; --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; return ++before_p;
} }
#endif #endif

View File

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

View File

@@ -289,6 +289,7 @@ class stable_vector_iterator
typedef std::random_access_iterator_tag iterator_category; typedef std::random_access_iterator_tag iterator_category;
typedef typename non_const_ptr_traits::element_type value_type; 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::difference_type difference_type;
typedef typename non_const_ptr_traits::size_type size_type;
typedef typename ::boost::container::dtl::if_c typedef typename ::boost::container::dtl::if_c
< IsConst < IsConst
, typename non_const_ptr_traits::template , typename non_const_ptr_traits::template
@@ -383,6 +384,7 @@ class stable_vector_iterator
reference operator[](difference_type off) const BOOST_NOEXCEPT_OR_NOTHROW reference operator[](difference_type off) const BOOST_NOEXCEPT_OR_NOTHROW
{ return node_ptr_traits::static_cast_from(this->m_pn->up[off])->get_data(); } { 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 BOOST_CONTAINER_FORCEINLINE stable_vector_iterator& operator+=(difference_type off) BOOST_NOEXCEPT_OR_NOTHROW
{ {
if(off) this->m_pn = this->m_pn->up[off]; if(off) this->m_pn = this->m_pn->up[off];
@@ -416,6 +418,7 @@ class stable_vector_iterator
return tmp; return tmp;
} }
//Difference
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE 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 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; } { return left.m_pn->up - right.m_pn->up; }
@@ -916,7 +919,7 @@ class stable_vector
//! <b>Complexity</b>: Linear to n. //! <b>Complexity</b>: Linear to n.
BOOST_CONTAINER_FORCEINLINE void assign(size_type n, const T& t) 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()); 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. //! <b>Complexity</b>: Linear to the difference between size() and new_size.
void resize(size_type n) 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; BOOST_CONTAINER_STABLE_VECTOR_CHECK_INVARIANT;
if(n > this->size()) 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()) 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 //! <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 //! <b>Note</b>: Non-standard extension
void resize(size_type n, default_init_t) 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; BOOST_CONTAINER_STABLE_VECTOR_CHECK_INVARIANT;
if(n > this->size()) if(n > this->size())
this->insert(this->cend(), default_init_iterator(n - this->size()), default_init_iterator()); this->insert(this->cend(), default_init_iterator(n - this->size()), default_init_iterator());
else if(n < this->size()) 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 //! <b>Effects</b>: Inserts or erases elements at the end such that
@@ -1193,7 +1197,7 @@ class stable_vector
if(n > this->size()) if(n > this->size())
this->insert(this->cend(), n - this->size(), t); this->insert(this->cend(), n - this->size(), t);
else if(n < this->size()) 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. //! <b>Effects</b>: Number of elements for which memory has been allocated.
@@ -1490,7 +1494,7 @@ class stable_vector
reference emplace_back(Args &&...args) reference emplace_back(Args &&...args)
{ {
typedef emplace_functor<Args...> EmplaceFunctor; 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)...); EmplaceFunctor &&ef = EmplaceFunctor(boost::forward<Args>(args)...);
return *this->insert(this->cend(), EmplaceIterator(ef), EmplaceIterator()); return *this->insert(this->cend(), EmplaceIterator(ef), EmplaceIterator());
} }
@@ -1508,9 +1512,9 @@ class stable_vector
iterator emplace(const_iterator p, Args && ...args) iterator emplace(const_iterator p, Args && ...args)
{ {
BOOST_ASSERT(this->priv_in_range_or_end(p)); 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_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)...); EmplaceFunctor &&ef = EmplaceFunctor(boost::forward<Args>(args)...);
this->insert(p, EmplaceIterator(ef), EmplaceIterator()); this->insert(p, EmplaceIterator(ef), EmplaceIterator());
return iterator(this->begin() + pos_n); return iterator(this->begin() + pos_n);
@@ -1524,7 +1528,7 @@ class stable_vector
{\ {\
typedef emplace_functor##N\ typedef emplace_functor##N\
BOOST_MOVE_LT##N BOOST_MOVE_TARG##N BOOST_MOVE_GT##N EmplaceFunctor;\ 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;\ EmplaceFunctor ef BOOST_MOVE_LP##N BOOST_MOVE_FWD##N BOOST_MOVE_RP##N;\
return *this->insert(this->cend() , EmplaceIterator(ef), EmplaceIterator());\ return *this->insert(this->cend() , EmplaceIterator(ef), EmplaceIterator());\
}\ }\
@@ -1535,11 +1539,11 @@ class stable_vector
BOOST_ASSERT(this->priv_in_range_or_end(p));\ BOOST_ASSERT(this->priv_in_range_or_end(p));\
typedef emplace_functor##N\ typedef emplace_functor##N\
BOOST_MOVE_LT##N BOOST_MOVE_TARG##N BOOST_MOVE_GT##N EmplaceFunctor;\ 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;\ 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());\ 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) 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_ASSERT(this->priv_in_range_or_end(p));
BOOST_CONTAINER_STABLE_VECTOR_CHECK_INVARIANT; 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()); 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_ASSERT(this->priv_in_range_or_end(p));
BOOST_CONTAINER_STABLE_VECTOR_CHECK_INVARIANT; 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){ for(; first != last; ++first){
this->emplace(p, *first); this->emplace(p, *first);
} }
return this->begin() + pos_n; return this->begin() + difference_type(pos_n);
} }
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1671,7 +1675,7 @@ class stable_vector
insert(const_iterator p, FwdIt first, FwdIt last) insert(const_iterator p, FwdIt first, FwdIt last)
{ {
BOOST_ASSERT(this->priv_in_range_or_end(p)); 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()); const size_type idx = static_cast<size_type>(p - this->cbegin());
if(num_new){ if(num_new){
//Fills the node pool and inserts num_new null pointers in idx. //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 //past-new nodes are not aligned until the end of this function
//or in a rollback in case of exception //or in a rollback in case of exception
index_iterator it_past_newly_constructed(this->priv_insert_forward_non_templated(idx, num_new)); 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 //Prepare rollback
insert_rollback rollback(*this, it_past_newly_constructed, it_past_new); 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(...) //nodes before insertion p in priv_insert_forward_non_templated(...)
index_traits_type::fix_up_pointers_from(this->index, it_past_newly_constructed); 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 #endif
@@ -1724,7 +1728,7 @@ class stable_vector
{ {
BOOST_ASSERT(this->priv_in_range(p)); BOOST_ASSERT(this->priv_in_range(p));
BOOST_CONTAINER_STABLE_VECTOR_CHECK_INVARIANT; 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; index_iterator it = this->index.begin() + d;
this->priv_delete_node(p.node_pointer()); this->priv_delete_node(p.node_pointer());
it = this->index.erase(it); it = this->index.erase(it);
@@ -1749,10 +1753,11 @@ class stable_vector
size_type d_dif = d2 - d1; size_type d_dif = d2 - d1;
if(d_dif){ if(d_dif){
multiallocation_chain holder; multiallocation_chain holder;
const index_iterator it1(this->index.begin() + d1); const index_iterator it1(this->index.begin() + difference_type(d1));
const index_iterator it2(it1 + d_dif); const index_iterator it2(it1 + difference_type(d_dif));
index_iterator it(it1); index_iterator it(it1);
while(d_dif--){ while(d_dif){
--d_dif;
node_base_ptr &nb = *it; node_base_ptr &nb = *it;
++it; ++it;
node_type &n = *node_ptr_traits::static_cast_from(nb); node_type &n = *node_ptr_traits::static_cast_from(nb);
@@ -1861,7 +1866,7 @@ class stable_vector
//Check range //Check range
BOOST_ASSERT(this->index.empty() || (this->index.data() <= p->up)); BOOST_ASSERT(this->index.empty() || (this->index.data() <= p->up));
BOOST_ASSERT(this->index.empty() || p->up <= (this->index.data() + this->index.size())); 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 class insert_rollback
@@ -1920,15 +1925,15 @@ class stable_vector
//Now try to make room in the vector //Now try to make room in the vector
const node_base_ptr_ptr old_buffer = this->index.data(); 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; bool new_buffer = this->index.data() != old_buffer;
//Fix the pointers for the newly allocated buffer //Fix the pointers for the newly allocated buffer
const index_iterator index_beg = this->index.begin(); const index_iterator index_beg = this->index.begin();
if(new_buffer){ 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 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) iterator priv_insert(const_iterator p, const value_type &t)
{ {
BOOST_ASSERT(this->priv_in_range_or_end(p)); 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()); return this->insert(p, cvalue_iterator(t, 1), cvalue_iterator());
} }
iterator priv_insert(const_iterator p, BOOST_RV_REF(T) x) iterator priv_insert(const_iterator p, BOOST_RV_REF(T) x)
{ {
BOOST_ASSERT(this->priv_in_range_or_end(p)); 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; typedef boost::move_iterator<repeat_it> repeat_move_it;
//Just call more general insert(p, size, value) and return iterator //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())); 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; typedef Allocator allocator_type;
public: public:
typedef allocator_traits<allocator_type> allocator_traits_type; typedef allocator_traits<allocator_type> allocator_traits_type;
typedef allocator_type stored_allocator_type; typedef allocator_type stored_allocator_type;
typedef typename allocator_traits_type::pointer pointer; typedef typename allocator_traits_type::pointer pointer;
typedef typename allocator_traits_type::value_type value_type; typedef typename allocator_traits_type::value_type value_type;
typedef typename allocator_traits_type::size_type size_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; typedef ::boost::intrusive::pointer_traits<pointer> pointer_traits;
BOOST_CONTAINER_FORCEINLINE basic_string_base() BOOST_CONTAINER_FORCEINLINE basic_string_base()
@@ -414,8 +416,8 @@ class basic_string_base
BOOST_CONTAINER_FORCEINLINE pointer priv_end_addr() const BOOST_CONTAINER_FORCEINLINE pointer priv_end_addr() const
{ {
return this->is_short() return this->is_short()
? this->priv_short_addr() + this->priv_short_size() ? this->priv_short_addr() + difference_type(this->priv_short_size())
: this->priv_long_addr() + this->priv_long_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) 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) 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) #if defined(BOOST_GCC) && (BOOST_GCC >= 40700)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif
@@ -611,7 +623,7 @@ class basic_string
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
private: private:
typedef constant_iterator<CharT, difference_type> cvalue_iterator; typedef constant_iterator<CharT> cvalue_iterator;
typedef typename base_t::alloc_version alloc_version; typedef typename base_t::alloc_version alloc_version;
typedef ::boost::intrusive::pointer_traits<pointer> pointer_traits; typedef ::boost::intrusive::pointer_traits<pointer> pointer_traits;
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
@@ -751,7 +763,7 @@ class basic_string
: base_t() : base_t()
{ {
this->priv_terminate_string(); 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, //! <b>Effects</b>: Constructs a basic_string taking the allocator as parameter,
@@ -760,7 +772,7 @@ class basic_string
: base_t(a) : base_t(a)
{ {
this->priv_terminate_string(); 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, //! <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) void resize(size_type n, CharT c)
{ {
if (n <= this->size()) if (n <= this->size())
this->erase(this->begin() + n, this->end()); this->erase(this->begin() + difference_type(n), this->end());
else else
this->append(n - this->size(), c); this->append(n - this->size(), c);
} }
@@ -1172,7 +1184,7 @@ class basic_string
void resize(size_type n, default_init_t) void resize(size_type n, default_init_t)
{ {
if (n <= this->size()) if (n <= this->size())
this->erase(this->begin() + n, this->end()); this->erase(this->begin() + difference_type(n), this->end());
else{ else{
this->priv_reserve(n, false); this->priv_reserve(n, false);
this->priv_size(n); this->priv_size(n);
@@ -1310,7 +1322,7 @@ class basic_string
reference operator[](size_type n) BOOST_NOEXCEPT_OR_NOTHROW reference operator[](size_type n) BOOST_NOEXCEPT_OR_NOTHROW
{ {
BOOST_ASSERT(this->size() > n); BOOST_ASSERT(this->size() > n);
return *(this->priv_addr() + n); return *(this->priv_addr() + difference_type(n));
} }
//! <b>Requires</b>: size() > n. //! <b>Requires</b>: size() > n.
@@ -1325,7 +1337,7 @@ class basic_string
const_reference operator[](size_type n) const BOOST_NOEXCEPT_OR_NOTHROW const_reference operator[](size_type n) const BOOST_NOEXCEPT_OR_NOTHROW
{ {
BOOST_ASSERT(this->size() > n); BOOST_ASSERT(this->size() > n);
return *(this->priv_addr() + n); return *(this->priv_addr() + difference_type(n));
} }
//! <b>Requires</b>: size() > n. //! <b>Requires</b>: size() > n.
@@ -1341,7 +1353,7 @@ class basic_string
{ {
if (n >= this->size()) if (n >= this->size())
throw_out_of_range("basic_string::at invalid subscript"); 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. //! <b>Requires</b>: size() > n.
@@ -1356,7 +1368,7 @@ class basic_string
const_reference at(size_type n) const { const_reference at(size_type n) const {
if (n >= this->size()) if (n >= this->size())
throw_out_of_range("basic_string::at invalid subscript"); 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 //! <b>Returns</b>: *this
basic_string& append(const CharT* s, size_type n) 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. //! <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(); const size_type old_size = this->priv_size();
if (old_size < this->capacity()){ if (old_size < this->capacity()){
const pointer addr = this->priv_addr(); const pointer addr = this->priv_addr();
this->priv_construct_null(addr + old_size + 1); this->priv_construct_null(addr + difference_type(old_size + 1u));
Traits::assign(addr[old_size], c); Traits::assign(addr[difference_type(old_size)], c);
this->priv_size(old_size+1); this->priv_size(old_size+1u);
} }
else{ else{
//No enough memory, insert a new object at the end //No enough memory, insert a new object at the end
@@ -1538,7 +1550,7 @@ class basic_string
//! //!
//! <b>Returns</b>: *this //! <b>Returns</b>: *this
basic_string& assign(const CharT* s, size_type n) 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. //! <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); this->reserve(n);
CharT* ptr = boost::movelib::to_raw_pointer(this->priv_addr()); CharT* ptr = boost::movelib::to_raw_pointer(this->priv_addr());
Traits::copy(ptr, first, n); Traits::copy(ptr, first, n);
this->priv_construct_null(ptr + n); this->priv_construct_null(ptr + difference_type(n));
this->priv_size(n); this->priv_size(n);
return *this; return *this;
} }
@@ -1589,7 +1601,7 @@ class basic_string
++ptr; ++ptr;
} }
if (first == last) if (first == last)
this->erase(addr + cur, addr + old_size); this->erase(addr + difference_type(cur), addr + difference_type(old_size));
else else
this->append(first, last); this->append(first, last);
return *this; return *this;
@@ -1662,7 +1674,7 @@ class basic_string
throw_out_of_range("basic_string::insert out of range position"); throw_out_of_range("basic_string::insert out of range position");
if (this->size() > this->max_size() - n) if (this->size() > this->max_size() - n)
throw_length_error("basic_string::insert max_size() exceeded"); 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; return *this;
} }
@@ -1714,7 +1726,7 @@ class basic_string
//! <b>Returns</b>: An iterator which refers to the copy of the inserted character. //! <b>Returns</b>: An iterator which refers to the copy of the inserted character.
iterator insert(const_iterator p, CharT c) 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()); this->insert(p, cvalue_iterator(c, 1), cvalue_iterator());
return this->priv_addr() + new_offset; return this->priv_addr() + new_offset;
} }
@@ -1747,7 +1759,7 @@ class basic_string
for ( ; first != last; ++first, ++p) { for ( ; first != last; ++first, ++p) {
p = this->insert(p, *first); p = this->insert(p, *first);
} }
return this->begin() + n_pos; return this->begin() + difference_type(n_pos);
} }
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1760,9 +1772,9 @@ class basic_string
>::type * = 0 >::type * = 0
) )
{ {
const size_type n_pos = p - this->cbegin(); const size_type n_pos = size_type(p - this->cbegin());
if (first != last) { 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 old_size = this->priv_size();
const size_type remaining = this->capacity() - old_size; const size_type remaining = this->capacity() - old_size;
const pointer old_start = this->priv_addr(); const pointer old_start = this->priv_addr();
@@ -1780,7 +1792,7 @@ class basic_string
new_cap = this->next_capacity(n); new_cap = this->next_capacity(n);
hint = old_start; hint = old_start;
allocation_ret = this->allocation_command 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 //Check forward expansion
if(old_start == allocation_ret){ if(old_start == allocation_ret){
@@ -1791,29 +1803,29 @@ class basic_string
//Reuse same buffer //Reuse same buffer
if(enough_capacity){ 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; const size_type old_length = old_size;
if (elems_after >= n) { if (elems_after >= n) {
const pointer pointer_past_last = old_start + old_size + 1; const pointer pointer_past_last = old_start + difference_type(old_size + 1u);
priv_uninitialized_copy(old_start + (old_size - n + 1), priv_uninitialized_copy(old_start + difference_type(old_size - n + 1u),
pointer_past_last, pointer_past_last); pointer_past_last, pointer_past_last);
this->priv_size(old_size+n); 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), 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))); this->priv_copy(first, last, const_cast<CharT*>(boost::movelib::to_raw_pointer(p)));
} }
else { else {
ForwardIter mid = first; 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); const size_type newer_size = old_size + (n - elems_after);
this->priv_size(newer_size); this->priv_size(newer_size);
priv_uninitialized_copy priv_uninitialized_copy
(p, const_iterator(old_start + old_length + 1), (p, const_iterator(old_start + difference_type(old_length + 1u)),
old_start + newer_size); old_start + difference_type(newer_size));
this->priv_size(newer_size + elems_after); this->priv_size(newer_size + elems_after);
this->priv_copy(first, mid, const_cast<CharT*>(boost::movelib::to_raw_pointer(p))); 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 new_length += priv_uninitialized_copy
(const_iterator(old_start), p, new_start); (const_iterator(old_start), p, new_start);
new_length += priv_uninitialized_copy new_length += priv_uninitialized_copy
(first, last, new_start + new_length); (first, last, new_start + difference_type(new_length));
new_length += priv_uninitialized_copy new_length += priv_uninitialized_copy
(p, const_iterator(old_start + old_size), (p, const_iterator(old_start + difference_type(old_size)),
new_start + new_length); new_start + difference_type(new_length));
this->priv_construct_null(new_start + new_length); this->priv_construct_null(new_start + difference_type(new_length));
this->deallocate_block(); this->deallocate_block();
this->assure_long(); this->assure_long();
@@ -1845,14 +1857,14 @@ class basic_string
value_type * const oldbuf = boost::movelib::to_raw_pointer(old_start); value_type * const oldbuf = boost::movelib::to_raw_pointer(old_start);
value_type * const newbuf = boost::movelib::to_raw_pointer(new_start); value_type * const newbuf = boost::movelib::to_raw_pointer(new_start);
const value_type *const pos = boost::movelib::to_raw_pointer(p); 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 //First move old data
Traits::move(newbuf, oldbuf, before); 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 //Now initialize the new data
priv_uninitialized_copy(first, last, new_start + before); priv_uninitialized_copy(first, last, new_start + difference_type(before));
this->priv_construct_null(new_start + (old_size + n)); this->priv_construct_null(new_start + difference_type(old_size + n));
this->assure_long(); this->assure_long();
this->priv_long_addr(new_start); this->priv_long_addr(new_start);
this->priv_long_size(old_size + n); 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 #endif
@@ -1903,7 +1915,7 @@ class basic_string
if (pos > this->size()) if (pos > this->size())
throw_out_of_range("basic_string::erase out of range position"); throw_out_of_range("basic_string::erase out of range position");
const pointer addr = this->priv_addr(); 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; return *this;
} }
@@ -1920,8 +1932,8 @@ class basic_string
const size_type old_size = this->priv_size(); const size_type old_size = this->priv_size();
Traits::move(ptr, Traits::move(ptr,
boost::movelib::to_raw_pointer(p + 1), boost::movelib::to_raw_pointer(p + 1),
old_size - (p - this->priv_addr())); old_size - size_type(p - this->priv_addr()));
this->priv_size(old_size-1); this->priv_size(old_size-1u);
return iterator(ptr); return iterator(ptr);
} }
@@ -1937,11 +1949,11 @@ class basic_string
{ {
CharT * f = const_cast<CharT*>(boost::movelib::to_raw_pointer(first)); CharT * f = const_cast<CharT*>(boost::movelib::to_raw_pointer(first));
if (first != last) { // The move includes the terminating null. 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(); const size_type old_size = this->priv_size();
Traits::move(f, Traits::move(f,
boost::movelib::to_raw_pointer(last), 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; const size_type new_length = old_size - num_erased;
this->priv_size(new_length); this->priv_size(new_length);
} }
@@ -1980,8 +1992,8 @@ class basic_string
if (this->size() - len >= this->max_size() - str.size()) if (this->size() - len >= this->max_size() - str.size())
throw_length_error("basic_string::replace max_size() exceeded"); throw_length_error("basic_string::replace max_size() exceeded");
const pointer addr = this->priv_addr(); const pointer addr = this->priv_addr();
return this->replace( const_iterator(addr + pos1) return this->replace( const_iterator(addr + difference_type(pos1))
, const_iterator(addr + pos1 + len) , const_iterator(addr + difference_type(pos1 + len))
, str.begin(), str.end()); , str.begin(), str.end());
} }
@@ -2048,7 +2060,7 @@ class basic_string
if (n2 > max_size || (this->size() - len) >= (max_size - n2)) if (n2 > max_size || (this->size() - len) >= (max_size - n2))
throw_length_error("basic_string::replace max_size() exceeded"); throw_length_error("basic_string::replace max_size() exceeded");
const pointer addr = this->priv_addr() + pos1; 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. //! <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) if (n2 > this->max_size() || this->size() - len >= this->max_size() - n2)
throw_length_error("basic_string::replace max_size() exceeded"); throw_length_error("basic_string::replace max_size() exceeded");
const pointer addr = this->priv_addr(); 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. //! <b>Requires</b>: [begin(),i1) and [i1,i2) are valid ranges.
@@ -2108,7 +2120,7 @@ class basic_string
//! //!
//! <b>Returns</b>: *this //! <b>Returns</b>: *this
BOOST_CONTAINER_FORCEINLINE basic_string& replace(const_iterator i1, const_iterator i2, const CharT* s, size_type n) 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 //! <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. //! 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); const size_type len = static_cast<size_type>(i2 - i1);
if (len >= n) { if (len >= n) {
Traits::assign(const_cast<CharT*>(boost::movelib::to_raw_pointer(i1)), n, c); Traits::assign(const_cast<CharT*>(boost::movelib::to_raw_pointer(i1)), n, c);
erase(i1 + n, i2); erase(i1 + difference_type(n), i2);
} }
else { else {
Traits::assign(const_cast<CharT*>(boost::movelib::to_raw_pointer(i1)), len, c); 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; const difference_type len = i2 - i1;
if (len >= n) { if (len >= n) {
this->priv_copy(j1, j2, const_cast<CharT*>(boost::movelib::to_raw_pointer(i1))); 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 { else {
ForwardIter m = j1; ForwardIter m = j1;
@@ -2350,12 +2362,12 @@ class basic_string
return npos; return npos;
else { else {
const pointer addr = this->priv_addr(); const pointer addr = this->priv_addr();
pointer finish = addr + this->priv_size(); pointer finish = addr + difference_type(this->priv_size());
const const_iterator result = 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), boost::movelib::to_raw_pointer(finish),
s, s + n, Eq_traits<Traits>()); s, s + difference_type(n), Eq_traits<Traits>());
return result != finish ? result - begin() : npos; return result != finish ? size_type(result - begin()) : npos;
} }
} }
@@ -2379,11 +2391,11 @@ class basic_string
return npos; return npos;
else { else {
const pointer addr = this->priv_addr(); const pointer addr = this->priv_addr();
pointer finish = addr + sz; pointer finish = addr + difference_type(sz);
const const_iterator result = 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)); 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) else if (n == 0)
return dtl::min_value(len, pos); return dtl::min_value(len, pos);
else { 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 const const_iterator result = boost::container::find_end
(begin(), last, s, s + n, Eq_traits<Traits>()); (begin(), last, s, s + difference_type(n), Eq_traits<Traits>());
return result != last ? result - begin() : npos; return result != last ? size_type(result - begin()) : npos;
} }
} }
@@ -2459,7 +2471,7 @@ class basic_string
const_reverse_iterator rresult = const_reverse_iterator rresult =
boost::container::find_if(const_reverse_iterator(last), rend(), boost::container::find_if(const_reverse_iterator(last), rend(),
boost::container::bind2nd(Eq_traits<Traits>(), c)); 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; return npos;
else { else {
const pointer addr = this->priv_addr(); const pointer addr = this->priv_addr();
pointer finish = addr + sz; pointer finish = addr + difference_type(sz);
const_iterator result = boost::container::find_first_of const_iterator result = boost::container::find_first_of
(addr + pos, finish, s, s + n, Eq_traits<Traits>()); (addr + difference_type(pos), finish, s, s + difference_type(n), Eq_traits<Traits>());
return result != finish ? result - this->begin() : npos; return result != finish ? size_type(result - this->begin()) : npos;
} }
} }
@@ -2561,11 +2573,11 @@ class basic_string
return npos; return npos;
else { else {
const pointer addr = this->priv_addr(); 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 = const const_reverse_iterator rresult =
boost::container::find_first_of(const_reverse_iterator(last), rend(), boost::container::find_first_of(const_reverse_iterator(last), rend(),
s, s + n, Eq_traits<Traits>()); s, s + difference_type(n), Eq_traits<Traits>());
return rresult != rend() ? (rresult.base() - 1) - addr : npos; return rresult != rend() ? size_type((rresult.base() - 1) - addr) : npos;
} }
} }
@@ -2622,10 +2634,10 @@ class basic_string
return npos; return npos;
else { else {
const pointer addr = this->priv_addr(); 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 const const_iterator result = boost::container::find_if
(addr + pos, finish, Not_within_traits<Traits>(s, s + n)); (addr + difference_type(pos), finish, Not_within_traits<Traits>(s, s + difference_type(n)));
return result != finish ? result - addr : npos; return result != finish ? size_type(result - addr) : npos;
} }
} }
@@ -2648,11 +2660,11 @@ class basic_string
return npos; return npos;
else { else {
const pointer addr = this->priv_addr(); 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 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))); 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_iterator last = begin() + dtl::min_value(len - 1, pos) + 1;
const const_reverse_iterator rresult = const const_reverse_iterator rresult =
boost::container::find_if(const_reverse_iterator(last), rend(), boost::container::find_if(const_reverse_iterator(last), rend(),
Not_within_traits<Traits>(s, s + n)); Not_within_traits<Traits>(s, s + difference_type(n)));
return rresult != rend() ? (rresult.base() - 1) - begin() : npos; return rresult != rend() ? size_type((rresult.base() - 1) - begin()) : npos;
} }
} }
@@ -2724,7 +2736,7 @@ class basic_string
const const_reverse_iterator rresult = const const_reverse_iterator rresult =
boost::container::find_if(const_reverse_iterator(last), rend(), boost::container::find_if(const_reverse_iterator(last), rend(),
boost::container::not1(boost::container::bind2nd(Eq_traits<Traits>(), c))); 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()) if (pos > this->size())
throw_out_of_range("basic_string::substr out of range position"); throw_out_of_range("basic_string::substr out of range position");
const pointer addr = this->priv_addr(); const pointer addr = this->priv_addr();
return basic_string(addr + pos, return basic_string(addr + difference_type(pos),
addr + pos + dtl::min_value(n, size() - pos), this->alloc()); 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 //! <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 addr = this->priv_addr();
const pointer str_addr = str.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 //! <b>Throws</b>: Nothing
@@ -2771,7 +2783,7 @@ class basic_string
int compare(BasicStringView<CharT,Traits> sv) const int compare(BasicStringView<CharT,Traits> sv) const
{ {
const pointer addr = this->priv_addr(); 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() //! <b>Requires</b>: pos1 <= size()
@@ -2790,9 +2802,9 @@ class basic_string
throw_out_of_range("basic_string::compare out of range position"); throw_out_of_range("basic_string::compare out of range position");
const pointer addr = this->priv_addr(); const pointer addr = this->priv_addr();
const pointer str_addr = str.priv_addr(); const pointer str_addr = str.priv_addr();
return this->s_compare(addr + pos1, return this->s_compare(addr + difference_type(pos1),
addr + pos1 + dtl::min_value(n1, this->size() - pos1), addr + difference_type(pos1 + dtl::min_value(n1, this->size() - pos1)),
str_addr, str_addr + str.priv_size()); str_addr, str_addr + difference_type(str.priv_size()));
} }
//! <b>Requires</b>: pos1 <= size() //! <b>Requires</b>: pos1 <= size()
@@ -2808,7 +2820,7 @@ class basic_string
throw_out_of_range("basic_string::compare out of range position"); throw_out_of_range("basic_string::compare out of range position");
const pointer addr = this->priv_addr() + pos1; const pointer addr = this->priv_addr() + pos1;
const CharT* str_addr = sv.data(); 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()); str_addr, str_addr + sv.size());
} }
@@ -2827,8 +2839,8 @@ class basic_string
throw_out_of_range("basic_string::compare out of range position"); throw_out_of_range("basic_string::compare out of range position");
const pointer addr = this->priv_addr() + pos1; const pointer addr = this->priv_addr() + pos1;
const pointer str_addr = str.priv_addr() + pos2; const pointer str_addr = str.priv_addr() + pos2;
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 + dtl::min_value(n2, str.size() - pos2)); str_addr, str_addr + difference_type(dtl::min_value(n2, str.size() - pos2)));
} }
//! <b>Requires</b>: pos1 <= size() and pos2 <= str.size() //! <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"); throw_out_of_range("basic_string::compare out of range position");
const pointer addr = this->priv_addr() + pos1; const pointer addr = this->priv_addr() + pos1;
const CharT * str_addr = sv.data() + pos2; const CharT * str_addr = sv.data() + pos2;
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 + dtl::min_value(n2, sv.size() - pos2)); str_addr, str_addr + difference_type(dtl::min_value(n2, sv.size() - pos2)));
} }
//! <b>Throws</b>: Nothing //! <b>Throws</b>: Nothing
@@ -2858,7 +2870,7 @@ class basic_string
int compare(const CharT* s) const int compare(const CharT* s) const
{ {
const pointer addr = this->priv_addr(); 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. //! <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()) if (pos1 > this->size())
throw_out_of_range("basic_string::compare out of range position"); throw_out_of_range("basic_string::compare out of range position");
const pointer addr = this->priv_addr(); const pointer addr = this->priv_addr();
return this->s_compare( addr + pos1, return this->s_compare( addr + difference_type(pos1),
addr + pos1 + dtl::min_value(n1, this->size() - pos1), addr + difference_type(pos1 + dtl::min_value(n1, this->size() - pos1)),
s, s + n2); 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. //! <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(); const pointer addr = this->priv_addr();
new_length += priv_uninitialized_copy new_length += priv_uninitialized_copy
(addr, addr + this->priv_size(), new_start); (addr, addr + difference_type(this->priv_size()), new_start);
if(null_terminate){ 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->deallocate_block();
this->assure_long(); this->assure_long();
@@ -2918,8 +2930,8 @@ class basic_string
template<class It1, class It2> template<class It1, class It2>
static int s_compare(It1 f1, It1 l1, It2 f2, It2 l2) static int s_compare(It1 f1, It1 l1, It2 f2, It2 l2)
{ {
const difference_type n1 = l1 - f1; const std::size_t n1 = std::size_t(l1 - f1);
const difference_type n2 = l2 - f2; const std::size_t n2 = std::size_t(l2 - f2);
const int cmp = Traits::compare(boost::movelib::to_raw_pointer(f1), const int cmp = Traits::compare(boost::movelib::to_raw_pointer(f1),
boost::movelib::to_raw_pointer(f2), boost::movelib::to_raw_pointer(f2),
dtl::min_value(n1, n2)); 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) 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> template <class Integer>
BOOST_CONTAINER_FORCEINLINE basic_string& priv_replace_dispatch(const_iterator first, const_iterator last, 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; typedef typename boost::intrusive::pointer_traits<Pointer>::element_type element_type;
#endif #endif
typedef typename boost::intrusive::pointer_traits<Pointer>::difference_type difference_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 dtl::if_c typedef typename dtl::if_c
< IsConst < IsConst
, typename boost::intrusive::pointer_traits<Pointer>::template , 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 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; } { BOOST_ASSERT(left.m_ptr || !off); left.m_ptr -= off; return left; }
//Difference
BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE
friend difference_type operator-(const vec_iterator &left, const vec_iterator& right) BOOST_NOEXCEPT_OR_NOTHROW friend difference_type operator-(const vec_iterator &left, const vec_iterator& right) BOOST_NOEXCEPT_OR_NOTHROW
{ return left.m_ptr - right.m_ptr; } { return left.m_ptr - right.m_ptr; }
@@ -417,10 +419,10 @@ struct vector_alloc_holder
{ this->m_size = static_cast<stored_size_type>(s); } { this->m_size = static_cast<stored_size_type>(s); }
BOOST_CONTAINER_FORCEINLINE void dec_stored_size(size_type s) BOOST_NOEXCEPT_OR_NOTHROW 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 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 BOOST_CONTAINER_FORCEINLINE void set_stored_capacity(size_type c) BOOST_NOEXCEPT_OR_NOTHROW
{ this->m_capacity = static_cast<stored_size_type>(c); } { 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) bool try_expand_fwd(size_type at_least)
{ {
//There is not enough memory, try to expand the old one //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; size_type real_cap = new_cap;
pointer reuse = this->start(); pointer reuse = this->start();
bool const success = !!this->allocation_command(expand_fwd, new_cap, real_cap, reuse); 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)); BOOST_ASSERT(additional_objects > size_type(this->m_capacity - this->m_size));
size_type max = allocator_traits_type::max_size(this->alloc()); size_type max = allocator_traits_type::max_size(this->alloc());
(clamp_by_stored_size_type<size_type>)(max, stored_size_type()); (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 remaining_cap = size_type(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 min_additional_cap = size_type(additional_objects - size_type(this->m_capacity - this->m_size));
if ( remaining_cap < min_additional_cap ) if ( remaining_cap < min_additional_cap )
boost::container::throw_length_error("get_next_capacity, allocator's max size reached"); 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); } { this->m_size = static_cast<stored_size_type>(s); }
BOOST_CONTAINER_FORCEINLINE void dec_stored_size(size_type s) BOOST_NOEXCEPT_OR_NOTHROW 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 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) BOOST_CONTAINER_FORCEINLINE void priv_first_allocation(size_type cap)
{ {
@@ -813,7 +815,7 @@ private:
private: private:
BOOST_COPYABLE_AND_MOVABLE(vector) BOOST_COPYABLE_AND_MOVABLE(vector)
typedef vector_value_traits<allocator_type> value_traits; typedef vector_value_traits<allocator_type> value_traits;
typedef constant_iterator<T, difference_type> cvalue_iterator; typedef constant_iterator<T> cvalue_iterator;
protected: protected:
@@ -1290,9 +1292,10 @@ private:
>::type * = 0) >::type * = 0)
) )
{ {
typedef typename iterator_traits<FwdIt>::size_type it_size_type;
//For Fwd iterators the standard only requires EmplaceConstructible and assignable from *first //For Fwd iterators the standard only requires EmplaceConstructible and assignable from *first
//so we can't do any backwards allocation //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)){ if (sz > size_type(-1)){
boost::container::throw_length_error("vector::assign, FwdIt's max length reached"); 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 BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE iterator end() BOOST_NOEXCEPT_OR_NOTHROW
{ {
iterator it (this->m_holder.start()); 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) 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 BOOST_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW
{ {
const_iterator it (this->m_holder.start()); 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) 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_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE reference back() BOOST_NOEXCEPT_OR_NOTHROW
{ {
BOOST_ASSERT(!this->empty()); BOOST_ASSERT(!this->empty());
return this->m_holder.start()[this->m_holder.m_size - 1]; return this->m_holder.start()[difference_type(this->m_holder.m_size - 1u)];
} }
//! <b>Requires</b>: !empty() //! <b>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_CONTAINER_ATTRIBUTE_NODISCARD BOOST_CONTAINER_FORCEINLINE reference operator[](size_type n) BOOST_NOEXCEPT_OR_NOTHROW
{ {
BOOST_ASSERT(this->m_holder.m_size > n); BOOST_ASSERT(this->m_holder.m_size > n);
return this->m_holder.start()[n]; return this->m_holder.start()[difference_type(n)];
} }
//! <b>Requires</b>: size() > n. //! <b>Requires</b>: size() > n.
@@ -1682,7 +1685,7 @@ private:
iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW
{ {
BOOST_ASSERT(this->m_holder.m_size >= n); BOOST_ASSERT(this->m_holder.m_size >= n);
return iterator(this->m_holder.start()+n); return iterator(this->m_holder.start()+difference_type(n));
} }
//! <b>Requires</b>: size() >= n. //! <b>Requires</b>: size() >= n.
@@ -1700,7 +1703,7 @@ private:
const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW
{ {
BOOST_ASSERT(this->m_holder.m_size >= n); BOOST_ASSERT(this->m_holder.m_size >= n);
return const_iterator(this->m_holder.start()+n); return const_iterator(this->m_holder.start()+difference_type(n));
} }
//! <b>Requires</b>: begin() <= p <= end(). //! <b>Requires</b>: begin() <= p <= end().
@@ -1990,13 +1993,13 @@ private:
) )
{ {
BOOST_ASSERT(this->priv_in_range_or_end(pos)); 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)); iterator it(vector_iterator_get_ptr(pos));
for(;first != last; ++first){ for(;first != last; ++first){
it = this->emplace(it, *first); it = this->emplace(it, *first);
++it; ++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) #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -2009,8 +2012,9 @@ private:
>::type * = 0 >::type * = 0
) )
{ {
typedef typename iterator_traits<FwdIt>::size_type it_size_type;
BOOST_ASSERT(this->priv_in_range_or_end(pos)); 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)){ if (sz > size_type(-1)){
boost::container::throw_length_error("vector::insert, FwdIt's max length reached"); 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(this->priv_in_range_or_end(pos));
BOOST_ASSERT(dtl::is_input_iterator<InIt>::value || 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; (void)last;
dtl::insert_range_proxy<allocator_type, InIt, T*> proxy(first); dtl::insert_range_proxy<allocator_type, InIt, T*> proxy(first);
return this->priv_insert_forward_range(vector_iterator_get_ptr(pos), num, proxy); 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) bool stable_reserve(size_type new_cap)
{ {
const size_type cp = this->capacity(); 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! //Absolutely experimental. This function might change, disappear or simply crash!
@@ -2247,7 +2251,7 @@ private:
size_type const free_cap = c - s; 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 not input iterator and new elements don't fit in the remaining capacity, merge in new buffer
if(!dtl::is_input_iterator<InputIt>::value && 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()); this->priv_merge_in_new_buffer(first, n, comp, alloc_version());
} }
else{ else{
@@ -2433,12 +2437,12 @@ private:
{ return this->m_holder.m_size != this->m_holder.capacity(); } { return this->m_holder.m_size != this->m_holder.capacity(); }
BOOST_CONTAINER_FORCEINLINE pointer back_ptr() const 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_CONTAINER_FORCEINLINE size_type priv_index_of(pointer p) const
{ {
BOOST_ASSERT(this->m_holder.start() <= p); 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()); return static_cast<size_type>(p - this->m_holder.start());
} }
@@ -2622,7 +2626,7 @@ private:
++this->num_expand_bwd; ++this->num_expand_bwd;
#endif #endif
this->priv_insert_forward_range_expand_backwards 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 else{ //New buffer
#ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
@@ -2750,7 +2754,7 @@ private:
++this->num_alloc; ++this->num_alloc;
#endif #endif
this->priv_insert_forward_range_new_allocation(new_buf, new_cap, raw_pos, n, insert_range_proxy); 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> template <class InsertionProxy>
@@ -2758,14 +2762,14 @@ private:
(T *const raw_pos, const size_type n, const InsertionProxy insert_range_proxy, version_2) (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 //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 //There is not enough memory, allocate a new
//buffer or expand the old one. //buffer or expand the old one.
size_type real_cap = this->m_holder.template next_capacity<growth_factor_type>(n); size_type real_cap = this->m_holder.template next_capacity<growth_factor_type>(n);
pointer reuse(this->m_holder.start()); pointer reuse(this->m_holder.start());
pointer const ret (this->m_holder.allocation_command 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 //Buffer reallocated
if(reuse){ if(reuse){
@@ -2797,7 +2801,7 @@ private:
( boost::movelib::to_raw_pointer(ret), real_cap, raw_pos, n, insert_range_proxy); ( 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> template <class InsertionProxy>
@@ -2843,10 +2847,10 @@ private:
const size_type sz = this->m_holder.m_size; const size_type sz = this->m_holder.m_size;
if (new_size < sz){ if (new_size < sz){
//Destroy last elements //Destroy last elements
this->priv_destroy_last_n(sz - new_size); this->priv_destroy_last_n(size_type(sz - new_size));
} }
else { 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 //All uninitialized_moved
::boost::container::uninitialized_move_alloc ::boost::container::uninitialized_move_alloc
(this->m_holder.alloc(), first_ptr, last_ptr, first_ptr + shift_count); (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: //Case C:
else{ else{
@@ -3024,7 +3030,7 @@ private:
//We can have 8 possibilities: //We can have 8 possibilities:
const size_type elemsbefore = static_cast<size_type>(pos - old_start); 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 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; typedef typename value_traits::ArrayDestructor array_destructor_t;
@@ -3039,7 +3045,7 @@ private:
this->m_holder.set_stored_size(elemsbefore); this->m_holder.set_stored_size(elemsbefore);
insert_range_proxy.uninitialized_copy_n_and_update(a, new_elem_pos, n); insert_range_proxy.uninitialized_copy_n_and_update(a, new_elem_pos, n);
this->m_holder.set_stored_size(before_plus_new); 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 //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 //there is a gap between the new data and the old data
if(s_before >= new_size){ if(s_before >= new_size){
@@ -3174,7 +3180,7 @@ private:
old_values_destroyer.shrink_forward(old_size - (s_before - n)); 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 //Now copy the second part of old_begin overwriting itself
T *const next = ::boost::container::move(old_start + s_before, pos, old_start); T *const next = ::boost::container::move(old_start + s_before, pos, old_start);
//Now copy the new_beg elements //Now copy the new_beg elements
@@ -3216,11 +3222,11 @@ private:
T * const new_pos = ::boost::container::uninitialized_move_alloc T * const new_pos = ::boost::container::uninitialized_move_alloc
(a, old_start, pos, new_start); (a, old_start, pos, new_start);
this->m_holder.set_stored_size(elemsbefore); 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); insert_range_proxy.uninitialized_copy_n_and_update(a, new_pos, mid_n);
//The buffer is all constructed until old_end, //The buffer is all constructed until old_end,
//release destroyer //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(); old_values_destroyer.release();
if(do_after){ if(do_after){
@@ -3229,7 +3235,7 @@ private:
} }
else{ else{
//Copy all new elements //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); insert_range_proxy.copy_n_and_update(a, old_start, rest_new);
T* const move_start = old_start + rest_new; T* const move_start = old_start + rest_new;
@@ -3240,7 +3246,7 @@ private:
//trivial_dctr_after_move is true //trivial_dctr_after_move is true
//Destroy remaining moved elements from old_end except if they //Destroy remaining moved elements from old_end except if they
//have trivial destructor after being moved //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_IF_CONSTEXPR(!value_traits::trivial_dctr_after_move){
boost::container::destroy_alloc_n(a, move_end, n_destroy); boost::container::destroy_alloc_n(a, move_end, n_destroy);
} }
@@ -3267,8 +3273,8 @@ private:
//| old_begin + new | old_end |raw | //| old_begin + new | old_end |raw |
//|_______________________________________|_________|____| //|_______________________________________|_________|____|
// //
const size_type n_after = n - s_before; const size_type n_after = size_type(n - s_before);
const size_type elemsafter = old_size - elemsbefore; const size_type elemsafter = size_type(old_size - elemsbefore);
//We can have two situations: //We can have two situations:
if (elemsafter >= n_after){ if (elemsafter >= n_after){
@@ -3308,7 +3314,7 @@ private:
//|__________________________|_______________|________|_________| //|__________________________|_______________|________|_________|
//First initialize data in raw memory //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. //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); ::boost::container::uninitialized_move_alloc(a, pos, old_finish, old_finish + mid_last_dist);

View File

@@ -21,7 +21,7 @@
namespace boost { namespace container { namespace test { namespace boost { namespace container { namespace test {
static const int NumIt = 200; static const std::size_t NumIt = 200;
enum deallocation_type { DirectDeallocation, InverseDeallocation, MixedDeallocation, EndDeallocationType }; enum deallocation_type { DirectDeallocation, InverseDeallocation, MixedDeallocation, EndDeallocationType };
@@ -39,7 +39,7 @@ bool test_allocation()
std::vector<void*> buffers; std::vector<void*> buffers;
//std::size_t free_memory = a.get_free_memory(); //std::size_t free_memory = a.get_free_memory();
for(int i = 0; i != NumIt; ++i){ for(std::size_t i = 0; i != NumIt; ++i){
void *ptr = dlmalloc_malloc(i); void *ptr = dlmalloc_malloc(i);
if(!ptr) if(!ptr)
break; break;
@@ -49,7 +49,7 @@ bool test_allocation()
switch(t){ switch(t){
case DirectDeallocation: case DirectDeallocation:
{ {
for(int j = 0, max = (int)buffers.size() for(std::size_t j = 0, max = buffers.size()
;j < max ;j < max
;++j){ ;++j){
dlmalloc_free(buffers[j]); dlmalloc_free(buffers[j]);
@@ -58,7 +58,7 @@ bool test_allocation()
break; break;
case InverseDeallocation: case InverseDeallocation:
{ {
for(int j = (int)buffers.size() for(std::size_t j = buffers.size()
;j-- ;j--
;){ ;){
dlmalloc_free(buffers[j]); dlmalloc_free(buffers[j]);
@@ -67,12 +67,12 @@ bool test_allocation()
break; break;
case MixedDeallocation: case MixedDeallocation:
{ {
for(int j = 0, max = (int)buffers.size() for(std::size_t j = 0, max = buffers.size()
;j < max ;j < max
;++j){ ;++j){
int pos = (j%4)*((int)buffers.size())/4; std::size_t pos = (j%4)*(buffers.size())/4;
dlmalloc_free(buffers[pos]); dlmalloc_free(buffers[pos]);
buffers.erase(buffers.begin()+pos); buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
} }
} }
break; break;
@@ -99,15 +99,15 @@ bool test_allocation_shrink()
std::vector<void*> buffers; std::vector<void*> buffers;
//Allocate buffers with extra memory //Allocate buffers with extra memory
for(int i = 0; i != NumIt; ++i){ for(std::size_t i = 0; i != NumIt; ++i){
void *ptr = dlmalloc_malloc(i*2); void *ptr = dlmalloc_malloc(i*2u);
if(!ptr) if(!ptr)
break; break;
buffers.push_back(ptr); buffers.push_back(ptr);
} }
//Now shrink to half //Now shrink to half
for(int i = 0, max = (int)buffers.size() for(std::size_t i = 0, max = buffers.size()
;i < max ;i < max
; ++i){ ; ++i){
std::size_t try_received_size = 0; std::size_t try_received_size = 0;
@@ -137,12 +137,12 @@ bool test_allocation_shrink()
} }
//Deallocate it in non sequential order //Deallocate it in non sequential order
for(int j = 0, max = (int)buffers.size() for(std::size_t j = 0, max = buffers.size()
;j < max ;j < max
;++j){ ;++j){
int pos = (j%4)*((int)buffers.size())/4; std::size_t pos = (j%4u)*(buffers.size())/4u;
dlmalloc_free(buffers[pos]); dlmalloc_free(buffers[pos]);
buffers.erase(buffers.begin()+pos); buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
} }
dlmalloc_malloc_check(); dlmalloc_malloc_check();
return 0 != dlmalloc_all_deallocated();//a.all_memory_deallocated() && a.check_sanity(); return 0 != dlmalloc_all_deallocated();//a.all_memory_deallocated() && a.check_sanity();
@@ -158,7 +158,7 @@ bool test_allocation_expand()
std::vector<void*> buffers; std::vector<void*> buffers;
//Allocate buffers with extra memory //Allocate buffers with extra memory
for(int i = 0; i != NumIt; ++i){ for(std::size_t i = 0; i != NumIt; ++i){
void *ptr = dlmalloc_malloc(i); void *ptr = dlmalloc_malloc(i);
if(!ptr) if(!ptr)
break; break;
@@ -166,7 +166,7 @@ bool test_allocation_expand()
} }
//Now try to expand to the double of the size //Now try to expand to the double of the size
for(int i = 0, max = (int)buffers.size() for(std::size_t i = 0, max = buffers.size()
;i < max ;i < max
;++i){ ;++i){
std::size_t received_size = 0; std::size_t received_size = 0;
@@ -187,12 +187,12 @@ bool test_allocation_expand()
} }
//Deallocate it in non sequential order //Deallocate it in non sequential order
for(int j = 0, max = (int)buffers.size() for(std::size_t j = 0, max = buffers.size()
;j < max ;j < max
;++j){ ;++j){
int pos = (j%4)*((int)buffers.size())/4; std::size_t pos = (j%4u)*(buffers.size())/4u;
dlmalloc_free(buffers[pos]); dlmalloc_free(buffers[pos]);
buffers.erase(buffers.begin()+pos); buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
} }
dlmalloc_malloc_check(); dlmalloc_malloc_check();
return 0 != dlmalloc_all_deallocated();//a.all_memory_deallocated() && a.check_sanity(); return 0 != dlmalloc_all_deallocated();//a.all_memory_deallocated() && a.check_sanity();
@@ -208,13 +208,13 @@ bool test_allocation_shrink_and_expand()
std::vector<bool> size_reduced; std::vector<bool> size_reduced;
//Allocate buffers wand store received sizes //Allocate buffers wand store received sizes
for(int i = 0; i != NumIt; ++i){ for(std::size_t i = 0; i != NumIt; ++i){
std::size_t received_size = 0; std::size_t received_size = 0;
void *ptr = dlmalloc_allocation_command void *ptr = dlmalloc_allocation_command
(BOOST_CONTAINER_ALLOCATE_NEW, 1, i, i*2, &received_size, 0).first; (BOOST_CONTAINER_ALLOCATE_NEW, 1u, i, i*2u, &received_size, 0).first;
if(!ptr){ if(!ptr){
ptr = dlmalloc_allocation_command ptr = dlmalloc_allocation_command
( BOOST_CONTAINER_ALLOCATE_NEW, 1, 1, i*2, &received_size, 0).first; ( BOOST_CONTAINER_ALLOCATE_NEW, 1u, 1u, i*2, &received_size, 0).first;
if(!ptr) if(!ptr)
break; break;
} }
@@ -223,7 +223,7 @@ bool test_allocation_shrink_and_expand()
} }
//Now shrink to half //Now shrink to half
for(int i = 0, max = (int)buffers.size() for(std::size_t i = 0, max = buffers.size()
; i < max ; i < max
; ++i){ ; ++i){
std::size_t received_size = 0; std::size_t received_size = 0;
@@ -243,7 +243,7 @@ bool test_allocation_shrink_and_expand()
} }
//Now try to expand to the original size //Now try to expand to the original size
for(int i = 0, max = (int)buffers.size() for(std::size_t i = 0, max = buffers.size()
;i < max ;i < max
;++i){ ;++i){
if(!size_reduced[i]) continue; if(!size_reduced[i]) continue;
@@ -262,12 +262,12 @@ bool test_allocation_shrink_and_expand()
} }
//Deallocate it in non sequential order //Deallocate it in non sequential order
for(int j = 0, max = (int)buffers.size() for(std::size_t j = 0, max = buffers.size()
;j < max ;j < max
;++j){ ;++j){
int pos = (j%4)*((int)buffers.size())/4; std::size_t pos = (j%4u)*(buffers.size())/4u;
dlmalloc_free(buffers[pos]); dlmalloc_free(buffers[pos]);
buffers.erase(buffers.begin()+pos); buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
} }
return 0 != dlmalloc_all_deallocated();//a.all_memory_deallocated() && a.check_sanity(); return 0 != dlmalloc_all_deallocated();//a.all_memory_deallocated() && a.check_sanity();
@@ -284,7 +284,7 @@ bool test_allocation_deallocation_expand()
std::vector<void*> buffers; std::vector<void*> buffers;
//Allocate buffers with extra memory //Allocate buffers with extra memory
for(int i = 0; i != NumIt; ++i){ for(std::size_t i = 0; i != NumIt; ++i){
void *ptr = dlmalloc_malloc(i); void *ptr = dlmalloc_malloc(i);
if(!ptr) if(!ptr)
break; break;
@@ -293,7 +293,7 @@ bool test_allocation_deallocation_expand()
//Now deallocate the half of the blocks //Now deallocate the half of the blocks
//so expand maybe can merge new free blocks //so expand maybe can merge new free blocks
for(int i = 0, max = (int)buffers.size() for(std::size_t i = 0, max = buffers.size()
;i < max ;i < max
;++i){ ;++i){
if(i%2){ if(i%2){
@@ -303,7 +303,7 @@ bool test_allocation_deallocation_expand()
} }
//Now try to expand to the double of the size //Now try to expand to the double of the size
for(int i = 0, max = (int)buffers.size() for(std::size_t i = 0, max = buffers.size()
;i < max ;i < max
;++i){ ;++i){
// //
@@ -332,12 +332,12 @@ bool test_allocation_deallocation_expand()
,buffers.end()); ,buffers.end());
//Deallocate it in non sequential order //Deallocate it in non sequential order
for(int j = 0, max = (int)buffers.size() for(std::size_t j = 0, max = buffers.size()
;j < max ;j < max
;++j){ ;++j){
int pos = (j%4)*((int)buffers.size())/4; std::size_t pos = (j%4u)*(buffers.size())/4u;
dlmalloc_free(buffers[pos]); dlmalloc_free(buffers[pos]);
buffers.erase(buffers.begin()+pos); buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
} }
dlmalloc_malloc_check(); dlmalloc_malloc_check();
return 0 != dlmalloc_all_deallocated();//a.all_memory_deallocated() && a.check_sanity(); return 0 != dlmalloc_all_deallocated();//a.all_memory_deallocated() && a.check_sanity();
@@ -354,11 +354,11 @@ bool test_allocation_with_reuse()
{ {
dlmalloc_malloc_check(); dlmalloc_malloc_check();
//We will repeat this test for different sized elements //We will repeat this test for different sized elements
for(int sizeof_object = 1; sizeof_object < 20; ++sizeof_object){ for(std::size_t sizeof_object = 1; sizeof_object < 20; ++sizeof_object){
std::vector<void*> buffers; std::vector<void*> buffers;
//Allocate buffers with extra memory //Allocate buffers with extra memory
for(int i = 0; i != NumIt; ++i){ for(std::size_t i = 0; i != NumIt; ++i){
void *ptr = dlmalloc_malloc(i*sizeof_object); void *ptr = dlmalloc_malloc(i*sizeof_object);
if(!ptr) if(!ptr)
break; break;
@@ -367,7 +367,7 @@ bool test_allocation_with_reuse()
//Now deallocate all except the latest //Now deallocate all except the latest
//Now try to expand to the double of the size //Now try to expand to the double of the size
for(int i = 0, max = (int)buffers.size() - 1 for(std::size_t i = 0, max = buffers.size() - 1
;i < max ;i < max
;++i){ ;++i){
dlmalloc_free(buffers[i]); dlmalloc_free(buffers[i]);
@@ -379,9 +379,9 @@ bool test_allocation_with_reuse()
//Now allocate with reuse //Now allocate with reuse
std::size_t received_size = 0; std::size_t received_size = 0;
for(int i = 0; i != NumIt; ++i){ for(std::size_t i = 0; i != NumIt; ++i){
std::size_t min_size = (received_size/sizeof_object + 1)*sizeof_object; std::size_t min_size = (received_size/sizeof_object + 1u)*sizeof_object;
std::size_t prf_size = (received_size/sizeof_object + (i+1)*2)*sizeof_object; std::size_t prf_size = (received_size/sizeof_object + (i+1u)*2u)*sizeof_object;
dlmalloc_command_ret_t ret = dlmalloc_allocation_command dlmalloc_command_ret_t ret = dlmalloc_allocation_command
( BOOST_CONTAINER_EXPAND_BWD, sizeof_object, min_size ( BOOST_CONTAINER_EXPAND_BWD, sizeof_object, min_size
, prf_size, &received_size, (char*)ptr); , prf_size, &received_size, (char*)ptr);
@@ -413,8 +413,8 @@ bool test_aligned_allocation()
dlmalloc_malloc_check(); dlmalloc_malloc_check();
//Allocate aligned buffers in a loop //Allocate aligned buffers in a loop
//and then deallocate it //and then deallocate it
for(unsigned int i = 1; i != (1 << (sizeof(int)/2)); i <<= 1){ for(std::size_t i = 1u; i != (1u << (sizeof(int)/2u)); i <<= 1u){
for(unsigned int j = 1; j != 512; j <<= 1){ for(std::size_t j = 1u; j != 512u; j <<= 1){
void *ptr = dlmalloc_memalign(i-1, j); void *ptr = dlmalloc_memalign(i-1, j);
if(!ptr){ if(!ptr){
return false; return false;
@@ -442,11 +442,11 @@ bool test_continuous_aligned_allocation()
//Allocate aligned buffers in a loop //Allocate aligned buffers in a loop
//and then deallocate it //and then deallocate it
bool continue_loop = true; bool continue_loop = true;
unsigned int MaxAlign = 4096; std::size_t MaxAlign = 4096;
unsigned int MaxSize = 4096; std::size_t MaxSize = 4096;
for(unsigned i = 1; i < MaxSize; i <<= 1){ for(std::size_t i = 1; i < MaxSize; i <<= 1){
for(unsigned int j = 1; j < MaxAlign; j <<= 1){ for(std::size_t j = 1; j < MaxAlign; j <<= 1){
for(int k = 0; k != NumIt; ++k){ for(std::size_t k = 0; k != NumIt; ++k){
void *ptr = dlmalloc_memalign(i-1, j); void *ptr = dlmalloc_memalign(i-1, j);
buffers.push_back(ptr); buffers.push_back(ptr);
if(!ptr){ if(!ptr){
@@ -458,7 +458,7 @@ bool test_continuous_aligned_allocation()
return false; return false;
} }
//Deallocate all //Deallocate all
for(int k = (int)buffers.size(); k--;){ for(std::size_t k = buffers.size(); k--;){
dlmalloc_free(buffers[k]); dlmalloc_free(buffers[k]);
} }
buffers.clear(); buffers.clear();
@@ -485,7 +485,7 @@ bool test_many_equal_allocation()
std::vector<void*> buffers2; std::vector<void*> buffers2;
//Allocate buffers with extra memory //Allocate buffers with extra memory
for(int i = 0; i != NumIt; ++i){ for(std::size_t i = 0; i != NumIt; ++i){
void *ptr = dlmalloc_malloc(i); void *ptr = dlmalloc_malloc(i);
if(!ptr) if(!ptr)
break; break;
@@ -496,7 +496,7 @@ bool test_many_equal_allocation()
//Now deallocate the half of the blocks //Now deallocate the half of the blocks
//so expand maybe can merge new free blocks //so expand maybe can merge new free blocks
for(int i = 0, max = (int)buffers2.size() for(std::size_t i = 0, max = buffers2.size()
;i < max ;i < max
;++i){ ;++i){
if(i%2){ if(i%2){
@@ -509,7 +509,7 @@ bool test_many_equal_allocation()
//return false; //return false;
std::vector<void*> buffers; std::vector<void*> buffers;
for(int i = 0; i != NumIt/10; ++i){ for(std::size_t i = 0; i != NumIt/10; ++i){
dlmalloc_memchain chain; dlmalloc_memchain chain;
BOOST_CONTAINER_MEMCHAIN_INIT(&chain); BOOST_CONTAINER_MEMCHAIN_INIT(&chain);
dlmalloc_multialloc_nodes((i+1)*2, i+1, BOOST_CONTAINER_DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &chain); dlmalloc_multialloc_nodes((i+1)*2, i+1, BOOST_CONTAINER_DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &chain);
@@ -532,7 +532,7 @@ bool test_many_equal_allocation()
switch(t){ switch(t){
case DirectDeallocation: case DirectDeallocation:
{ {
for(int j = 0, max = (int)buffers.size() for(std::size_t j = 0, max = buffers.size()
;j < max ;j < max
;++j){ ;++j){
dlmalloc_free(buffers[j]); dlmalloc_free(buffers[j]);
@@ -541,7 +541,7 @@ bool test_many_equal_allocation()
break; break;
case InverseDeallocation: case InverseDeallocation:
{ {
for(int j = (int)buffers.size() for(std::size_t j = buffers.size()
;j-- ;j--
;){ ;){
dlmalloc_free(buffers[j]); dlmalloc_free(buffers[j]);
@@ -550,12 +550,12 @@ bool test_many_equal_allocation()
break; break;
case MixedDeallocation: case MixedDeallocation:
{ {
for(int j = 0, max = (int)buffers.size() for(std::size_t j = 0, max = buffers.size()
;j < max ;j < max
;++j){ ;++j){
int pos = (j%4)*((int)buffers.size())/4; std::size_t pos = (j%4u)*(buffers.size())/4u;
dlmalloc_free(buffers[pos]); dlmalloc_free(buffers[pos]);
buffers.erase(buffers.begin()+pos); buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
} }
} }
break; break;
@@ -566,12 +566,12 @@ bool test_many_equal_allocation()
//Deallocate the rest of the blocks //Deallocate the rest of the blocks
//Deallocate it in non sequential order //Deallocate it in non sequential order
for(int j = 0, max = (int)buffers2.size() for(std::size_t j = 0, max = buffers2.size()
;j < max ;j < max
;++j){ ;++j){
int pos = (j%4)*((int)buffers2.size())/4; std::size_t pos = (j%4u)*(buffers2.size())/4u;
dlmalloc_free(buffers2[pos]); dlmalloc_free(buffers2[pos]);
buffers2.erase(buffers2.begin()+pos); buffers2.erase(buffers2.begin()+(std::ptrdiff_t)pos);
} }
//bool ok = free_memory == a.get_free_memory() && //bool ok = free_memory == a.get_free_memory() &&
@@ -602,7 +602,7 @@ bool test_many_different_allocation()
std::vector<void*> buffers2; std::vector<void*> buffers2;
//Allocate buffers with extra memory //Allocate buffers with extra memory
for(int i = 0; i != NumIt; ++i){ for(std::size_t i = 0; i != NumIt; ++i){
void *ptr = dlmalloc_malloc(i); void *ptr = dlmalloc_malloc(i);
if(!ptr) if(!ptr)
break; break;
@@ -611,7 +611,7 @@ bool test_many_different_allocation()
//Now deallocate the half of the blocks //Now deallocate the half of the blocks
//so expand maybe can merge new free blocks //so expand maybe can merge new free blocks
for(int i = 0, max = (int)buffers2.size() for(std::size_t i = 0, max = buffers2.size()
;i < max ;i < max
;++i){ ;++i){
if(i%2){ if(i%2){
@@ -621,7 +621,7 @@ bool test_many_different_allocation()
} }
std::vector<void*> buffers; std::vector<void*> buffers;
for(int i = 0; i != NumIt; ++i){ for(std::size_t i = 0; i != NumIt; ++i){
dlmalloc_memchain chain; dlmalloc_memchain chain;
BOOST_CONTAINER_MEMCHAIN_INIT(&chain); BOOST_CONTAINER_MEMCHAIN_INIT(&chain);
dlmalloc_multialloc_arrays(ArraySize, requested_sizes, 1, BOOST_CONTAINER_DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &chain); dlmalloc_multialloc_arrays(ArraySize, requested_sizes, 1, BOOST_CONTAINER_DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &chain);
@@ -640,7 +640,7 @@ bool test_many_different_allocation()
switch(t){ switch(t){
case DirectDeallocation: case DirectDeallocation:
{ {
for(int j = 0, max = (int)buffers.size() for(std::size_t j = 0, max = buffers.size()
;j < max ;j < max
;++j){ ;++j){
dlmalloc_free(buffers[j]); dlmalloc_free(buffers[j]);
@@ -649,7 +649,7 @@ bool test_many_different_allocation()
break; break;
case InverseDeallocation: case InverseDeallocation:
{ {
for(int j = (int)buffers.size() for(std::size_t j = buffers.size()
;j-- ;j--
;){ ;){
dlmalloc_free(buffers[j]); dlmalloc_free(buffers[j]);
@@ -658,12 +658,12 @@ bool test_many_different_allocation()
break; break;
case MixedDeallocation: case MixedDeallocation:
{ {
for(int j = 0, max = (int)buffers.size() for(std::size_t j = 0, max = buffers.size()
;j < max ;j < max
;++j){ ;++j){
int pos = (j%4)*((int)buffers.size())/4; std::size_t pos = (j%4)*(buffers.size())/4;
dlmalloc_free(buffers[pos]); dlmalloc_free(buffers[pos]);
buffers.erase(buffers.begin()+pos); buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
} }
} }
break; break;
@@ -674,12 +674,12 @@ bool test_many_different_allocation()
//Deallocate the rest of the blocks //Deallocate the rest of the blocks
//Deallocate it in non sequential order //Deallocate it in non sequential order
for(int j = 0, max = (int)buffers2.size() for(std::size_t j = 0, max = buffers2.size()
;j < max ;j < max
;++j){ ;++j){
int pos = (j%4)*((int)buffers2.size())/4; std::size_t pos = (j%4u)*(buffers2.size())/4u;
dlmalloc_free(buffers2[pos]); dlmalloc_free(buffers2[pos]);
buffers2.erase(buffers2.begin()+pos); buffers2.erase(buffers2.begin()+(std::ptrdiff_t)pos);
} }
//bool ok = free_memory == a.get_free_memory() && //bool ok = free_memory == a.get_free_memory() &&
@@ -699,7 +699,7 @@ bool test_many_deallocation()
requested_sizes[i] = 4*i; requested_sizes[i] = 4*i;
} }
for(int i = 0; i != NumIt; ++i){ for(std::size_t i = 0; i != NumIt; ++i){
dlmalloc_memchain chain; dlmalloc_memchain chain;
BOOST_CONTAINER_MEMCHAIN_INIT(&chain); BOOST_CONTAINER_MEMCHAIN_INIT(&chain);
dlmalloc_multialloc_arrays(ArraySize, requested_sizes, 1, BOOST_CONTAINER_DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &chain); dlmalloc_multialloc_arrays(ArraySize, requested_sizes, 1, BOOST_CONTAINER_DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &chain);
@@ -708,7 +708,7 @@ bool test_many_deallocation()
return false; return false;
buffers.push_back(chain); buffers.push_back(chain);
} }
for(int i = 0; i != NumIt; ++i){ for(std::size_t i = 0; i != NumIt; ++i){
dlmalloc_multidealloc(&buffers[i]); dlmalloc_multidealloc(&buffers[i]);
} }
buffers.clear(); buffers.clear();
@@ -717,7 +717,7 @@ bool test_many_deallocation()
if(!dlmalloc_all_deallocated()) if(!dlmalloc_all_deallocated())
return false; return false;
for(int i = 0; i != NumIt; ++i){ for(std::size_t i = 0; i != NumIt; ++i){
dlmalloc_memchain chain; dlmalloc_memchain chain;
BOOST_CONTAINER_MEMCHAIN_INIT(&chain); BOOST_CONTAINER_MEMCHAIN_INIT(&chain);
dlmalloc_multialloc_nodes(ArraySize, i*4+1, BOOST_CONTAINER_DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &chain); dlmalloc_multialloc_nodes(ArraySize, i*4+1, BOOST_CONTAINER_DL_MULTIALLOC_DEFAULT_CONTIGUOUS, &chain);
@@ -726,7 +726,7 @@ bool test_many_deallocation()
return false; return false;
buffers.push_back(chain); buffers.push_back(chain);
} }
for(int i = 0; i != NumIt; ++i){ for(std::size_t i = 0; i != NumIt; ++i){
dlmalloc_multidealloc(&buffers[i]); dlmalloc_multidealloc(&buffers[i]);
} }
buffers.clear(); buffers.clear();

View File

@@ -69,11 +69,11 @@ bool CheckEqualContainers(const ContA &cont_a, const ContB &cont_b)
typename ContA::const_iterator itcont_a(cont_a.begin()), itcont_a_end(cont_a.end()); typename ContA::const_iterator itcont_a(cont_a.begin()), itcont_a_end(cont_a.end());
typename ContB::const_iterator itcont_b(cont_b.begin()), itcont_b_end(cont_b.end());; typename ContB::const_iterator itcont_b(cont_b.begin()), itcont_b_end(cont_b.end());;
typename ContB::size_type dist = (typename ContB::size_type)boost::container::iterator_distance(itcont_a, itcont_a_end); typename ContB::size_type dist = boost::container::iterator_udistance(itcont_a, itcont_a_end);
if(dist != cont_a.size()){ if(dist != cont_a.size()){
return false; return false;
} }
typename ContA::size_type dist2 = (typename ContA::size_type)boost::container::iterator_distance(itcont_b, itcont_b_end); typename ContA::size_type dist2 = boost::container::iterator_udistance(itcont_b, itcont_b_end);
if(dist2 != cont_b.size()){ if(dist2 != cont_b.size()){
return false; return false;
} }

View File

@@ -29,6 +29,8 @@ bool test_nth_index_of(Container &c)
typename Container::iterator it; typename Container::iterator it;
typename Container::const_iterator cit; typename Container::const_iterator cit;
typename Container::size_type sz, csz; typename Container::size_type sz, csz;
typedef typename Container::difference_type difference_type;
//index 0 //index 0
it = c.nth(0); it = c.nth(0);
sz = c.index_of(it); sz = c.index_of(it);
@@ -51,9 +53,9 @@ bool test_nth_index_of(Container &c)
cit = (as_const)(c).nth(sz_div_2); cit = (as_const)(c).nth(sz_div_2);
csz = (as_const)(c).index_of(cit); csz = (as_const)(c).index_of(cit);
if(it != (c.begin()+sz_div_2)) if(it != (c.begin()+difference_type(sz_div_2)))
return false; return false;
if(cit != (c.cbegin()+sz_div_2)) if(cit != (c.cbegin()+difference_type(sz_div_2)))
return false; return false;
if(sz != sz_div_2) if(sz != sz_div_2)
return false; return false;

View File

@@ -46,13 +46,13 @@ bool deque_copyable_only(V1 &cntdeque, V2 &stddeque, dtl::true_type)
{ {
typedef typename V1::value_type IntType; typedef typename V1::value_type IntType;
std::size_t size = cntdeque.size(); std::size_t size = cntdeque.size();
stddeque.insert(stddeque.end(), 50, 1); stddeque.insert(stddeque.end(), 50u, 1);
cntdeque.insert(cntdeque.end(), 50, IntType(1)); cntdeque.insert(cntdeque.end(), 50u, IntType(1));
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
{ {
IntType move_me(1); IntType move_me(1);
stddeque.insert(stddeque.begin()+size/2, 50, 1); stddeque.insert(stddeque.begin()+std::ptrdiff_t(size)/2, 50u, 1);
cntdeque.insert(cntdeque.begin()+size/2, 50, boost::move(move_me)); cntdeque.insert(cntdeque.begin()+std::ptrdiff_t(size/2), 50u, boost::move(move_me));
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
} }
{ {
@@ -65,28 +65,28 @@ bool deque_copyable_only(V1 &cntdeque, V2 &stddeque, dtl::true_type)
IntType move_me(1); IntType move_me(1);
stddeque.clear(); stddeque.clear();
cntdeque.clear(); cntdeque.clear();
stddeque.insert(stddeque.begin(), 50, 1); stddeque.insert(stddeque.begin(), 50u, 1);
cntdeque.insert(cntdeque.begin(), 50, boost::move(move_me)); cntdeque.insert(cntdeque.begin(), 50u, boost::move(move_me));
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
stddeque.insert(stddeque.begin()+20, 50, 1); stddeque.insert(stddeque.begin()+20, 50u, 1);
cntdeque.insert(cntdeque.begin()+20, 50, boost::move(move_me)); cntdeque.insert(cntdeque.begin()+20, 50u, boost::move(move_me));
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
stddeque.insert(stddeque.begin()+20, 20, 1); stddeque.insert(stddeque.begin()+20, 20u, 1);
cntdeque.insert(cntdeque.begin()+20, 20, boost::move(move_me)); cntdeque.insert(cntdeque.begin()+20, 20u, boost::move(move_me));
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
} }
{ {
IntType move_me(1); IntType move_me(1);
stddeque.clear(); stddeque.clear();
cntdeque.clear(); cntdeque.clear();
stddeque.insert(stddeque.end(), 50, 1); stddeque.insert(stddeque.end(), 50u, 1);
cntdeque.insert(cntdeque.end(), 50, boost::move(move_me)); cntdeque.insert(cntdeque.end(), 50u, boost::move(move_me));
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
stddeque.insert(stddeque.end()-20, 50, 1); stddeque.insert(stddeque.end()-20, 50u, 1);
cntdeque.insert(cntdeque.end()-20, 50, boost::move(move_me)); cntdeque.insert(cntdeque.end()-20, 50u, boost::move(move_me));
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
stddeque.insert(stddeque.end()-20, 20, 1); stddeque.insert(stddeque.end()-20, 20u, 1);
cntdeque.insert(cntdeque.end()-20, 20, boost::move(move_me)); cntdeque.insert(cntdeque.end()-20, 20u, boost::move(move_me));
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
} }
@@ -204,10 +204,10 @@ bool do_test()
aux_vect2[i] = i; aux_vect2[i] = i;
} }
cntdeque.insert(cntdeque.begin()+cntdeque.size() cntdeque.insert(cntdeque.begin()+std::ptrdiff_t(cntdeque.size())
,boost::make_move_iterator(&aux_vect[0]) ,boost::make_move_iterator(&aux_vect[0])
,boost::make_move_iterator(aux_vect + 50)); ,boost::make_move_iterator(aux_vect + 50));
stddeque.insert(stddeque.begin()+stddeque.size(), aux_vect2, aux_vect2 + 50); stddeque.insert(stddeque.begin()+std::ptrdiff_t(stddeque.size()), aux_vect2, aux_vect2 + 50);
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
for(int i = 0, j = static_cast<int>(cntdeque.size()); i < j; ++i){ for(int i = 0, j = static_cast<int>(cntdeque.size()); i < j; ++i){

View File

@@ -1722,7 +1722,7 @@ template <class Devector> void test_reserve_front()
Devector a; Devector a;
a.reserve_front(100); a.reserve_front(100);
for (unsigned i = 0; i < 100u; ++i) for (int i = 0; i < 100; ++i)
{ {
a.push_front(value_type(i)); a.push_front(value_type(i));
} }
@@ -1742,7 +1742,7 @@ template <class Devector> void test_reserve_back()
Devector a; Devector a;
typedef typename Devector::value_type value_type; typedef typename Devector::value_type value_type;
a.reserve_back(100); a.reserve_back(100);
for (unsigned i = 0; i < 100; ++i) for (int i = 0; i < 100; ++i)
{ {
a.push_back(value_type(i)); a.push_back(value_type(i));
} }
@@ -1760,19 +1760,20 @@ template <class Devector> void test_reserve_back()
template <typename Devector> template <typename Devector>
void test_shrink_to_fit_always() void test_shrink_to_fit_always()
{ {
typedef typename Devector::value_type value_type;
Devector a; Devector a;
a.reserve(100); a.reserve(100u);
a.push_back(1); a.push_back(value_type(1));
a.push_back(2); a.push_back(value_type(2));
a.push_back(3); a.push_back(value_type(3));
a.shrink_to_fit(); a.shrink_to_fit();
boost::container::vector<unsigned> expected; boost::container::vector<unsigned> expected;
expected.push_back(1); expected.push_back(1u);
expected.push_back(2); expected.push_back(2u);
expected.push_back(3); expected.push_back(3u);
test_equal_range(a, expected); test_equal_range(a, expected);
std::size_t exp_capacity = 3u; std::size_t exp_capacity = 3u;

View File

@@ -79,7 +79,7 @@ class expand_bwd_test_allocator
{ typedef expand_bwd_test_allocator<T2> other; }; { typedef expand_bwd_test_allocator<T2> other; };
//!Constructor from the segment manager. Never throws //!Constructor from the segment manager. Never throws
expand_bwd_test_allocator(T *buffer, size_type sz, difference_type offset) expand_bwd_test_allocator(T *buffer, size_type sz, size_type offset)
: mp_buffer(buffer), m_size(sz) : mp_buffer(buffer), m_size(sz)
, m_offset(offset), m_allocations(0){ } , m_offset(offset), m_allocations(0){ }
@@ -171,7 +171,7 @@ class expand_bwd_test_allocator
pointer mp_buffer; pointer mp_buffer;
size_type m_size; size_type m_size;
difference_type m_offset; size_type m_offset;
char m_allocations; char m_allocations;
}; };

View File

@@ -89,7 +89,7 @@ bool test_insert_with_expand_bwd()
std::vector<value_type> initial_data; std::vector<value_type> initial_data;
initial_data.resize(InitialSize[iteration]); initial_data.resize(InitialSize[iteration]);
for(unsigned int i = 0; i < InitialSize[iteration]; ++i){ for(unsigned int i = 0; i < InitialSize[iteration]; ++i){
initial_data[i] = static_cast<value_type>(i); initial_data[i] = static_cast<value_type>((int)i);
} }
if(!life_count<value_type>::check(InitialSize[iteration])) if(!life_count<value_type>::check(InitialSize[iteration]))
@@ -97,7 +97,7 @@ bool test_insert_with_expand_bwd()
Vect data_to_insert; Vect data_to_insert;
data_to_insert.resize(InsertSize[iteration]); data_to_insert.resize(InsertSize[iteration]);
for(unsigned int i = 0; i < InsertSize[iteration]; ++i){ for(unsigned int i = 0; i < InsertSize[iteration]; ++i){
data_to_insert[i] = static_cast<value_type>(-i); data_to_insert[i] = static_cast<value_type>((int)-i);
} }
if(!life_count<value_type>::check(InitialSize[iteration]+InsertSize[iteration])) if(!life_count<value_type>::check(InitialSize[iteration]+InsertSize[iteration]))
@@ -153,14 +153,14 @@ bool test_assign_with_expand_bwd()
std::vector<value_type> initial_data; std::vector<value_type> initial_data;
initial_data.resize(InitialSize[iteration]); initial_data.resize(InitialSize[iteration]);
for(unsigned int i = 0; i < InitialSize[iteration]; ++i){ for(unsigned int i = 0; i < InitialSize[iteration]; ++i){
initial_data[i] = static_cast<value_type>(i); initial_data[i] = static_cast<value_type>((int)i);
} }
//Create data to assign //Create data to assign
std::vector<value_type> data_to_insert; std::vector<value_type> data_to_insert;
data_to_insert.resize(InsertSize[iteration]); data_to_insert.resize(InsertSize[iteration]);
for(unsigned int i = 0; i < InsertSize[iteration]; ++i){ for(unsigned int i = 0; i < InsertSize[iteration]; ++i){
data_to_insert[i] = static_cast<value_type>(-i); data_to_insert[i] = static_cast<value_type>((int)-i);
} }
//Insert initial data to the vector to test //Insert initial data to the vector to test

View File

@@ -26,13 +26,13 @@ void
BOOST_TEST(CheckEqualContainers(std_deque, seq_container)); BOOST_TEST(CheckEqualContainers(std_deque, seq_container));
std_deque.insert( std_deque.insert(
std_deque.begin() + index std_deque.begin() + std::ptrdiff_t(index)
, input_deque.begin() , input_deque.begin()
, input_deque.end() , input_deque.end()
); );
seq_container.insert( seq_container.insert(
seq_container.begin() + index seq_container.begin() + std::ptrdiff_t(index)
, input_deque.begin() , input_deque.begin()
, input_deque.end() , input_deque.end()
); );

View File

@@ -22,6 +22,7 @@
#include <list> #include <list>
#include <functional> //std::greater #include <functional> //std::greater
#include <cstddef> //std::size_t
namespace boost{ namespace boost{
namespace container { namespace container {
@@ -38,14 +39,14 @@ template<class V1, class V2>
bool list_copyable_only(V1 &boostlist, V2 &stdlist, boost::container::dtl::true_type) bool list_copyable_only(V1 &boostlist, V2 &stdlist, boost::container::dtl::true_type)
{ {
typedef typename V1::value_type IntType; typedef typename V1::value_type IntType;
boostlist.insert(boostlist.end(), 50, IntType(1)); boostlist.insert(boostlist.end(), 50u, IntType(1));
stdlist.insert(stdlist.end(), 50, 1); stdlist.insert(stdlist.end(), 50u, 1);
if(!test::CheckEqualContainers(boostlist, stdlist)) return false; if(!test::CheckEqualContainers(boostlist, stdlist)) return false;
{ {
IntType move_me(1); IntType move_me(1);
boostlist.insert(boostlist.begin(), 50, boost::move(move_me)); boostlist.insert(boostlist.begin(), 50u, boost::move(move_me));
stdlist.insert(stdlist.begin(), 50, 1); stdlist.insert(stdlist.begin(), 50u, 1);
if(!test::CheckEqualContainers(boostlist, stdlist)) return false; if(!test::CheckEqualContainers(boostlist, stdlist)) return false;
} }
{ {
@@ -104,14 +105,14 @@ template<bool DoublyLinked>
struct list_push_data_function struct list_push_data_function
{ {
template<class MyBoostList, class MyStdList> template<class MyBoostList, class MyStdList>
static int execute(int max, MyBoostList &boostlist, MyStdList &stdlist) static int execute(std::size_t max, MyBoostList &boostlist, MyStdList &stdlist)
{ {
typedef typename MyBoostList::value_type IntType; typedef typename MyBoostList::value_type IntType;
for(int i = 0; i < max; ++i){ for(std::size_t i = 0; i < max; ++i){
IntType move_me(i); IntType move_me((int)i);
boostlist.push_back(boost::move(move_me)); boostlist.push_back(boost::move(move_me));
stdlist.push_back(i); stdlist.push_back((int)i);
boostlist.push_front(IntType(i)); boostlist.push_front(IntType(int(i)));
stdlist.push_front(int(i)); stdlist.push_front(int(i));
} }
if(!CheckEqualContainers(boostlist, stdlist)) if(!CheckEqualContainers(boostlist, stdlist))
@@ -124,14 +125,14 @@ template<>
struct list_push_data_function<false> struct list_push_data_function<false>
{ {
template<class MyBoostList, class MyStdList> template<class MyBoostList, class MyStdList>
static int execute(int max, MyBoostList &boostlist, MyStdList &stdlist) static int execute(std::size_t max, MyBoostList &boostlist, MyStdList &stdlist)
{ {
typedef typename MyBoostList::value_type IntType; typedef typename MyBoostList::value_type IntType;
for(int i = 0; i < max; ++i){ for(std::size_t i = 0; i < max; ++i){
IntType move_me(i); IntType move_me((int)i);
boostlist.push_front(boost::move(move_me)); boostlist.push_front(boost::move(move_me));
stdlist.push_front(i); stdlist.push_front((int)i);
boostlist.push_front(IntType(i)); boostlist.push_front(IntType(int(i)));
stdlist.push_front(int(i)); stdlist.push_front(int(i));
} }
if(!CheckEqualContainers(boostlist, stdlist)) if(!CheckEqualContainers(boostlist, stdlist))
@@ -171,35 +172,35 @@ int list_test (bool copied_allocators_equal = true)
{ {
typedef std::list<int> MyStdList; typedef std::list<int> MyStdList;
typedef typename MyBoostList::value_type IntType; typedef typename MyBoostList::value_type IntType;
const int max = 100; const std::size_t max = 100u;
typedef list_push_data_function<DoublyLinked> push_data_t; typedef list_push_data_function<DoublyLinked> push_data_t;
{ //List(n) { //List(n)
::boost::movelib::unique_ptr<MyBoostList> const pboostlist = ::boost::movelib::make_unique<MyBoostList>(100); ::boost::movelib::unique_ptr<MyBoostList> const pboostlist = ::boost::movelib::make_unique<MyBoostList>(100u);
::boost::movelib::unique_ptr<MyStdList> const pstdlist = ::boost::movelib::make_unique<MyStdList>(100); ::boost::movelib::unique_ptr<MyStdList> const pstdlist = ::boost::movelib::make_unique<MyStdList>(100u);
if(!test::CheckEqualContainers(*pboostlist, *pstdlist)) return 1; if(!test::CheckEqualContainers(*pboostlist, *pstdlist)) return 1;
} }
{ //List(n, alloc) { //List(n, alloc)
::boost::movelib::unique_ptr<MyBoostList> const pboostlist = ::boost::movelib::make_unique<MyBoostList>(100, typename MyBoostList::allocator_type()); ::boost::movelib::unique_ptr<MyBoostList> const pboostlist = ::boost::movelib::make_unique<MyBoostList>(100u, typename MyBoostList::allocator_type());
::boost::movelib::unique_ptr<MyStdList> const pstdlist = ::boost::movelib::make_unique<MyStdList>(100); ::boost::movelib::unique_ptr<MyStdList> const pstdlist = ::boost::movelib::make_unique<MyStdList>(100u);
if(!test::CheckEqualContainers(*pboostlist, *pstdlist)) return 1; if(!test::CheckEqualContainers(*pboostlist, *pstdlist)) return 1;
} }
{ //List(List &&) { //List(List &&)
::boost::movelib::unique_ptr<MyStdList> const stdlistp = ::boost::movelib::make_unique<MyStdList>(100); ::boost::movelib::unique_ptr<MyStdList> const stdlistp = ::boost::movelib::make_unique<MyStdList>(100u);
::boost::movelib::unique_ptr<MyBoostList> const boostlistp = ::boost::movelib::make_unique<MyBoostList>(100); ::boost::movelib::unique_ptr<MyBoostList> const boostlistp = ::boost::movelib::make_unique<MyBoostList>(100u);
::boost::movelib::unique_ptr<MyBoostList> const boostlistp2 = ::boost::movelib::make_unique<MyBoostList>(::boost::move(*boostlistp)); ::boost::movelib::unique_ptr<MyBoostList> const boostlistp2 = ::boost::movelib::make_unique<MyBoostList>(::boost::move(*boostlistp));
if(!test::CheckEqualContainers(*boostlistp2, *stdlistp)) return 1; if(!test::CheckEqualContainers(*boostlistp2, *stdlistp)) return 1;
} }
{ //List(List &&, alloc) { //List(List &&, alloc)
::boost::movelib::unique_ptr<MyStdList> const stdlistp = ::boost::movelib::make_unique<MyStdList>(100); ::boost::movelib::unique_ptr<MyStdList> const stdlistp = ::boost::movelib::make_unique<MyStdList>(100u);
::boost::movelib::unique_ptr<MyBoostList> const boostlistp = ::boost::movelib::make_unique<MyBoostList>(100); ::boost::movelib::unique_ptr<MyBoostList> const boostlistp = ::boost::movelib::make_unique<MyBoostList>(100u);
::boost::movelib::unique_ptr<MyBoostList> const boostlistp2 = ::boost::movelib::make_unique<MyBoostList> ::boost::movelib::unique_ptr<MyBoostList> const boostlistp2 = ::boost::movelib::make_unique<MyBoostList>
(::boost::move(*boostlistp), typename MyBoostList::allocator_type()); (::boost::move(*boostlistp), typename MyBoostList::allocator_type());
if(!test::CheckEqualContainers(*boostlistp2, *stdlistp)) return 1; if(!test::CheckEqualContainers(*boostlistp2, *stdlistp)) return 1;
} }
{ //List operator=(List &&) { //List operator=(List &&)
::boost::movelib::unique_ptr<MyStdList> const stdlistp = ::boost::movelib::make_unique<MyStdList>(100); ::boost::movelib::unique_ptr<MyStdList> const stdlistp = ::boost::movelib::make_unique<MyStdList>(100u);
::boost::movelib::unique_ptr<MyBoostList> const boostlistp = ::boost::movelib::make_unique<MyBoostList>(100); ::boost::movelib::unique_ptr<MyBoostList> const boostlistp = ::boost::movelib::make_unique<MyBoostList>(100u);
::boost::movelib::unique_ptr<MyBoostList> const boostlistp2 = ::boost::movelib::make_unique<MyBoostList>(); ::boost::movelib::unique_ptr<MyBoostList> const boostlistp2 = ::boost::movelib::make_unique<MyBoostList>();
*boostlistp2 = ::boost::move(*boostlistp); *boostlistp2 = ::boost::move(*boostlistp);
if(!test::CheckEqualContainers(*boostlistp2, *stdlistp)) return 1; if(!test::CheckEqualContainers(*boostlistp2, *stdlistp)) return 1;
@@ -324,10 +325,10 @@ int list_test (bool copied_allocators_equal = true)
return 1; return 1;
} }
for(int i = 0; i < max; ++i){ for(std::size_t i = 0; i < max; ++i){
IntType new_int(i); IntType new_int((int)i);
boostlist.insert(boostlist.end(), boost::move(new_int)); boostlist.insert(boostlist.end(), boost::move(new_int));
stdlist.insert(stdlist.end(), i); stdlist.insert(stdlist.end(), (int)i);
if(!test::CheckEqualContainers(boostlist, stdlist)) return 1; if(!test::CheckEqualContainers(boostlist, stdlist)) return 1;
} }
if(!test::CheckEqualContainers(boostlist, stdlist)) return 1; if(!test::CheckEqualContainers(boostlist, stdlist)) return 1;
@@ -362,7 +363,7 @@ int list_test (bool copied_allocators_equal = true)
MyBoostList otherboostlist(boostlist.get_allocator()); MyBoostList otherboostlist(boostlist.get_allocator());
MyStdList otherstdlist; MyStdList otherstdlist;
int listsize = (int)boostlist.size(); std::size_t listsize = boostlist.size();
if(push_data_t::execute(listsize, boostlist, stdlist)){ if(push_data_t::execute(listsize, boostlist, stdlist)){
return 1; return 1;
@@ -375,7 +376,7 @@ int list_test (bool copied_allocators_equal = true)
return 1; return 1;
} }
listsize = (int)boostlist.size(); listsize = boostlist.size();
if(push_data_t::execute(listsize, boostlist, stdlist)){ if(push_data_t::execute(listsize, boostlist, stdlist)){
return 1; return 1;

View File

@@ -108,17 +108,19 @@ int map_test_copyable(boost::container::dtl::true_type)
boostmap.clear(); boostmap.clear();
boostmultimap.clear(); boostmultimap.clear();
stdmultimap.clear(); stdmultimap.clear();
//Now try from convertible pair //Now try from convertible pair
for(i = 0; i < MaxElem; ++i){ for(i = 0; i < MaxElem; ++i){
{ {
boostmap.insert(std::pair<unsigned, unsigned>(i, i)); boostmap.insert(std::pair<signed short, signed short>((signed short)i, (signed short)i));
stdmap.insert(StdPairType(i, i)); stdmap.insert(StdPairType(i, i));
} }
{ {
boostmultimap.insert(std::pair<unsigned, unsigned>(i, i)); boostmultimap.insert(std::pair<signed short, signed short>((signed short)i, (signed short)i));
stdmultimap.insert(StdPairType(i, i)); stdmultimap.insert(StdPairType(i, i));
} }
} }
if(!CheckEqualContainers(boostmap, stdmap)) return 1; if(!CheckEqualContainers(boostmap, stdmap)) return 1;
if(!CheckEqualContainers(boostmultimap, stdmultimap)) return 1; if(!CheckEqualContainers(boostmultimap, stdmultimap)) return 1;
@@ -692,8 +694,8 @@ int map_test_insert2(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &bo
std::pair<typename MyStdMultiMap::iterator, typename MyStdMultiMap::iterator> sret = std::pair<typename MyStdMultiMap::iterator, typename MyStdMultiMap::iterator> sret =
stdmultimap.equal_range(stdmultimap.begin()->first); stdmultimap.equal_range(stdmultimap.begin()->first);
if( boost::container::iterator_distance(bret.first, bret.second) != if( boost::container::iterator_udistance(bret.first, bret.second) !=
boost::container::iterator_distance(sret.first, sret.second) ){ boost::container::iterator_udistance(sret.first, sret.second) ){
return 1; return 1;
} }
} }

View File

@@ -198,7 +198,7 @@ void test_pop_back_nd()
template <typename It1, typename It2> template <typename It1, typename It2>
void test_compare_ranges(It1 first1, It1 last1, It2 first2, It2 last2) void test_compare_ranges(It1 first1, It1 last1, It2 first2, It2 last2)
{ {
BOOST_TEST(boost::container::iterator_distance(first1, last1) == boost::container::iterator_distance(first2, last2)); BOOST_TEST(boost::container::iterator_udistance(first1, last1) == boost::container::iterator_udistance(first2, last2));
for ( ; first1 != last1 && first2 != last2 ; ++first1, ++first2 ) for ( ; first1 != last1 && first2 != last2 ; ++first1, ++first2 )
BOOST_TEST(*first1 == *first2); BOOST_TEST(*first1 == *first2);
} }
@@ -290,6 +290,7 @@ void test_erase_nd()
{ {
static_vector<T, N> s; static_vector<T, N> s;
typedef typename static_vector<T, N>::iterator It; typedef typename static_vector<T, N>::iterator It;
typedef typename static_vector<T, N>::difference_type dif_t;
for ( size_t i = 0 ; i < N ; ++i ) for ( size_t i = 0 ; i < N ; ++i )
s.push_back(T((int)i)); s.push_back(T((int)i));
@@ -299,8 +300,8 @@ void test_erase_nd()
for ( size_t i = 0 ; i < N ; ++i ) for ( size_t i = 0 ; i < N ; ++i )
{ {
static_vector<T, N> s1(s); static_vector<T, N> s1(s);
It it = s1.erase(s1.begin() + i); It it = s1.erase(s1.begin() + dif_t(i));
BOOST_TEST(s1.begin() + i == it); BOOST_TEST(s1.begin() + dif_t(i) == it);
BOOST_TEST(s1.size() == N - 1); BOOST_TEST(s1.size() == N - 1);
for ( size_t j = 0 ; j < i ; ++j ) for ( size_t j = 0 ; j < i ; ++j )
BOOST_TEST(s1[j] == T((int)j)); BOOST_TEST(s1[j] == T((int)j));
@@ -315,8 +316,8 @@ void test_erase_nd()
{ {
static_vector<T, N> s1(s); static_vector<T, N> s1(s);
size_t removed = i + n < N ? n : N - i; size_t removed = i + n < N ? n : N - i;
It it = s1.erase(s1.begin() + i, s1.begin() + i + removed); It it = s1.erase(s1.begin() + dif_t(i), s1.begin() + dif_t(i + removed));
BOOST_TEST(s1.begin() + i == it); BOOST_TEST(s1.begin() + dif_t(i) == it);
BOOST_TEST(s1.size() == N - removed); BOOST_TEST(s1.size() == N - removed);
for ( size_t j = 0 ; j < i ; ++j ) for ( size_t j = 0 ; j < i ; ++j )
BOOST_TEST(s1[j] == T((int)j)); BOOST_TEST(s1[j] == T((int)j));
@@ -330,18 +331,19 @@ template <typename T, size_t N, typename SV, typename C>
void test_insert(SV const& s, C const& c) void test_insert(SV const& s, C const& c)
{ {
size_t h = N/2; size_t h = N/2;
size_t n = size_t(h/1.5f); size_t n = size_t(float(h)/1.5f);
typedef typename static_vector<T, N>::difference_type dif_t;
for ( size_t i = 0 ; i <= h ; ++i ) for ( size_t i = 0 ; i <= h ; ++i )
{ {
static_vector<T, N> s1(s); static_vector<T, N> s1(s);
typename C::const_iterator it = c.begin(); typename C::const_iterator it = c.begin();
boost::container::iterator_advance(it, n); boost::container::iterator_uadvance(it, n);
typename static_vector<T, N>::iterator typename static_vector<T, N>::iterator
it1 = s1.insert(s1.begin() + i, c.begin(), it); it1 = s1.insert(s1.begin() + dif_t(i), c.begin(), it);
BOOST_TEST(s1.begin() + i == it1); BOOST_TEST(s1.begin() + dif_t(i) == it1);
BOOST_TEST(s1.size() == h+n); BOOST_TEST(s1.size() == h+n);
for ( size_t j = 0 ; j < i ; ++j ) for ( size_t j = 0 ; j < i ; ++j )
BOOST_TEST(s1[j] == T((int)j)); BOOST_TEST(s1[j] == T((int)j));
@@ -362,6 +364,7 @@ void test_insert_nd(T const& val)
list<T> l; list<T> l;
typedef typename static_vector<T, N>::iterator It; typedef typename static_vector<T, N>::iterator It;
typedef typename static_vector<T, N>::difference_type dif_t;
for ( size_t i = 0 ; i < h ; ++i ) for ( size_t i = 0 ; i < h ; ++i )
{ {
@@ -376,8 +379,8 @@ void test_insert_nd(T const& val)
for ( size_t i = 0 ; i <= h ; ++i ) for ( size_t i = 0 ; i <= h ; ++i )
{ {
static_vector<T, N> s1(s); static_vector<T, N> s1(s);
It it = s1.insert(s1.begin() + i, val); It it = s1.insert(s1.begin() + dif_t(i), val);
BOOST_TEST(s1.begin() + i == it); BOOST_TEST(s1.begin() + dif_t(i) == it);
BOOST_TEST(s1.size() == h+1); BOOST_TEST(s1.size() == h+1);
for ( size_t j = 0 ; j < i ; ++j ) for ( size_t j = 0 ; j < i ; ++j )
BOOST_TEST(s1[j] == T((int)j)); BOOST_TEST(s1[j] == T((int)j));
@@ -388,12 +391,12 @@ void test_insert_nd(T const& val)
} }
// insert(pos, n, val) // insert(pos, n, val)
{ {
size_t n = size_t(h/1.5f); size_t n = size_t(float(h)/1.5f);
for ( size_t i = 0 ; i <= h ; ++i ) for ( size_t i = 0 ; i <= h ; ++i )
{ {
static_vector<T, N> s1(s); static_vector<T, N> s1(s);
It it = s1.insert(s1.begin() + i, n, val); It it = s1.insert(s1.begin() + dif_t(i), n, val);
BOOST_TEST(s1.begin() + i == it); BOOST_TEST(s1.begin() + dif_t(i) == it);
BOOST_TEST(s1.size() == h+n); BOOST_TEST(s1.size() == h+n);
for ( size_t j = 0 ; j < i ; ++j ) for ( size_t j = 0 ; j < i ; ++j )
BOOST_TEST(s1[j] == T((int)j)); BOOST_TEST(s1[j] == T((int)j));
@@ -571,18 +574,19 @@ void test_emplace_2p()
{ {
static_vector<T, N> v; static_vector<T, N> v;
for (int i = 0 ; i < int(N) ; ++i ) for (int i = 0 ; i < (int)N ; ++i )
v.emplace_back(i, 100 + i); v.emplace_back(i, 100 + i);
BOOST_TEST(v.size() == N); BOOST_TEST(v.size() == N);
BOOST_TEST_THROWS(v.emplace_back((int)N, 100 + (int)N), bad_alloc_t); BOOST_TEST_THROWS(v.emplace_back((int)N, 100 + (int)N), bad_alloc_t);
BOOST_TEST(v.size() == N); BOOST_TEST(v.size() == N);
for (int i = 0 ; i < int(N) ; ++i ) for (int i = 0 ; i < (int)N ; ++i )
BOOST_TEST(v[i] == T(i, 100 + i)); BOOST_TEST(v[std::size_t(i)] == T(i, 100 + i));
} }
// emplace(pos, int, int) // emplace(pos, int, int)
{ {
typedef typename static_vector<T, N>::iterator It; typedef typename static_vector<T, N>::iterator It;
typedef typename static_vector<T, N>::difference_type dif_t;
int h = N / 2; int h = N / 2;
@@ -593,14 +597,14 @@ void test_emplace_2p()
for ( int i = 0 ; i <= h ; ++i ) for ( int i = 0 ; i <= h ; ++i )
{ {
static_vector<T, N> vv(v); static_vector<T, N> vv(v);
It it = vv.emplace(vv.begin() + i, i+100, i+200); It it = vv.emplace(vv.begin() + dif_t(i), i+100, i+200);
BOOST_TEST(vv.begin() + i == it); BOOST_TEST(vv.begin() + dif_t(i) == it);
BOOST_TEST(vv.size() == size_t(h+1)); BOOST_TEST(vv.size() == size_t(h+1));
for ( int j = 0 ; j < i ; ++j ) for ( int j = 0 ; j < i ; ++j )
BOOST_TEST(vv[j] == T(j, j+100)); BOOST_TEST(vv[std::size_t(j)] == T(j, j+100));
BOOST_TEST(vv[i] == T(i+100, i+200)); BOOST_TEST(vv[std::size_t(i)] == T(i+100, i+200));
for ( int j = 0 ; j < h-i ; ++j ) for ( int j = 0 ; j < h-i ; ++j )
BOOST_TEST(vv[j+i+1] == T(j+i, j+i+100)); BOOST_TEST(vv[std::size_t(j+i+1)] == T(j+i, j+i+100));
} }
} }
} }

View File

@@ -97,6 +97,18 @@ struct string_literals<char>
{ {
std::sprintf(buf, "%i", number); std::sprintf(buf, "%i", number);
} }
static void sprintf_number(char *buf, unsigned number)
{
std::sprintf(buf, "%u", number);
}
static void sprintf_number(char *buf, long number)
{
std::sprintf(buf, "%li", number);
}
static void sprintf_number(char *buf, unsigned long number)
{
std::sprintf(buf, "%lu", number);
}
}; };
template<> template<>
@@ -119,7 +131,7 @@ struct string_literals<wchar_t>
wchar_t *buf = buffer; wchar_t *buf = buffer;
while(1){ while(1){
int rem = number % 10; unsigned rem = number % 10;
number = number / 10; number = number / 10;
*buf = digits[rem]; *buf = digits[rem];
@@ -141,7 +153,7 @@ int string_test()
typedef basic_string<CharType> BoostString; typedef basic_string<CharType> BoostString;
typedef vector<BoostString> BoostStringVector; typedef vector<BoostString> BoostStringVector;
const int MaxSize = 100; const std::size_t MaxSize = 100;
{ {
BoostStringVector *boostStringVect = new BoostStringVector; BoostStringVector *boostStringVect = new BoostStringVector;
@@ -152,7 +164,7 @@ int string_test()
CharType buffer [20]; CharType buffer [20];
//First, push back //First, push back
for(int i = 0; i < MaxSize; ++i){ for(std::size_t i = 0; i < MaxSize; ++i){
auxBoostString = string_literals<CharType>::String(); auxBoostString = string_literals<CharType>::String();
auxStdString = string_literals<CharType>::String(); auxStdString = string_literals<CharType>::String();
string_literals<CharType>::sprintf_number(buffer, i); string_literals<CharType>::sprintf_number(buffer, i);
@@ -171,7 +183,7 @@ int string_test()
} }
//Now push back moving //Now push back moving
for(int i = 0; i < MaxSize; ++i){ for(std::size_t i = 0; i < MaxSize; ++i){
auxBoostString = string_literals<CharType>::String(); auxBoostString = string_literals<CharType>::String();
auxStdString = string_literals<CharType>::String(); auxStdString = string_literals<CharType>::String();
string_literals<CharType>::sprintf_number(buffer, i); string_literals<CharType>::sprintf_number(buffer, i);
@@ -186,7 +198,7 @@ int string_test()
} }
//push front //push front
for(int i = 0; i < MaxSize; ++i){ for(std::size_t i = 0; i < MaxSize; ++i){
auxBoostString = string_literals<CharType>::String(); auxBoostString = string_literals<CharType>::String();
auxStdString = string_literals<CharType>::String(); auxStdString = string_literals<CharType>::String();
string_literals<CharType>::sprintf_number(buffer, i); string_literals<CharType>::sprintf_number(buffer, i);
@@ -201,7 +213,7 @@ int string_test()
} }
//Now push front moving //Now push front moving
for(int i = 0; i < MaxSize; ++i){ for(std::size_t i = 0; i < MaxSize; ++i){
auxBoostString = string_literals<CharType>::String(); auxBoostString = string_literals<CharType>::String();
auxStdString = string_literals<CharType>::String(); auxStdString = string_literals<CharType>::String();
string_literals<CharType>::sprintf_number(buffer, i); string_literals<CharType>::sprintf_number(buffer, i);
@@ -285,10 +297,10 @@ int string_test()
if(!CheckEqualStringVector(boostStringVect, stdStringVect)) return 1; if(!CheckEqualStringVector(boostStringVect, stdStringVect)) return 1;
const CharType *prefix = string_literals<CharType>::Prefix(); const CharType *prefix = string_literals<CharType>::Prefix();
const int prefix_size = std::char_traits<CharType>::length(prefix); const std::size_t prefix_size = std::char_traits<CharType>::length(prefix);
const CharType *sufix = string_literals<CharType>::Suffix(); const CharType *sufix = string_literals<CharType>::Suffix();
for(int i = 0; i < MaxSize; ++i){ for(std::size_t i = 0; i < MaxSize; ++i){
(*boostStringVect)[i].append(sufix); (*boostStringVect)[i].append(sufix);
(*stdStringVect)[i].append(sufix); (*stdStringVect)[i].append(sufix);
(*boostStringVect)[i].insert((*boostStringVect)[i].begin(), (*boostStringVect)[i].insert((*boostStringVect)[i].begin(),
@@ -299,28 +311,28 @@ int string_test()
if(!CheckEqualStringVector(boostStringVect, stdStringVect)) return 1; if(!CheckEqualStringVector(boostStringVect, stdStringVect)) return 1;
for(int i = 0; i < MaxSize; ++i){ for(std::size_t i = 0; i < MaxSize; ++i){
std::reverse((*boostStringVect)[i].begin(), (*boostStringVect)[i].end()); std::reverse((*boostStringVect)[i].begin(), (*boostStringVect)[i].end());
std::reverse((*stdStringVect)[i].begin(), (*stdStringVect)[i].end()); std::reverse((*stdStringVect)[i].begin(), (*stdStringVect)[i].end());
} }
if(!CheckEqualStringVector(boostStringVect, stdStringVect)) return 1; if(!CheckEqualStringVector(boostStringVect, stdStringVect)) return 1;
for(int i = 0; i < MaxSize; ++i){ for(std::size_t i = 0; i < MaxSize; ++i){
std::reverse((*boostStringVect)[i].begin(), (*boostStringVect)[i].end()); std::reverse((*boostStringVect)[i].begin(), (*boostStringVect)[i].end());
std::reverse((*stdStringVect)[i].begin(), (*stdStringVect)[i].end()); std::reverse((*stdStringVect)[i].begin(), (*stdStringVect)[i].end());
} }
if(!CheckEqualStringVector(boostStringVect, stdStringVect)) return 1; if(!CheckEqualStringVector(boostStringVect, stdStringVect)) return 1;
for(int i = 0; i < MaxSize; ++i){ for(std::size_t i = 0; i < MaxSize; ++i){
std::sort(boostStringVect->begin(), boostStringVect->end()); std::sort(boostStringVect->begin(), boostStringVect->end());
std::sort(stdStringVect->begin(), stdStringVect->end()); std::sort(stdStringVect->begin(), stdStringVect->end());
} }
if(!CheckEqualStringVector(boostStringVect, stdStringVect)) return 1; if(!CheckEqualStringVector(boostStringVect, stdStringVect)) return 1;
for(int i = 0; i < MaxSize; ++i){ for(std::size_t i = 0; i < MaxSize; ++i){
(*boostStringVect)[i].replace((*boostStringVect)[i].begin(), (*boostStringVect)[i].replace((*boostStringVect)[i].begin(),
(*boostStringVect)[i].end(), (*boostStringVect)[i].end(),
string_literals<CharType>::String()); string_literals<CharType>::String());

View File

@@ -128,7 +128,7 @@ void test_equal_range(const C& a, std::initializer_list<unsigned> il)
for (auto&& elem : il) for (auto&& elem : il)
{ {
b.emplace_back(elem); b.emplace_back((int)elem);
} }
test_equal_range(a, b); test_equal_range(a, b);

View File

@@ -99,15 +99,16 @@ template<class MyBoostVector, class MyStdVector>
bool vector_copyable_only(MyBoostVector &boostvector, MyStdVector &stdvector, boost::container::dtl::true_type) bool vector_copyable_only(MyBoostVector &boostvector, MyStdVector &stdvector, boost::container::dtl::true_type)
{ {
typedef typename MyBoostVector::value_type IntType; typedef typename MyBoostVector::value_type IntType;
typedef typename MyBoostVector::difference_type difference_type;
std::size_t size = boostvector.size(); std::size_t size = boostvector.size();
boostvector.insert(boostvector.end(), 50, IntType(1)); boostvector.insert(boostvector.end(), 50u, IntType(1));
stdvector.insert(stdvector.end(), 50, 1); stdvector.insert(stdvector.end(), 50u, 1);
if(!test::CheckEqualContainers(boostvector, stdvector)) return false; if(!test::CheckEqualContainers(boostvector, stdvector)) return false;
{ {
IntType move_me(1); IntType move_me(1);
boostvector.insert(boostvector.begin()+size/2, 50, boost::move(move_me)); boostvector.insert(boostvector.begin()+difference_type(size/2), 50u, boost::move(move_me));
stdvector.insert(stdvector.begin()+size/2, 50, 1); stdvector.insert(stdvector.begin()+difference_type(size/2), 50u, 1);
if(!test::CheckEqualContainers(boostvector, stdvector)) return false; if(!test::CheckEqualContainers(boostvector, stdvector)) return false;
} }
{ {
@@ -164,32 +165,32 @@ bool vector_copyable_only(MyBoostVector &boostvector, MyStdVector &stdvector, bo
} }
{ //Vector(n, T) { //Vector(n, T)
::boost::movelib::unique_ptr<MyStdVector> const stdvectorp = ::boost::movelib::unique_ptr<MyStdVector> const stdvectorp =
::boost::movelib::make_unique<MyStdVector>(100, int(5)); ::boost::movelib::make_unique<MyStdVector>(100u, int(5));
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp = ::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp =
::boost::movelib::make_unique<MyBoostVector>(100, IntType(5)); ::boost::movelib::make_unique<MyBoostVector>(100u, IntType(5));
if(!test::CheckEqualContainers(*boostvectorp, *stdvectorp)) return 1; if(!test::CheckEqualContainers(*boostvectorp, *stdvectorp)) return 1;
} }
{ //Vector(n, T, alloc) { //Vector(n, T, alloc)
::boost::movelib::unique_ptr<MyStdVector> const stdvectorp = ::boost::movelib::unique_ptr<MyStdVector> const stdvectorp =
::boost::movelib::make_unique<MyStdVector>(100, int(5)); ::boost::movelib::make_unique<MyStdVector>(100u, int(5));
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp = ::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp =
::boost::movelib::make_unique<MyBoostVector>(100, IntType(5), typename MyBoostVector::allocator_type()); ::boost::movelib::make_unique<MyBoostVector>(100u, IntType(5), typename MyBoostVector::allocator_type());
if(!test::CheckEqualContainers(*boostvectorp, *stdvectorp)) return 1; if(!test::CheckEqualContainers(*boostvectorp, *stdvectorp)) return 1;
} }
{ //Vector(It, It) { //Vector(It, It)
::boost::movelib::unique_ptr<MyStdVector> const stdvectorp = ::boost::movelib::unique_ptr<MyStdVector> const stdvectorp =
::boost::movelib::make_unique<MyStdVector>(100); ::boost::movelib::make_unique<MyStdVector>(100u);
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp = ::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp =
::boost::movelib::make_unique<MyBoostVector>(100); ::boost::movelib::make_unique<MyBoostVector>(100u);
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp2 = ::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp2 =
::boost::movelib::make_unique<MyBoostVector>(boostvectorp->begin(), boostvectorp->end()); ::boost::movelib::make_unique<MyBoostVector>(boostvectorp->begin(), boostvectorp->end());
if(!test::CheckEqualContainers(*boostvectorp2, *stdvectorp)) return 1; if(!test::CheckEqualContainers(*boostvectorp2, *stdvectorp)) return 1;
} }
{ //Vector(It, It, alloc) { //Vector(It, It, alloc)
::boost::movelib::unique_ptr<MyStdVector> const stdvectorp = ::boost::movelib::unique_ptr<MyStdVector> const stdvectorp =
::boost::movelib::make_unique<MyStdVector>(100); ::boost::movelib::make_unique<MyStdVector>(100u);
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp = ::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp =
::boost::movelib::make_unique<MyBoostVector>(100); ::boost::movelib::make_unique<MyBoostVector>(100u);
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp2 = ::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp2 =
::boost::movelib::make_unique<MyBoostVector>(boostvectorp->begin(), boostvectorp->end(), typename MyBoostVector::allocator_type()); ::boost::movelib::make_unique<MyBoostVector>(boostvectorp->begin(), boostvectorp->end(), typename MyBoostVector::allocator_type());
if(!test::CheckEqualContainers(*boostvectorp2, *stdvectorp)) return 1; if(!test::CheckEqualContainers(*boostvectorp2, *stdvectorp)) return 1;
@@ -199,8 +200,8 @@ bool vector_copyable_only(MyBoostVector &boostvector, MyStdVector &stdvector, bo
::boost::movelib::make_unique<MyStdVector>(); ::boost::movelib::make_unique<MyStdVector>();
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp = ::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp =
::boost::movelib::make_unique<MyBoostVector>(); ::boost::movelib::make_unique<MyBoostVector>();
stdvectorp->resize(100, int(9)); stdvectorp->resize(100u, int(9));
boostvectorp->resize(100, IntType(9)); boostvectorp->resize(100u, IntType(9));
if(!test::CheckEqualContainers(*boostvectorp, *stdvectorp)) return 1; if(!test::CheckEqualContainers(*boostvectorp, *stdvectorp)) return 1;
} }
//operator= //operator=
@@ -215,8 +216,8 @@ bool vector_copyable_only(MyBoostVector &boostvector, MyStdVector &stdvector, bo
if(!test::CheckEqualContainers(bcopy2, scopy2)) return false; if(!test::CheckEqualContainers(bcopy2, scopy2)) return false;
//Assignment from a smaller vector //Assignment from a smaller vector
bcopy2.erase(bcopy2.begin() + bcopy2.size()/2, bcopy2.end()); bcopy2.erase(bcopy2.begin() + difference_type(bcopy2.size()/2), bcopy2.end());
scopy2.erase(scopy2.begin() + scopy2.size()/2, scopy2.end()); scopy2.erase(scopy2.begin() + difference_type(scopy2.size()/2), scopy2.end());
bcopy = bcopy2; bcopy = bcopy2;
scopy = scopy2; scopy = scopy2;
if(!test::CheckEqualContainers(bcopy, scopy)) return false; if(!test::CheckEqualContainers(bcopy, scopy)) return false;
@@ -227,8 +228,8 @@ bool vector_copyable_only(MyBoostVector &boostvector, MyStdVector &stdvector, bo
if(!test::CheckEqualContainers(bcopy2, scopy2)) return false; if(!test::CheckEqualContainers(bcopy2, scopy2)) return false;
//Assignment from bigger vector with no capacity //Assignment from bigger vector with no capacity
bcopy2.erase(bcopy2.begin() + bcopy2.size()/2, bcopy2.end()); bcopy2.erase(bcopy2.begin() + difference_type(bcopy2.size()/2), bcopy2.end());
scopy2.erase(scopy2.begin() + scopy2.size()/2, scopy2.end()); scopy2.erase(scopy2.begin() + difference_type(scopy2.size()/2), scopy2.end());
bcopy2.shrink_to_fit(); bcopy2.shrink_to_fit();
MyStdVector(scopy2).swap(scopy2); MyStdVector(scopy2).swap(scopy2);
@@ -250,6 +251,7 @@ int vector_test()
{ {
typedef std::vector<int> MyStdVector; typedef std::vector<int> MyStdVector;
typedef typename MyBoostVector::value_type IntType; typedef typename MyBoostVector::value_type IntType;
typedef typename MyBoostVector::difference_type difference_type;
const int max = 100; const int max = 100;
if(!test_range_insertion<MyBoostVector>()){ if(!test_range_insertion<MyBoostVector>()){
@@ -257,32 +259,32 @@ int vector_test()
} }
{ //Vector(n) { //Vector(n)
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp = ::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp =
::boost::movelib::make_unique<MyBoostVector>(100); ::boost::movelib::make_unique<MyBoostVector>(100u);
::boost::movelib::unique_ptr<MyStdVector> const stdvectorp = ::boost::movelib::unique_ptr<MyStdVector> const stdvectorp =
::boost::movelib::make_unique<MyStdVector>(100); ::boost::movelib::make_unique<MyStdVector>(100u);
if(!test::CheckEqualContainers(*boostvectorp, *stdvectorp)) return 1; if(!test::CheckEqualContainers(*boostvectorp, *stdvectorp)) return 1;
} }
{ //Vector(n, alloc) { //Vector(n, alloc)
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp = ::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp =
::boost::movelib::make_unique<MyBoostVector>(100, typename MyBoostVector::allocator_type()); ::boost::movelib::make_unique<MyBoostVector>(100u, typename MyBoostVector::allocator_type());
::boost::movelib::unique_ptr<MyStdVector> const stdvectorp = ::boost::movelib::unique_ptr<MyStdVector> const stdvectorp =
::boost::movelib::make_unique<MyStdVector>(100); ::boost::movelib::make_unique<MyStdVector>(100u);
if(!test::CheckEqualContainers(*boostvectorp, *stdvectorp)) return 1; if(!test::CheckEqualContainers(*boostvectorp, *stdvectorp)) return 1;
} }
{ //Vector(Vector &&) { //Vector(Vector &&)
::boost::movelib::unique_ptr<MyStdVector> const stdvectorp = ::boost::movelib::unique_ptr<MyStdVector> const stdvectorp =
::boost::movelib::make_unique<MyStdVector>(100); ::boost::movelib::make_unique<MyStdVector>(100u);
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp = ::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp =
::boost::movelib::make_unique<MyBoostVector>(100); ::boost::movelib::make_unique<MyBoostVector>(100u);
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp2 = ::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp2 =
::boost::movelib::make_unique<MyBoostVector>(::boost::move(*boostvectorp)); ::boost::movelib::make_unique<MyBoostVector>(::boost::move(*boostvectorp));
if(!test::CheckEqualContainers(*boostvectorp2, *stdvectorp)) return 1; if(!test::CheckEqualContainers(*boostvectorp2, *stdvectorp)) return 1;
} }
{ //Vector(Vector &&, alloc) { //Vector(Vector &&, alloc)
::boost::movelib::unique_ptr<MyStdVector> const stdvectorp = ::boost::movelib::unique_ptr<MyStdVector> const stdvectorp =
::boost::movelib::make_unique<MyStdVector>(100); ::boost::movelib::make_unique<MyStdVector>(100u);
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp = ::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp =
::boost::movelib::make_unique<MyBoostVector>(100); ::boost::movelib::make_unique<MyBoostVector>(100u);
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp2 = ::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp2 =
::boost::movelib::make_unique<MyBoostVector> ::boost::movelib::make_unique<MyBoostVector>
(::boost::move(*boostvectorp), typename MyBoostVector::allocator_type()); (::boost::move(*boostvectorp), typename MyBoostVector::allocator_type());
@@ -290,9 +292,9 @@ int vector_test()
} }
{ //Vector operator=(Vector &&) { //Vector operator=(Vector &&)
::boost::movelib::unique_ptr<MyStdVector> const stdvectorp = ::boost::movelib::unique_ptr<MyStdVector> const stdvectorp =
::boost::movelib::make_unique<MyStdVector>(100); ::boost::movelib::make_unique<MyStdVector>(100u);
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp = ::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp =
::boost::movelib::make_unique<MyBoostVector>(100); ::boost::movelib::make_unique<MyBoostVector>(100u);
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp2 = ::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp2 =
::boost::movelib::make_unique<MyBoostVector>(); ::boost::movelib::make_unique<MyBoostVector>();
*boostvectorp2 = ::boost::move(*boostvectorp); *boostvectorp2 = ::boost::move(*boostvectorp);
@@ -305,8 +307,8 @@ int vector_test()
MyBoostVector & boostvector = *boostvectorp; MyBoostVector & boostvector = *boostvectorp;
MyStdVector & stdvector = *stdvectorp; MyStdVector & stdvector = *stdvectorp;
boostvector.resize(100); boostvector.resize(100u);
stdvector.resize(100); stdvector.resize(100u);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
boostvector.resize(200); boostvector.resize(200);
@@ -358,7 +360,7 @@ int vector_test()
boostvector.insert(boostvector.end() boostvector.insert(boostvector.end()
,boost::make_move_iterator(&aux_vect[0]) ,boost::make_move_iterator(&aux_vect[0])
,boost::make_move_iterator(aux_vect + 50)); ,boost::make_move_iterator(aux_vect + 50));
if(std::size_t(boost::container::iterator_distance(insert_it, boostvector.end())) != 50) return 1; if(boost::container::iterator_udistance(insert_it, boostvector.end()) != 50) return 1;
stdvector.insert(stdvector.end(), aux_vect2, aux_vect2 + 50); stdvector.insert(stdvector.end(), aux_vect2, aux_vect2 + 50);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
@@ -369,8 +371,8 @@ int vector_test()
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
} }
{ {
boostvector.resize(100); boostvector.resize(100u);
stdvector.resize(100); stdvector.resize(100u);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
IntType aux_vect[50]; IntType aux_vect[50];
@@ -384,11 +386,11 @@ int vector_test()
} }
typename MyBoostVector::size_type old_size = boostvector.size(); typename MyBoostVector::size_type old_size = boostvector.size();
typename MyBoostVector::iterator insert_it = typename MyBoostVector::iterator insert_it =
boostvector.insert(boostvector.begin() + old_size/2 boostvector.insert(boostvector.begin() + difference_type(old_size/2)
,boost::make_move_iterator(&aux_vect[0]) ,boost::make_move_iterator(&aux_vect[0])
,boost::make_move_iterator(aux_vect + 50)); ,boost::make_move_iterator(aux_vect + 50));
if(boostvector.begin() + old_size/2 != insert_it) return 1; if(boostvector.begin() + difference_type(old_size/2) != insert_it) return 1;
stdvector.insert(stdvector.begin() + old_size/2, aux_vect2, aux_vect2 + 50); stdvector.insert(stdvector.begin() + difference_type(old_size/2), aux_vect2, aux_vect2 + 50);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
for(int i = 0; i < 50; ++i){ for(int i = 0; i < 50; ++i){
@@ -401,12 +403,12 @@ int vector_test()
} }
old_size = boostvector.size(); old_size = boostvector.size();
//Now try with input iterators instead //Now try with input iterators instead
insert_it = boostvector.insert(boostvector.begin() + old_size/2 insert_it = boostvector.insert(boostvector.begin() + difference_type(old_size/2)
,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0])) ,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0]))
,boost::make_move_iterator(make_input_from_forward_iterator(aux_vect + 50)) ,boost::make_move_iterator(make_input_from_forward_iterator(aux_vect + 50))
); );
if(boostvector.begin() + old_size/2 != insert_it) return 1; if(boostvector.begin() + difference_type(old_size/2) != insert_it) return 1;
stdvector.insert(stdvector.begin() + old_size/2, aux_vect2, aux_vect2 + 50); stdvector.insert(stdvector.begin() + difference_type(old_size/2), aux_vect2, aux_vect2 + 50);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1; if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
} }
@@ -505,7 +507,7 @@ int vector_test()
MyStdVector(stdvector).swap(stdvector); MyStdVector(stdvector).swap(stdvector);
if(!test::CheckEqualContainers(boostvector, stdvector)) return false; if(!test::CheckEqualContainers(boostvector, stdvector)) return false;
boostvector.resize(100); boostvector.resize(100u);
if(!test_nth_index_of(boostvector)) if(!test_nth_index_of(boostvector))
return 1; return 1;