From 7f35ef420e50bd9f3a3772ec6f8f920ce491667b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Wed, 20 Oct 2021 00:18:05 +0200 Subject: [PATCH] Support Clang's -Wconversion -Wfloat-conversion -Wsign-conversion with -Werror --- bench/bench_alloc.cpp | 26 ++++----- bench/bench_alloc_expand_bwd.cpp | 42 +++++++------- bench/bench_alloc_expand_fwd.cpp | 50 ++++++++--------- bench/bench_alloc_shrink_to_fit.cpp | 38 ++++++------- bench/bench_alloc_stable_vector_burst.cpp | 48 ++++++++-------- bench/bench_static_vector.cpp | 2 +- bench/bench_vectors.cpp | 2 +- include/boost/container/node_allocator.hpp | 2 +- test/map_test.hpp | 64 +++++++++++----------- test/set_test.hpp | 12 ++-- test/string_test.cpp | 4 +- 11 files changed, 145 insertions(+), 145 deletions(-) diff --git a/bench/bench_alloc.cpp b/bench/bench_alloc.cpp index 14d4ae7..713a8b9 100644 --- a/bench/bench_alloc.cpp +++ b/bench/bench_alloc.cpp @@ -30,10 +30,10 @@ using boost::move_detail::nanosecond_type; using namespace boost::container; template -void allocation_timing_test(unsigned int num_iterations, unsigned int num_elements) +void allocation_timing_test(std::size_t num_iterations, std::size_t num_elements) { size_t capacity = 0; - unsigned int numalloc = 0, numexpand = 0; + std::size_t numalloc = 0, numexpand = 0; std::cout << " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n" @@ -52,7 +52,7 @@ void allocation_timing_test(unsigned int num_iterations, unsigned int num_elemen cpu_timer timer; timer.resume(); - for(unsigned int r = 0; r != num_iterations; ++r){ + for(std::size_t r = 0; r != num_iterations; ++r){ void *first_mem = 0; if(m_mode != BOOST_CONTAINER_EXPAND_FWD) first_mem = dlmalloc_malloc(sizeof(POD)*num_elements*3/2); @@ -123,7 +123,7 @@ void allocation_timing_test(unsigned int num_iterations, unsigned int num_elemen << float(nseconds)/float(num_iterations*num_elements) << std::endl << " capacity - alloc calls (new/expand): " - << (unsigned int)capacity << " - " + << (std::size_t)capacity << " - " << (float(numalloc) + float(numexpand))/float(num_iterations) << "(" << float(numalloc)/float(num_iterations) << "/" << float(numexpand)/float(num_iterations) << ")" << std::endl << std::endl; @@ -152,24 +152,24 @@ int allocation_loop() #define SIMPLE_IT #ifdef SINGLE_TEST #ifdef NDEBUG - unsigned int numrep [] = { 50000 }; + std::size_t numrep [] = { 50000 }; #else - unsigned int numrep [] = { 5000 }; + std::size_t numrep [] = { 5000 }; #endif - unsigned int numele [] = { 100 }; + std::size_t numele [] = { 100 }; #elif defined(SIMPLE_IT) - unsigned int numrep [] = { 3 }; - unsigned int numele [] = { 100 }; + std::size_t numrep [] = { 3 }; + std::size_t numele [] = { 100 }; #else #ifdef NDEBUG - unsigned int numrep [] = { /*10000, */10000, 100000, 1000000 }; + std::size_t numrep [] = { /*10000, */10000, 100000, 1000000 }; #else - unsigned int numrep [] = { /*10000, */1000, 10000, 100000 }; + std::size_t numrep [] = { /*10000, */1000, 10000, 100000 }; #endif - unsigned int numele [] = { /*10000, */1000, 100, 10 }; + std::size_t numele [] = { /*10000, */1000, 100, 10 }; #endif - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ allocation_timing_test(numrep[i], numele[i]); } diff --git a/bench/bench_alloc_expand_bwd.cpp b/bench/bench_alloc_expand_bwd.cpp index 46ac435..9a8c4fa 100644 --- a/bench/bench_alloc_expand_bwd.cpp +++ b/bench/bench_alloc_expand_bwd.cpp @@ -101,16 +101,16 @@ void print_header() } template -void vector_test_template(unsigned int num_iterations, unsigned int num_elements, bool csv_output) +void vector_test_template(std::size_t num_iterations, std::size_t num_elements, bool csv_output) { typedef Allocator IntAllocator; - unsigned int numalloc = 0, numexpand = 0; + std::size_t numalloc = 0, numexpand = 0; cpu_timer timer; timer.resume(); - unsigned int capacity = 0; - for(unsigned int r = 0; r != num_iterations; ++r){ + std::size_t capacity = 0; + for(std::size_t r = 0; r != num_iterations; ++r){ bc::vector v; v.reset_alloc_stats(); void *first_mem = 0; @@ -119,12 +119,12 @@ void vector_test_template(unsigned int num_iterations, unsigned int num_elements v.push_back(MyInt(0)); bc::dlmalloc_free(first_mem); - for(unsigned int e = 0; e != num_elements; ++e){ - v.push_back(MyInt(e)); + for(std::size_t e = 0; e != num_elements; ++e){ + v.push_back(MyInt((int)e)); } numalloc += v.num_alloc; numexpand += v.num_expand_bwd; - capacity = static_cast(v.capacity()); + capacity = static_cast(v.capacity()); } BOOST_CATCH(...){ bc::dlmalloc_free(first_mem); @@ -164,7 +164,7 @@ void vector_test_template(unsigned int num_iterations, unsigned int num_elements << float(nseconds)/float(num_iterations*num_elements) << std::endl << " capacity - alloc calls (new/expand): " - << (unsigned int)capacity << " - " + << (std::size_t)capacity << " - " << (float(numalloc) + float(numexpand))/float(num_iterations) << "(" << float(numalloc)/float(num_iterations) << "/" << float(numexpand)/float(num_iterations) << ")" << std::endl; @@ -181,42 +181,42 @@ int main(int argc, const char *argv[]) #define SIMPLE_IT #ifdef SINGLE_TEST #ifdef NDEBUG - unsigned int numit [] = { 10 }; + std::size_t numit [] = { 10 }; #else - unsigned int numit [] = { 10 }; + std::size_t numit [] = { 10 }; #endif - unsigned int numele [] = { 10000 }; + std::size_t numele [] = { 10000 }; #elif defined(SIMPLE_IT) - unsigned int numit [] = { 3 }; - unsigned int numele[] = { 10000 }; + std::size_t numit [] = { 3 }; + std::size_t numele[] = { 10000 }; #else #ifdef NDEBUG - unsigned int numit [] = { 2000, 20000, 200000, 2000000 }; + std::size_t numit [] = { 2000, 20000, 200000, 2000000 }; #else - unsigned int numit [] = { 100, 1000, 10000, 100000 }; + std::size_t numit [] = { 100, 1000, 10000, 100000 }; #endif - unsigned int numele [] = { 10000, 1000, 100, 10 }; + std::size_t numele [] = { 10000, 1000, 100, 10 }; #endif bool csv_output = argc == 2 && (strcmp(argv[1], "--csv-output") == 0); if(csv_output){ print_header(); - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ vector_test_template(numit[i], numele[i], csv_output); } - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ vector_test_template(numit[i], numele[i], csv_output); } - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ vector_test_template(numit[i], numele[i], csv_output); } - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ vector_test_template(numit[i], numele[i], csv_output); } } else{ - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ std::cout << "\n ----------------------------------- \n" << " Iterations/Elements: " << numit[i] << "/" << numele[i] << "\n ----------------------------------- \n"; diff --git a/bench/bench_alloc_expand_fwd.cpp b/bench/bench_alloc_expand_fwd.cpp index 20e98a5..f970e54 100644 --- a/bench/bench_alloc_expand_fwd.cpp +++ b/bench/bench_alloc_expand_fwd.cpp @@ -85,15 +85,15 @@ class MyInt }; template -void vector_test_template(unsigned int num_iterations, unsigned int num_elements) +void vector_test_template(std::size_t num_iterations, std::size_t num_elements) { - unsigned int numalloc = 0, numexpand = 0; + std::size_t numalloc = 0, numexpand = 0; cpu_timer timer; timer.resume(); - unsigned int capacity = 0; - for(unsigned int r = 0; r != num_iterations; ++r){ + std::size_t capacity = 0; + for(std::size_t r = 0; r != num_iterations; ++r){ Container v; #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS reset_alloc_stats(v); @@ -101,47 +101,47 @@ void vector_test_template(unsigned int num_iterations, unsigned int num_elements //v.reserve(num_elements); //MyInt a[3]; /* - for(unsigned int e = 0; e != num_elements/3; ++e){ + for(std::size_t e = 0; e != num_elements/3; ++e){ v.insert(v.end(), &a[0], &a[0]+3); }*/ /* - for(unsigned int e = 0; e != num_elements/3; ++e){ - v.insert(v.end(), 3, MyInt(e)); + for(std::size_t e = 0; e != num_elements/3; ++e){ + v.insert(v.end(), 3, MyInt((int)e)); }*/ /* - for(unsigned int e = 0; e != num_elements/3; ++e){ + for(std::size_t e = 0; e != num_elements/3; ++e){ v.insert(v.empty() ? v.end() : --v.end(), &a[0], &a[0]+3); }*/ /* - for(unsigned int e = 0; e != num_elements/3; ++e){ - v.insert(v.empty() ? v.end() : --v.end(), 3, MyInt(e)); + for(std::size_t e = 0; e != num_elements/3; ++e){ + v.insert(v.empty() ? v.end() : --v.end(), 3, MyInt((int)e)); }*/ /* - for(unsigned int e = 0; e != num_elements/3; ++e){ + for(std::size_t e = 0; e != num_elements/3; ++e){ v.insert(v.size() >= 3 ? v.end()-3 : v.begin(), &a[0], &a[0]+3); }*/ /* - for(unsigned int e = 0; e != num_elements/3; ++e){ - v.insert(v.size() >= 3 ? v.end()-3 : v.begin(), 3, MyInt(e)); + for(std::size_t e = 0; e != num_elements/3; ++e){ + v.insert(v.size() >= 3 ? v.end()-3 : v.begin(), 3, MyInt((int)e)); }*/ /* - for(unsigned int e = 0; e != num_elements; ++e){ - v.insert(v.end(), MyInt(e)); + for(std::size_t e = 0; e != num_elements; ++e){ + v.insert(v.end(), MyInt((int)e)); }*/ /* - for(unsigned int e = 0; e != num_elements; ++e){ - v.insert(v.empty() ? v.end() : --v.end(), MyInt(e)); + for(std::size_t e = 0; e != num_elements; ++e){ + v.insert(v.empty() ? v.end() : --v.end(), MyInt((int)e)); }*/ - for(unsigned int e = 0; e != num_elements; ++e){ - v.push_back(MyInt(e)); + for(std::size_t e = 0; e != num_elements; ++e){ + v.push_back(MyInt((int)e)); } #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS numalloc += get_num_alloc(v); numexpand += get_num_expand(v); #endif - capacity = static_cast(v.capacity()); + capacity = static_cast(v.capacity()); } timer.stop(); @@ -154,7 +154,7 @@ void vector_test_template(unsigned int num_iterations, unsigned int num_elements << float(nseconds)/float(num_iterations*num_elements) << std::endl << " capacity - alloc calls (new/expand): " - << (unsigned int)capacity << " - " + << (std::size_t)capacity << " - " << (float(numalloc) + float(numexpand))/float(num_iterations) << "(" << float(numalloc)/float(num_iterations) << "/" << float(numexpand)/float(num_iterations) << ")" << std::endl << std::endl; @@ -184,15 +184,15 @@ int main() std::size_t numele [] = { 10000 }; #else #ifdef NDEBUG - unsigned int numit [] = { 1000, 10000, 100000, 1000000 }; + std::size_t numit [] = { 1000, 10000, 100000, 1000000 }; #else - unsigned int numit [] = { 100, 1000, 10000, 100000 }; + std::size_t numit [] = { 100, 1000, 10000, 100000 }; #endif - unsigned int numele [] = { 10000, 1000, 100, 10 }; + std::size_t numele [] = { 10000, 1000, 100, 10 }; #endif print_header(); - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ vector_test_template< bc::vector > >(numit[i], numele[i]); vector_test_template< bc::vector > >(numit[i], numele[i]); vector_test_template > >(numit[i], numele[i]); diff --git a/bench/bench_alloc_shrink_to_fit.cpp b/bench/bench_alloc_shrink_to_fit.cpp index cbc7739..5595a26 100644 --- a/bench/bench_alloc_shrink_to_fit.cpp +++ b/bench/bench_alloc_shrink_to_fit.cpp @@ -33,7 +33,7 @@ namespace bc = boost::container; class MyInt { - std::size_t int_; //Use a type that will grow on 64 bit machines + std::ptrdiff_t int_; //Use a type that will grow on 64 bit machines public: MyInt(int i = 0) : int_(i){} @@ -71,13 +71,13 @@ void print_header() } template -void vector_test_template(unsigned int num_iterations, unsigned int num_elements, bool csv_output) +void vector_test_template(std::size_t num_iterations, std::size_t num_elements, bool csv_output) { typedef Allocator IntAllocator; - unsigned int capacity = 0; + std::size_t capacity = 0; const std::size_t Step = 5; - unsigned int num_shrink = 0; + std::size_t num_shrink = 0; (void)capacity; cpu_timer timer; @@ -88,12 +88,12 @@ void vector_test_template(unsigned int num_iterations, unsigned int num_elements ::value> alloc_version; #endif - for(unsigned int r = 0; r != num_iterations; ++r){ + for(std::size_t r = 0; r != num_iterations; ++r){ bc::vector v(num_elements); v.reset_alloc_stats(); num_shrink = 0; - for(unsigned int e = num_elements; e != 0; e -= Step){ - v.erase(v.end() - Step, v.end()); + for(std::size_t e = num_elements; e != 0; e -= Step){ + v.erase(v.end() - std::ptrdiff_t(Step), v.end()); v.shrink_to_fit(); assert( (alloc_version::value != 2) || (e == Step) || (v.num_shrink > num_shrink) ); num_shrink = v.num_shrink; @@ -136,39 +136,39 @@ int main(int argc, const char *argv[]) #define SIMPLE_IT #ifdef SINGLE_TEST #ifdef NDEBUG - unsigned int numit [] = { 10 }; + std::size_t numit [] = { 10 }; #else - unsigned int numit [] = { 50 }; - unsigned int numele[] = { 2000 }; + std::size_t numit [] = { 50 }; + std::size_t numele[] = { 2000 }; #endif #elif defined SIMPLE_IT - unsigned int numit [] = { 3 }; - unsigned int numele[] = { 2000 }; + std::size_t numit [] = { 3 }; + std::size_t numele[] = { 2000 }; #else #ifdef NDEBUG - unsigned int numit [] = { 100, 1000, 10000 }; + std::size_t numit [] = { 100, 1000, 10000 }; #else - unsigned int numit [] = { 10, 100, 1000 }; + std::size_t numit [] = { 10, 100, 1000 }; #endif - unsigned int numele [] = { 10000, 2000, 500 }; + std::size_t numele [] = { 10000, 2000, 500 }; #endif bool csv_output = argc == 2 && (strcmp(argv[1], "--csv-output") == 0); if(csv_output){ print_header(); - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ vector_test_template(numit[i], numele[i], csv_output); } - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ vector_test_template(numit[i], numele[i], csv_output); } - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ vector_test_template(numit[i], numele[i], csv_output); } } else{ - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ std::cout << "\n ----------------------------------- \n" << " Iterations/Elements: " << numit[i] << "/" << numele[i] << "\n ----------------------------------- \n"; diff --git a/bench/bench_alloc_stable_vector_burst.cpp b/bench/bench_alloc_stable_vector_burst.cpp index 9d9652a..7233321 100644 --- a/bench/bench_alloc_stable_vector_burst.cpp +++ b/bench/bench_alloc_stable_vector_burst.cpp @@ -96,7 +96,7 @@ struct get_stable_vector }; template class GetContainer, class Allocator> -void stable_vector_test_template(unsigned int num_iterations, unsigned int num_elements, bool csv_output) +void stable_vector_test_template(std::size_t num_iterations, std::size_t num_elements, bool csv_output) { typedef typename GetContainer::type vector_type; //std::size_t top_capacity = 0; @@ -107,8 +107,8 @@ void stable_vector_test_template(unsigned int num_iterations, unsigned int num_e cpu_timer timer; timer.resume(); - for(unsigned int r = 0; r != num_iterations; ++r){ - l.insert(l.end(), num_elements, MyInt(r)); + for(std::size_t r = 0; r != num_iterations; ++r){ + l.insert(l.end(), num_elements, MyInt((int)r)); } timer.stop(); @@ -138,7 +138,7 @@ void stable_vector_test_template(unsigned int num_iterations, unsigned int num_e //Now preprocess ranges to erase std::vector ranges_to_erase; ranges_to_erase.push_back(l.begin()); - for(unsigned int r = 0; r != num_iterations; ++r){ + for(std::size_t r = 0; r != num_iterations; ++r){ typename vector_type::iterator next_pos(ranges_to_erase[r]); std::size_t n = num_elements; while(n--){ ++next_pos; } @@ -149,7 +149,7 @@ void stable_vector_test_template(unsigned int num_iterations, unsigned int num_e timer.stop(); timer.start(); - for(unsigned int r = 0; r != num_iterations; ++r){ + for(std::size_t r = 0; r != num_iterations; ++r){ std::size_t init_pos = (num_iterations-1)-r; l.erase(ranges_to_erase[init_pos], l.end()); } @@ -169,10 +169,10 @@ void stable_vector_test_template(unsigned int num_iterations, unsigned int num_e << float(nseconds)/float(num_iterations*num_elements)/* << std::endl << " max capacity: " - << static_cast(top_capacity) + << static_cast(top_capacity) << std::endl << " remaining cap. " - << static_cast(top_capacity - num_iterations*num_elements) + << static_cast(top_capacity - num_iterations*num_elements) << " (" << (float(top_capacity)/float(num_iterations*num_elements) - 1)*100 << " %)"*/ << std::endl << std::endl; } @@ -224,21 +224,21 @@ int main(int argc, const char *argv[]) #define SIMPLE_IT #ifdef SINGLE_TEST #ifdef NDEBUG - unsigned int numit [] = { 40 }; + std::size_t numit [] = { 40 }; #else - unsigned int numit [] = { 4 }; + std::size_t numit [] = { 4 }; #endif - unsigned int numele [] = { 10000 }; + std::size_t numele [] = { 10000 }; #elif defined(SIMPLE_IT) - unsigned int numit [] = { 3 }; - unsigned int numele [] = { 10000 }; + std::size_t numit [] = { 3 }; + std::size_t numele [] = { 10000 }; #else #ifdef NDEBUG - unsigned int numit [] = { 40, 400, 4000, 40000 }; + std::size_t numit [] = { 40, 400, 4000, 40000 }; #else - unsigned int numit [] = { 4, 40, 400, 4000 }; + std::size_t numit [] = { 4, 40, 400, 4000 }; #endif - unsigned int numele [] = { 10000, 1000, 100, 10 }; + std::size_t numele [] = { 10000, 1000, 100, 10 }; #endif //Warning: range erasure is buggy. Vector iterators are not stable, so it is not @@ -248,33 +248,33 @@ int main(int argc, const char *argv[]) if(csv_output){ print_header(); - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ stable_vector_test_template(numit[i], numele[i], csv_output); } - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ stable_vector_test_template(numit[i], numele[i], csv_output); } - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ stable_vector_test_template(numit[i], numele[i], csv_output); } - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ stable_vector_test_template(numit[i], numele[i], csv_output); } - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ stable_vector_test_template(numit[i], numele[i], csv_output); } - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ stable_vector_test_template(numit[i], numele[i], csv_output); } - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ stable_vector_test_template(numit[i], numele[i], csv_output); } - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ stable_vector_test_template(numit[i], numele[i], csv_output); } } else{ - for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ + for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){ std::cout << "\n ----------------------------------- \n" << " Iterations/Elements: " << numit[i] << "/" << numele[i] << "\n ----------------------------------- \n"; diff --git a/bench/bench_static_vector.cpp b/bench/bench_static_vector.cpp index 390e57b..29da30d 100644 --- a/bench/bench_static_vector.cpp +++ b/bench/bench_static_vector.cpp @@ -93,7 +93,7 @@ cpu_times time_it() std::sort(v.begin(), v.end()); sortTime.stop(); rotateTime.resume(); - std::rotate(v.begin(), v.begin() + v.size()/2, v.end()); + std::rotate(v.begin(), v.begin() + std::ptrdiff_t(v.size()/2), v.end()); rotateTime.stop(); destructionTime.resume(); delete &v; diff --git a/bench/bench_vectors.cpp b/bench/bench_vectors.cpp index 19dc936..fb86767 100644 --- a/bench/bench_vectors.cpp +++ b/bench/bench_vectors.cpp @@ -177,7 +177,7 @@ struct insert_near_end { typedef typename C::iterator it_t; it_t it (c.end()); - it -= static_cast(c.size() >= 2)*2; + it -= static_cast(c.size() >= 2)*2; c.insert(it, MyInt(i)); } diff --git a/include/boost/container/node_allocator.hpp b/include/boost/container/node_allocator.hpp index 64719fd..fa17645 100644 --- a/include/boost/container/node_allocator.hpp +++ b/include/boost/container/node_allocator.hpp @@ -81,7 +81,7 @@ class node_allocator typedef std::ptrdiff_t difference_type; typedef boost::container::dtl:: - version_type version; + version_type version; #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED typedef boost::container::dtl:: diff --git a/test/map_test.hpp b/test/map_test.hpp index 4353ee6..1922526 100644 --- a/test/map_test.hpp +++ b/test/map_test.hpp @@ -184,19 +184,19 @@ int map_test_range() //Test construction from a range { - IntPairType aux_vect[MaxElem]; + IntPairType aux_vect[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(i/2); IntType i2(i/2); new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2)); } - StdValueType aux_vect2[MaxElem]; + StdValueType aux_vect2[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ new(&aux_vect2[i])StdValueType(StdKeyType(i/2), StdMappedType(i/2)); } - IntPairType aux_vect3[MaxElem]; + IntPairType aux_vect3[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(i/2); IntType i2(i/2); @@ -218,19 +218,19 @@ int map_test_range() if(!CheckEqualContainers(*pboostmultimap, *pstdmultimap)) return 1; } { - IntPairType aux_vect[MaxElem]; + IntPairType aux_vect[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(i/2); IntType i2(i/2); new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2)); } - StdValueType aux_vect2[MaxElem]; + StdValueType aux_vect2[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ new(&aux_vect2[i])StdValueType(StdKeyType(i/2), StdMappedType(i/2)); } - IntPairType aux_vect3[MaxElem]; + IntPairType aux_vect3[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(i/2); IntType i2(i/2); @@ -266,7 +266,7 @@ int map_test_step(MyBoostMap &, MyStdMap &, MyBoostMultiMap &, MyStdMultiMap &) { //This is really nasty, but we have no other simple choice - IntPairType aux_vect[MaxElem]; + IntPairType aux_vect[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(i/2); IntType i2(i/2); @@ -276,12 +276,12 @@ int map_test_step(MyBoostMap &, MyStdMap &, MyBoostMultiMap &, MyStdMultiMap &) typedef typename MyStdMap::value_type StdValueType; typedef typename MyStdMap::key_type StdKeyType; typedef typename MyStdMap::mapped_type StdMappedType; - StdValueType aux_vect2[MaxElem]; + StdValueType aux_vect2[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ new(&aux_vect2[i])StdValueType(StdKeyType(i/2), StdMappedType(i/2)); } - IntPairType aux_vect3[MaxElem]; + IntPairType aux_vect3[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(i/2); IntType i2(i/2); @@ -400,13 +400,13 @@ int map_test_insert(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &boo { //This is really nasty, but we have no other simple choice - IntPairType aux_vect[MaxElem]; + IntPairType aux_vect[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(i); IntType i2(i); new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2)); } - IntPairType aux_vect3[MaxElem]; + IntPairType aux_vect3[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(i); IntType i2(i); @@ -501,13 +501,13 @@ int map_test_erase(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &boos //Initialize values { //This is really nasty, but we have no other simple choice - IntPairType aux_vect[MaxElem]; + IntPairType aux_vect[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(-1); IntType i2(-1); new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2)); } - IntPairType aux_vect3[MaxElem]; + IntPairType aux_vect3[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(-1); IntType i2(-1); @@ -535,28 +535,28 @@ int map_test_erase(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &boos if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1; } { - IntPairType aux_vect[MaxElem]; + IntPairType aux_vect[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(-1); IntType i2(-1); new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2)); } - IntPairType aux_vect3[MaxElem]; + IntPairType aux_vect3[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(-1); IntType i2(-1); new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2)); } - IntPairType aux_vect4[MaxElem]; + IntPairType aux_vect4[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(-1); IntType i2(-1); new(&aux_vect4[i])IntPairType(boost::move(i1), boost::move(i2)); } - IntPairType aux_vect5[MaxElem]; + IntPairType aux_vect5[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(-1); IntType i2(-1); @@ -599,13 +599,13 @@ int map_test_insert2(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &bo typedef typename MyStdMap::value_type StdPairType; //This is really nasty, but we have no other simple choice - IntPairType aux_vect[MaxElem]; + IntPairType aux_vect[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(i); IntType i2(i); new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2)); } - IntPairType aux_vect3[MaxElem]; + IntPairType aux_vect3[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(i); IntType i2(i); @@ -813,7 +813,7 @@ int map_test_indexing(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &b stdmap.clear(); stdmultimap.clear(); - IntPairType aux_vect[MaxElem]; + IntPairType aux_vect[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(i); IntType i2(i); @@ -844,14 +844,14 @@ int map_test_insert_or_assign_impl() { //insert_or_assign test MyBoostMap boostmap; StdMap stdmap; - IntPairType aux_vect[MaxElem]; + IntPairType aux_vect[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(i); IntType i2(MaxElem-i); new(&aux_vect[i])IntPairType(maybe_move(i1), maybe_move(i2)); } - IntPairType aux_vect2[MaxElem]; + IntPairType aux_vect2[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(i); IntType i2(i); @@ -891,14 +891,14 @@ int map_test_insert_or_assign_impl() { //insert_or_assign test with hint MyBoostMap boostmap; StdMap stdmap; - IntPairType aux_vect[MaxElem]; + IntPairType aux_vect[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(i); IntType i2(MaxElem-i); new(&aux_vect[i])IntPairType(maybe_move(i1), maybe_move(i2)); } - IntPairType aux_vect2[MaxElem]; + IntPairType aux_vect2[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(i); IntType i2(i); @@ -964,14 +964,14 @@ int map_test_try_emplace(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap stdmap.clear(); stdmultimap.clear(); - IntPairType aux_vect[MaxElem]; + IntPairType aux_vect[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(i); IntType i2(i); new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2)); } - IntPairType aux_vect2[MaxElem]; + IntPairType aux_vect2[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(i); IntType i2(MaxElem-i); @@ -1055,20 +1055,20 @@ int map_test_merge(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &boos stdmultimap.clear(); { - IntPairType aux_vect[MaxElem]; + IntPairType aux_vect[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(i); IntType i2(i); new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2)); } - IntPairType aux_vect2[MaxElem]; + IntPairType aux_vect2[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(MaxElem/2+i); IntType i2(MaxElem-i); new(&aux_vect2[i])IntPairType(boost::move(i1), boost::move(i2)); } - IntPairType aux_vect3[MaxElem]; + IntPairType aux_vect3[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(MaxElem*2/2+i); IntType i2(MaxElem*2+i); @@ -1102,20 +1102,20 @@ int map_test_merge(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &boos stdmap.clear(); stdmultimap.clear(); { - IntPairType aux_vect[MaxElem]; + IntPairType aux_vect[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(i); IntType i2(i); new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2)); } - IntPairType aux_vect2[MaxElem]; + IntPairType aux_vect2[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(MaxElem/2+i); IntType i2(MaxElem-i); new(&aux_vect2[i])IntPairType(boost::move(i1), boost::move(i2)); } - IntPairType aux_vect3[MaxElem]; + IntPairType aux_vect3[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ IntType i1(MaxElem*2/2+i); IntType i2(MaxElem*2+i); diff --git a/test/set_test.hpp b/test/set_test.hpp index 22cf4f0..1834e1d 100644 --- a/test/set_test.hpp +++ b/test/set_test.hpp @@ -764,16 +764,16 @@ int set_test () stdmultiset.clear(); { - IntType aux_vect[MaxElem]; + IntType aux_vect[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ aux_vect[i] = i; } - IntType aux_vect2[MaxElem]; + IntType aux_vect2[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ aux_vect2[i] = MaxElem/2+i; } - IntType aux_vect3[MaxElem]; + IntType aux_vect3[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ aux_vect3[i] = MaxElem*2/2+i; } @@ -805,16 +805,16 @@ int set_test () stdset.clear(); stdmultiset.clear(); { - IntType aux_vect[MaxElem]; + IntType aux_vect[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ aux_vect[i] = i; } - IntType aux_vect2[MaxElem]; + IntType aux_vect2[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ aux_vect2[i] = MaxElem/2+i; } - IntType aux_vect3[MaxElem]; + IntType aux_vect3[(std::size_t)MaxElem]; for(int i = 0; i < MaxElem; ++i){ aux_vect3[i] = MaxElem*2/2+i; } diff --git a/test/string_test.cpp b/test/string_test.cpp index 7bc6954..6fbd8f1 100644 --- a/test/string_test.cpp +++ b/test/string_test.cpp @@ -124,14 +124,14 @@ struct string_literals { return L"LongLongLongLongLongLongLongLongLongLongLongLongLongString"; } static wchar_t Char() { return L'C'; } - static void sprintf_number(wchar_t *buffer, unsigned int number) + static void sprintf_number(wchar_t *buffer, unsigned long number) { //For compilers without wsprintf, print it backwards const wchar_t *digits = L"0123456789"; wchar_t *buf = buffer; while(1){ - unsigned rem = number % 10; + unsigned long rem = number % 10; number = number / 10; *buf = digits[rem];