forked from boostorg/container
Support GCC's -Wconversion -Wfloat-conversion -Warith-conversion -Wsign-conversion warnings.
This commit is contained in:
@@ -194,17 +194,17 @@ void list_test_template(std::size_t num_iterations, std::size_t num_elements, bo
|
||||
<< ";"
|
||||
<< num_elements
|
||||
<< ";"
|
||||
<< float(tinsert)/(num_iterations*num_elements)
|
||||
<< float(tinsert)/float(num_iterations*num_elements)
|
||||
<< ";"
|
||||
<< (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
|
||||
<< ";"
|
||||
<< (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
|
||||
<< ";"
|
||||
@@ -215,11 +215,11 @@ void list_test_template(std::size_t num_iterations, std::size_t num_elements, bo
|
||||
std::cout << std::endl
|
||||
<< "Allocator: " << get_allocator_name<Allocator>::get()
|
||||
<< 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
|
||||
<< " 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
|
||||
<< " system MB/inuse bytes after: " << (float)erase_stats.system_bytes/(1024*1024) << '\t' << bc::dlmalloc_in_use_memory()
|
||||
<< std::endl << std::endl;
|
||||
|
||||
@@ -120,12 +120,12 @@ void allocation_timing_test(unsigned int num_iterations, unsigned int num_elemen
|
||||
std::cout << " Malloc type: " << malloc_name
|
||||
<< std::endl
|
||||
<< " allocation ns: "
|
||||
<< float(nseconds)/(num_iterations*num_elements)
|
||||
<< float(nseconds)/float(num_iterations*num_elements)
|
||||
<< std::endl
|
||||
<< " capacity - alloc calls (new/expand): "
|
||||
<< (unsigned int)capacity << " - "
|
||||
<< (float(numalloc) + float(numexpand))/num_iterations
|
||||
<< "(" << float(numalloc)/num_iterations << "/" << float(numexpand)/num_iterations << ")"
|
||||
<< (float(numalloc) + float(numexpand))/float(num_iterations)
|
||||
<< "(" << float(numalloc)/float(num_iterations) << "/" << float(numexpand)/float(num_iterations) << ")"
|
||||
<< std::endl << std::endl;
|
||||
dlmalloc_trim(0);
|
||||
}
|
||||
|
||||
@@ -147,13 +147,13 @@ void vector_test_template(unsigned int num_iterations, unsigned int num_elements
|
||||
<< ";"
|
||||
<< 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;
|
||||
}
|
||||
else{
|
||||
@@ -161,12 +161,12 @@ void vector_test_template(unsigned int num_iterations, unsigned int num_elements
|
||||
<< "Allocator: " << get_allocator_name<Allocator>::get()
|
||||
<< std::endl
|
||||
<< " push_back ns: "
|
||||
<< float(nseconds)/(num_iterations*num_elements)
|
||||
<< float(nseconds)/float(num_iterations*num_elements)
|
||||
<< std::endl
|
||||
<< " capacity - alloc calls (new/expand): "
|
||||
<< (unsigned int)capacity << " - "
|
||||
<< (float(numalloc) + float(numexpand))/num_iterations
|
||||
<< "(" << float(numalloc)/num_iterations << "/" << float(numexpand)/num_iterations << ")"
|
||||
<< (float(numalloc) + float(numexpand))/float(num_iterations)
|
||||
<< "(" << float(numalloc)/float(num_iterations) << "/" << float(numexpand)/float(num_iterations) << ")"
|
||||
<< std::endl;
|
||||
std::cout << '\n'
|
||||
<< " ----------------------------------- "
|
||||
|
||||
@@ -151,12 +151,12 @@ void vector_test_template(unsigned int num_iterations, unsigned int num_elements
|
||||
<< "Allocator: " << typeid(typename Container::allocator_type).name()
|
||||
<< std::endl
|
||||
<< " push_back ns: "
|
||||
<< float(nseconds)/(num_iterations*num_elements)
|
||||
<< float(nseconds)/float(num_iterations*num_elements)
|
||||
<< std::endl
|
||||
<< " capacity - alloc calls (new/expand): "
|
||||
<< (unsigned int)capacity << " - "
|
||||
<< (float(numalloc) + float(numexpand))/num_iterations
|
||||
<< "(" << float(numalloc)/num_iterations << "/" << float(numexpand)/num_iterations << ")"
|
||||
<< (float(numalloc) + float(numexpand))/float(num_iterations)
|
||||
<< "(" << float(numalloc)/float(num_iterations) << "/" << float(numexpand)/float(num_iterations) << ")"
|
||||
<< std::endl << std::endl;
|
||||
bc::dlmalloc_trim(0);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ void vector_test_template(unsigned int num_iterations, unsigned int num_elements
|
||||
<< ";"
|
||||
<< num_shrink
|
||||
<< ";"
|
||||
<< float(nseconds)/(num_iterations*num_elements)
|
||||
<< float(nseconds)/float(num_iterations*num_elements)
|
||||
<< std::endl;
|
||||
}
|
||||
else{
|
||||
@@ -124,7 +124,7 @@ void vector_test_template(unsigned int num_iterations, unsigned int num_elements
|
||||
<< " num_shrink: " << num_shrink
|
||||
<< std::endl
|
||||
<< " shrink_to_fit ns: "
|
||||
<< float(nseconds)/(num_iterations*num_elements)
|
||||
<< float(nseconds)/float(num_iterations*num_elements)
|
||||
<< std::endl << std::endl;
|
||||
}
|
||||
bc::dlmalloc_trim(0);
|
||||
|
||||
@@ -123,7 +123,7 @@ void stable_vector_test_template(unsigned int num_iterations, unsigned int num_e
|
||||
<< ";"
|
||||
<< num_elements
|
||||
<< ";"
|
||||
<< float(nseconds)/(num_iterations*num_elements)
|
||||
<< float(nseconds)/float(num_iterations*num_elements)
|
||||
<< ";";
|
||||
}
|
||||
else{
|
||||
@@ -132,7 +132,7 @@ void stable_vector_test_template(unsigned int num_iterations, unsigned int num_e
|
||||
<< GetContainer<Allocator>::vector_name()
|
||||
<< std::endl
|
||||
<< " allocation ns: "
|
||||
<< float(nseconds)/(num_iterations*num_elements);
|
||||
<< float(nseconds)/float(num_iterations*num_elements);
|
||||
}
|
||||
// top_capacity = l.capacity();
|
||||
//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){
|
||||
std::cout << float(nseconds)/(num_iterations*num_elements)
|
||||
std::cout << float(nseconds)/float(num_iterations*num_elements)
|
||||
<< std::endl;
|
||||
}
|
||||
else{
|
||||
std::cout << '\t'
|
||||
<< " deallocation ns: "
|
||||
<< float(nseconds)/(num_iterations*num_elements)/*
|
||||
<< float(nseconds)/float(num_iterations*num_elements)/*
|
||||
<< std::endl
|
||||
<< " max capacity: "
|
||||
<< static_cast<unsigned int>(top_capacity)
|
||||
|
||||
@@ -241,7 +241,7 @@ void vector_test_template(std::size_t num_iterations, std::size_t num_elements,
|
||||
nanosecond_type nseconds = timer.elapsed().wall;
|
||||
|
||||
std::cout << cont_name << "->" << op.name() <<" ns: "
|
||||
<< float(nseconds)/(num_iterations*num_elements)
|
||||
<< float(nseconds)/float(num_iterations*num_elements)
|
||||
<< '\t'
|
||||
<< "Capacity: " << capacity
|
||||
<< "\n";
|
||||
|
||||
+10
-10
@@ -1617,7 +1617,7 @@ private:
|
||||
// Linear O(N).
|
||||
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;
|
||||
for (; first_sm != last_sm ; ++first_sm, ++first_la)
|
||||
@@ -1632,7 +1632,7 @@ private:
|
||||
::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
|
||||
@@ -1641,7 +1641,7 @@ private:
|
||||
// Linear O(N).
|
||||
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;
|
||||
for (; first_sm != last_sm ; ++first_sm, ++first_la)
|
||||
@@ -1704,7 +1704,7 @@ private:
|
||||
{
|
||||
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
|
||||
|
||||
@@ -1736,16 +1736,16 @@ private:
|
||||
{
|
||||
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
|
||||
|
||||
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;
|
||||
}
|
||||
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
|
||||
|
||||
@@ -1799,7 +1799,7 @@ private:
|
||||
{
|
||||
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
|
||||
|
||||
@@ -1835,11 +1835,11 @@ private:
|
||||
|
||||
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
|
||||
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
|
||||
}
|
||||
|
||||
@@ -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*/)
|
||||
{
|
||||
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);
|
||||
return dst + d;
|
||||
}
|
||||
@@ -205,7 +205,7 @@ O uninitialized_copy_dispatch(I first, I last, O dst,
|
||||
bcd::true_type const& /*use_memcpy*/)
|
||||
{
|
||||
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);
|
||||
return dst + d;
|
||||
}
|
||||
@@ -237,7 +237,7 @@ O uninitialized_move_dispatch(I first, I last, O dst,
|
||||
bcd::true_type const& /*use_memcpy*/)
|
||||
{
|
||||
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);
|
||||
return dst + d;
|
||||
}
|
||||
@@ -288,7 +288,7 @@ O move_dispatch(I first, I last, O dst,
|
||||
bcd::true_type const& /*use_memmove*/)
|
||||
{
|
||||
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 );
|
||||
return dst + d;
|
||||
}
|
||||
@@ -320,7 +320,7 @@ BDO move_backward_dispatch(BDI first, BDI last, BDO dst,
|
||||
bcd::true_type const& /*use_memmove*/)
|
||||
{
|
||||
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);
|
||||
::memmove(boost::container::dtl::addressof(*foo), boost::container::dtl::addressof(*first), sizeof(value_type) * d);
|
||||
return foo;
|
||||
|
||||
Reference in New Issue
Block a user