mirror of
https://github.com/boostorg/container.git
synced 2026-02-25 04:12:27 +00:00
Support GCC's -Wconversion -Wfloat-conversion -Warith-conversion -Wsign-conversion warnings.
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
|
||||
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 };
|
||||
|
||||
@@ -39,7 +39,7 @@ bool test_allocation()
|
||||
std::vector<void*> buffers;
|
||||
//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);
|
||||
if(!ptr)
|
||||
break;
|
||||
@@ -49,7 +49,7 @@ bool test_allocation()
|
||||
switch(t){
|
||||
case DirectDeallocation:
|
||||
{
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
for(std::size_t j = 0, max = buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
dlmalloc_free(buffers[j]);
|
||||
@@ -58,7 +58,7 @@ bool test_allocation()
|
||||
break;
|
||||
case InverseDeallocation:
|
||||
{
|
||||
for(int j = (int)buffers.size()
|
||||
for(std::size_t j = buffers.size()
|
||||
;j--
|
||||
;){
|
||||
dlmalloc_free(buffers[j]);
|
||||
@@ -67,12 +67,12 @@ bool test_allocation()
|
||||
break;
|
||||
case MixedDeallocation:
|
||||
{
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
for(std::size_t j = 0, max = buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
std::size_t pos = (j%4)*(buffers.size())/4;
|
||||
dlmalloc_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -99,15 +99,15 @@ bool test_allocation_shrink()
|
||||
std::vector<void*> buffers;
|
||||
|
||||
//Allocate buffers with extra memory
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
void *ptr = dlmalloc_malloc(i*2);
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
void *ptr = dlmalloc_malloc(i*2u);
|
||||
if(!ptr)
|
||||
break;
|
||||
buffers.push_back(ptr);
|
||||
}
|
||||
|
||||
//Now shrink to half
|
||||
for(int i = 0, max = (int)buffers.size()
|
||||
for(std::size_t i = 0, max = buffers.size()
|
||||
;i < max
|
||||
; ++i){
|
||||
std::size_t try_received_size = 0;
|
||||
@@ -137,12 +137,12 @@ bool test_allocation_shrink()
|
||||
}
|
||||
|
||||
//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){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
std::size_t pos = (j%4u)*(buffers.size())/4u;
|
||||
dlmalloc_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
|
||||
}
|
||||
dlmalloc_malloc_check();
|
||||
return 0 != dlmalloc_all_deallocated();//a.all_memory_deallocated() && a.check_sanity();
|
||||
@@ -158,7 +158,7 @@ bool test_allocation_expand()
|
||||
std::vector<void*> buffers;
|
||||
|
||||
//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);
|
||||
if(!ptr)
|
||||
break;
|
||||
@@ -166,7 +166,7 @@ bool test_allocation_expand()
|
||||
}
|
||||
|
||||
//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){
|
||||
std::size_t received_size = 0;
|
||||
@@ -187,12 +187,12 @@ bool test_allocation_expand()
|
||||
}
|
||||
|
||||
//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){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
std::size_t pos = (j%4u)*(buffers.size())/4u;
|
||||
dlmalloc_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
|
||||
}
|
||||
dlmalloc_malloc_check();
|
||||
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;
|
||||
|
||||
//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;
|
||||
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){
|
||||
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)
|
||||
break;
|
||||
}
|
||||
@@ -223,7 +223,7 @@ bool test_allocation_shrink_and_expand()
|
||||
}
|
||||
|
||||
//Now shrink to half
|
||||
for(int i = 0, max = (int)buffers.size()
|
||||
for(std::size_t i = 0, max = buffers.size()
|
||||
; i < max
|
||||
; ++i){
|
||||
std::size_t received_size = 0;
|
||||
@@ -243,7 +243,7 @@ bool test_allocation_shrink_and_expand()
|
||||
}
|
||||
|
||||
//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){
|
||||
if(!size_reduced[i]) continue;
|
||||
@@ -262,12 +262,12 @@ bool test_allocation_shrink_and_expand()
|
||||
}
|
||||
|
||||
//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){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
std::size_t pos = (j%4u)*(buffers.size())/4u;
|
||||
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();
|
||||
@@ -284,7 +284,7 @@ bool test_allocation_deallocation_expand()
|
||||
std::vector<void*> buffers;
|
||||
|
||||
//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);
|
||||
if(!ptr)
|
||||
break;
|
||||
@@ -293,7 +293,7 @@ bool test_allocation_deallocation_expand()
|
||||
|
||||
//Now deallocate the half of the 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){
|
||||
if(i%2){
|
||||
@@ -303,7 +303,7 @@ bool test_allocation_deallocation_expand()
|
||||
}
|
||||
|
||||
//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){
|
||||
//
|
||||
@@ -332,12 +332,12 @@ bool test_allocation_deallocation_expand()
|
||||
,buffers.end());
|
||||
|
||||
//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){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
std::size_t pos = (j%4u)*(buffers.size())/4u;
|
||||
dlmalloc_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
|
||||
}
|
||||
dlmalloc_malloc_check();
|
||||
return 0 != dlmalloc_all_deallocated();//a.all_memory_deallocated() && a.check_sanity();
|
||||
@@ -354,11 +354,11 @@ bool test_allocation_with_reuse()
|
||||
{
|
||||
dlmalloc_malloc_check();
|
||||
//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;
|
||||
|
||||
//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);
|
||||
if(!ptr)
|
||||
break;
|
||||
@@ -367,7 +367,7 @@ bool test_allocation_with_reuse()
|
||||
|
||||
//Now deallocate all except the latest
|
||||
//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){
|
||||
dlmalloc_free(buffers[i]);
|
||||
@@ -379,9 +379,9 @@ bool test_allocation_with_reuse()
|
||||
|
||||
//Now allocate with reuse
|
||||
std::size_t received_size = 0;
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
std::size_t min_size = (received_size/sizeof_object + 1)*sizeof_object;
|
||||
std::size_t prf_size = (received_size/sizeof_object + (i+1)*2)*sizeof_object;
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
std::size_t min_size = (received_size/sizeof_object + 1u)*sizeof_object;
|
||||
std::size_t prf_size = (received_size/sizeof_object + (i+1u)*2u)*sizeof_object;
|
||||
dlmalloc_command_ret_t ret = dlmalloc_allocation_command
|
||||
( BOOST_CONTAINER_EXPAND_BWD, sizeof_object, min_size
|
||||
, prf_size, &received_size, (char*)ptr);
|
||||
@@ -413,8 +413,8 @@ bool test_aligned_allocation()
|
||||
dlmalloc_malloc_check();
|
||||
//Allocate aligned buffers in a loop
|
||||
//and then deallocate it
|
||||
for(unsigned int i = 1; i != (1 << (sizeof(int)/2)); i <<= 1){
|
||||
for(unsigned int j = 1; j != 512; j <<= 1){
|
||||
for(std::size_t i = 1u; i != (1u << (sizeof(int)/2u)); i <<= 1u){
|
||||
for(std::size_t j = 1u; j != 512u; j <<= 1){
|
||||
void *ptr = dlmalloc_memalign(i-1, j);
|
||||
if(!ptr){
|
||||
return false;
|
||||
@@ -442,11 +442,11 @@ bool test_continuous_aligned_allocation()
|
||||
//Allocate aligned buffers in a loop
|
||||
//and then deallocate it
|
||||
bool continue_loop = true;
|
||||
unsigned int MaxAlign = 4096;
|
||||
unsigned int MaxSize = 4096;
|
||||
for(unsigned i = 1; i < MaxSize; i <<= 1){
|
||||
for(unsigned int j = 1; j < MaxAlign; j <<= 1){
|
||||
for(int k = 0; k != NumIt; ++k){
|
||||
std::size_t MaxAlign = 4096;
|
||||
std::size_t MaxSize = 4096;
|
||||
for(std::size_t i = 1; i < MaxSize; i <<= 1){
|
||||
for(std::size_t j = 1; j < MaxAlign; j <<= 1){
|
||||
for(std::size_t k = 0; k != NumIt; ++k){
|
||||
void *ptr = dlmalloc_memalign(i-1, j);
|
||||
buffers.push_back(ptr);
|
||||
if(!ptr){
|
||||
@@ -458,7 +458,7 @@ bool test_continuous_aligned_allocation()
|
||||
return false;
|
||||
}
|
||||
//Deallocate all
|
||||
for(int k = (int)buffers.size(); k--;){
|
||||
for(std::size_t k = buffers.size(); k--;){
|
||||
dlmalloc_free(buffers[k]);
|
||||
}
|
||||
buffers.clear();
|
||||
@@ -485,7 +485,7 @@ bool test_many_equal_allocation()
|
||||
std::vector<void*> buffers2;
|
||||
|
||||
//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);
|
||||
if(!ptr)
|
||||
break;
|
||||
@@ -496,7 +496,7 @@ bool test_many_equal_allocation()
|
||||
|
||||
//Now deallocate the half of the 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){
|
||||
if(i%2){
|
||||
@@ -509,7 +509,7 @@ bool test_many_equal_allocation()
|
||||
//return false;
|
||||
|
||||
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;
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT(&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){
|
||||
case DirectDeallocation:
|
||||
{
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
for(std::size_t j = 0, max = buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
dlmalloc_free(buffers[j]);
|
||||
@@ -541,7 +541,7 @@ bool test_many_equal_allocation()
|
||||
break;
|
||||
case InverseDeallocation:
|
||||
{
|
||||
for(int j = (int)buffers.size()
|
||||
for(std::size_t j = buffers.size()
|
||||
;j--
|
||||
;){
|
||||
dlmalloc_free(buffers[j]);
|
||||
@@ -550,12 +550,12 @@ bool test_many_equal_allocation()
|
||||
break;
|
||||
case MixedDeallocation:
|
||||
{
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
for(std::size_t j = 0, max = buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
std::size_t pos = (j%4u)*(buffers.size())/4u;
|
||||
dlmalloc_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -566,12 +566,12 @@ bool test_many_equal_allocation()
|
||||
//Deallocate the rest of the blocks
|
||||
|
||||
//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){
|
||||
int pos = (j%4)*((int)buffers2.size())/4;
|
||||
std::size_t pos = (j%4u)*(buffers2.size())/4u;
|
||||
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() &&
|
||||
@@ -602,7 +602,7 @@ bool test_many_different_allocation()
|
||||
std::vector<void*> buffers2;
|
||||
|
||||
//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);
|
||||
if(!ptr)
|
||||
break;
|
||||
@@ -611,7 +611,7 @@ bool test_many_different_allocation()
|
||||
|
||||
//Now deallocate the half of the 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){
|
||||
if(i%2){
|
||||
@@ -621,7 +621,7 @@ bool test_many_different_allocation()
|
||||
}
|
||||
|
||||
std::vector<void*> buffers;
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
dlmalloc_memchain chain;
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT(&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){
|
||||
case DirectDeallocation:
|
||||
{
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
for(std::size_t j = 0, max = buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
dlmalloc_free(buffers[j]);
|
||||
@@ -649,7 +649,7 @@ bool test_many_different_allocation()
|
||||
break;
|
||||
case InverseDeallocation:
|
||||
{
|
||||
for(int j = (int)buffers.size()
|
||||
for(std::size_t j = buffers.size()
|
||||
;j--
|
||||
;){
|
||||
dlmalloc_free(buffers[j]);
|
||||
@@ -658,12 +658,12 @@ bool test_many_different_allocation()
|
||||
break;
|
||||
case MixedDeallocation:
|
||||
{
|
||||
for(int j = 0, max = (int)buffers.size()
|
||||
for(std::size_t j = 0, max = buffers.size()
|
||||
;j < max
|
||||
;++j){
|
||||
int pos = (j%4)*((int)buffers.size())/4;
|
||||
std::size_t pos = (j%4)*(buffers.size())/4;
|
||||
dlmalloc_free(buffers[pos]);
|
||||
buffers.erase(buffers.begin()+pos);
|
||||
buffers.erase(buffers.begin()+(std::ptrdiff_t)pos);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -674,12 +674,12 @@ bool test_many_different_allocation()
|
||||
//Deallocate the rest of the blocks
|
||||
|
||||
//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){
|
||||
int pos = (j%4)*((int)buffers2.size())/4;
|
||||
std::size_t pos = (j%4u)*(buffers2.size())/4u;
|
||||
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() &&
|
||||
@@ -699,7 +699,7 @@ bool test_many_deallocation()
|
||||
requested_sizes[i] = 4*i;
|
||||
}
|
||||
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
dlmalloc_memchain chain;
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT(&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;
|
||||
buffers.push_back(chain);
|
||||
}
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
dlmalloc_multidealloc(&buffers[i]);
|
||||
}
|
||||
buffers.clear();
|
||||
@@ -717,7 +717,7 @@ bool test_many_deallocation()
|
||||
if(!dlmalloc_all_deallocated())
|
||||
return false;
|
||||
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
dlmalloc_memchain chain;
|
||||
BOOST_CONTAINER_MEMCHAIN_INIT(&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;
|
||||
buffers.push_back(chain);
|
||||
}
|
||||
for(int i = 0; i != NumIt; ++i){
|
||||
for(std::size_t i = 0; i != NumIt; ++i){
|
||||
dlmalloc_multidealloc(&buffers[i]);
|
||||
}
|
||||
buffers.clear();
|
||||
|
||||
@@ -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 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()){
|
||||
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()){
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ bool test_nth_index_of(Container &c)
|
||||
typename Container::iterator it;
|
||||
typename Container::const_iterator cit;
|
||||
typename Container::size_type sz, csz;
|
||||
typedef typename Container::difference_type difference_type;
|
||||
|
||||
//index 0
|
||||
it = c.nth(0);
|
||||
sz = c.index_of(it);
|
||||
@@ -51,9 +53,9 @@ bool test_nth_index_of(Container &c)
|
||||
cit = (as_const)(c).nth(sz_div_2);
|
||||
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;
|
||||
if(cit != (c.cbegin()+sz_div_2))
|
||||
if(cit != (c.cbegin()+difference_type(sz_div_2)))
|
||||
return false;
|
||||
if(sz != sz_div_2)
|
||||
return false;
|
||||
|
||||
@@ -46,13 +46,13 @@ bool deque_copyable_only(V1 &cntdeque, V2 &stddeque, dtl::true_type)
|
||||
{
|
||||
typedef typename V1::value_type IntType;
|
||||
std::size_t size = cntdeque.size();
|
||||
stddeque.insert(stddeque.end(), 50, 1);
|
||||
cntdeque.insert(cntdeque.end(), 50, IntType(1));
|
||||
stddeque.insert(stddeque.end(), 50u, 1);
|
||||
cntdeque.insert(cntdeque.end(), 50u, IntType(1));
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
{
|
||||
IntType move_me(1);
|
||||
stddeque.insert(stddeque.begin()+size/2, 50, 1);
|
||||
cntdeque.insert(cntdeque.begin()+size/2, 50, boost::move(move_me));
|
||||
stddeque.insert(stddeque.begin()+std::ptrdiff_t(size)/2, 50u, 1);
|
||||
cntdeque.insert(cntdeque.begin()+std::ptrdiff_t(size/2), 50u, boost::move(move_me));
|
||||
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);
|
||||
stddeque.clear();
|
||||
cntdeque.clear();
|
||||
stddeque.insert(stddeque.begin(), 50, 1);
|
||||
cntdeque.insert(cntdeque.begin(), 50, boost::move(move_me));
|
||||
stddeque.insert(stddeque.begin(), 50u, 1);
|
||||
cntdeque.insert(cntdeque.begin(), 50u, boost::move(move_me));
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
stddeque.insert(stddeque.begin()+20, 50, 1);
|
||||
cntdeque.insert(cntdeque.begin()+20, 50, boost::move(move_me));
|
||||
stddeque.insert(stddeque.begin()+20, 50u, 1);
|
||||
cntdeque.insert(cntdeque.begin()+20, 50u, boost::move(move_me));
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
stddeque.insert(stddeque.begin()+20, 20, 1);
|
||||
cntdeque.insert(cntdeque.begin()+20, 20, boost::move(move_me));
|
||||
stddeque.insert(stddeque.begin()+20, 20u, 1);
|
||||
cntdeque.insert(cntdeque.begin()+20, 20u, boost::move(move_me));
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
}
|
||||
{
|
||||
IntType move_me(1);
|
||||
stddeque.clear();
|
||||
cntdeque.clear();
|
||||
stddeque.insert(stddeque.end(), 50, 1);
|
||||
cntdeque.insert(cntdeque.end(), 50, boost::move(move_me));
|
||||
stddeque.insert(stddeque.end(), 50u, 1);
|
||||
cntdeque.insert(cntdeque.end(), 50u, boost::move(move_me));
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
stddeque.insert(stddeque.end()-20, 50, 1);
|
||||
cntdeque.insert(cntdeque.end()-20, 50, boost::move(move_me));
|
||||
stddeque.insert(stddeque.end()-20, 50u, 1);
|
||||
cntdeque.insert(cntdeque.end()-20, 50u, boost::move(move_me));
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
stddeque.insert(stddeque.end()-20, 20, 1);
|
||||
cntdeque.insert(cntdeque.end()-20, 20, boost::move(move_me));
|
||||
stddeque.insert(stddeque.end()-20, 20u, 1);
|
||||
cntdeque.insert(cntdeque.end()-20, 20u, boost::move(move_me));
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
||||
}
|
||||
|
||||
@@ -204,10 +204,10 @@ bool do_test()
|
||||
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 + 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;
|
||||
|
||||
for(int i = 0, j = static_cast<int>(cntdeque.size()); i < j; ++i){
|
||||
|
||||
@@ -1722,7 +1722,7 @@ template <class Devector> void test_reserve_front()
|
||||
Devector a;
|
||||
|
||||
a.reserve_front(100);
|
||||
for (unsigned i = 0; i < 100u; ++i)
|
||||
for (int i = 0; i < 100; ++i)
|
||||
{
|
||||
a.push_front(value_type(i));
|
||||
}
|
||||
@@ -1742,7 +1742,7 @@ template <class Devector> void test_reserve_back()
|
||||
Devector a;
|
||||
typedef typename Devector::value_type value_type;
|
||||
a.reserve_back(100);
|
||||
for (unsigned i = 0; i < 100; ++i)
|
||||
for (int i = 0; i < 100; ++i)
|
||||
{
|
||||
a.push_back(value_type(i));
|
||||
}
|
||||
@@ -1760,19 +1760,20 @@ template <class Devector> void test_reserve_back()
|
||||
template <typename Devector>
|
||||
void test_shrink_to_fit_always()
|
||||
{
|
||||
typedef typename Devector::value_type value_type;
|
||||
Devector a;
|
||||
a.reserve(100);
|
||||
a.reserve(100u);
|
||||
|
||||
a.push_back(1);
|
||||
a.push_back(2);
|
||||
a.push_back(3);
|
||||
a.push_back(value_type(1));
|
||||
a.push_back(value_type(2));
|
||||
a.push_back(value_type(3));
|
||||
|
||||
a.shrink_to_fit();
|
||||
|
||||
boost::container::vector<unsigned> expected;
|
||||
expected.push_back(1);
|
||||
expected.push_back(2);
|
||||
expected.push_back(3);
|
||||
expected.push_back(1u);
|
||||
expected.push_back(2u);
|
||||
expected.push_back(3u);
|
||||
test_equal_range(a, expected);
|
||||
|
||||
std::size_t exp_capacity = 3u;
|
||||
|
||||
@@ -79,7 +79,7 @@ class expand_bwd_test_allocator
|
||||
{ typedef expand_bwd_test_allocator<T2> other; };
|
||||
|
||||
//!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)
|
||||
, m_offset(offset), m_allocations(0){ }
|
||||
|
||||
@@ -171,7 +171,7 @@ class expand_bwd_test_allocator
|
||||
|
||||
pointer mp_buffer;
|
||||
size_type m_size;
|
||||
difference_type m_offset;
|
||||
size_type m_offset;
|
||||
char m_allocations;
|
||||
};
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ bool test_insert_with_expand_bwd()
|
||||
std::vector<value_type> initial_data;
|
||||
initial_data.resize(InitialSize[iteration]);
|
||||
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]))
|
||||
@@ -97,7 +97,7 @@ bool test_insert_with_expand_bwd()
|
||||
Vect data_to_insert;
|
||||
data_to_insert.resize(InsertSize[iteration]);
|
||||
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]))
|
||||
@@ -153,14 +153,14 @@ bool test_assign_with_expand_bwd()
|
||||
std::vector<value_type> initial_data;
|
||||
initial_data.resize(InitialSize[iteration]);
|
||||
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
|
||||
std::vector<value_type> data_to_insert;
|
||||
data_to_insert.resize(InsertSize[iteration]);
|
||||
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
|
||||
|
||||
@@ -26,13 +26,13 @@ void
|
||||
BOOST_TEST(CheckEqualContainers(std_deque, seq_container));
|
||||
|
||||
std_deque.insert(
|
||||
std_deque.begin() + index
|
||||
std_deque.begin() + std::ptrdiff_t(index)
|
||||
, input_deque.begin()
|
||||
, input_deque.end()
|
||||
);
|
||||
|
||||
seq_container.insert(
|
||||
seq_container.begin() + index
|
||||
seq_container.begin() + std::ptrdiff_t(index)
|
||||
, input_deque.begin()
|
||||
, input_deque.end()
|
||||
);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <list>
|
||||
#include <functional> //std::greater
|
||||
#include <cstddef> //std::size_t
|
||||
|
||||
namespace boost{
|
||||
namespace container {
|
||||
@@ -38,14 +39,14 @@ template<class V1, class V2>
|
||||
bool list_copyable_only(V1 &boostlist, V2 &stdlist, boost::container::dtl::true_type)
|
||||
{
|
||||
typedef typename V1::value_type IntType;
|
||||
boostlist.insert(boostlist.end(), 50, IntType(1));
|
||||
stdlist.insert(stdlist.end(), 50, 1);
|
||||
boostlist.insert(boostlist.end(), 50u, IntType(1));
|
||||
stdlist.insert(stdlist.end(), 50u, 1);
|
||||
if(!test::CheckEqualContainers(boostlist, stdlist)) return false;
|
||||
|
||||
{
|
||||
IntType move_me(1);
|
||||
boostlist.insert(boostlist.begin(), 50, boost::move(move_me));
|
||||
stdlist.insert(stdlist.begin(), 50, 1);
|
||||
boostlist.insert(boostlist.begin(), 50u, boost::move(move_me));
|
||||
stdlist.insert(stdlist.begin(), 50u, 1);
|
||||
if(!test::CheckEqualContainers(boostlist, stdlist)) return false;
|
||||
}
|
||||
{
|
||||
@@ -104,14 +105,14 @@ template<bool DoublyLinked>
|
||||
struct list_push_data_function
|
||||
{
|
||||
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;
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType move_me(i);
|
||||
for(std::size_t i = 0; i < max; ++i){
|
||||
IntType move_me((int)i);
|
||||
boostlist.push_back(boost::move(move_me));
|
||||
stdlist.push_back(i);
|
||||
boostlist.push_front(IntType(i));
|
||||
stdlist.push_back((int)i);
|
||||
boostlist.push_front(IntType(int(i)));
|
||||
stdlist.push_front(int(i));
|
||||
}
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
@@ -124,14 +125,14 @@ template<>
|
||||
struct list_push_data_function<false>
|
||||
{
|
||||
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;
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType move_me(i);
|
||||
for(std::size_t i = 0; i < max; ++i){
|
||||
IntType move_me((int)i);
|
||||
boostlist.push_front(boost::move(move_me));
|
||||
stdlist.push_front(i);
|
||||
boostlist.push_front(IntType(i));
|
||||
stdlist.push_front((int)i);
|
||||
boostlist.push_front(IntType(int(i)));
|
||||
stdlist.push_front(int(i));
|
||||
}
|
||||
if(!CheckEqualContainers(boostlist, stdlist))
|
||||
@@ -171,35 +172,35 @@ int list_test (bool copied_allocators_equal = true)
|
||||
{
|
||||
typedef std::list<int> MyStdList;
|
||||
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;
|
||||
|
||||
{ //List(n)
|
||||
::boost::movelib::unique_ptr<MyBoostList> const pboostlist = ::boost::movelib::make_unique<MyBoostList>(100);
|
||||
::boost::movelib::unique_ptr<MyStdList> const pstdlist = ::boost::movelib::make_unique<MyStdList>(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>(100u);
|
||||
if(!test::CheckEqualContainers(*pboostlist, *pstdlist)) return 1;
|
||||
}
|
||||
{ //List(n, alloc)
|
||||
::boost::movelib::unique_ptr<MyBoostList> const pboostlist = ::boost::movelib::make_unique<MyBoostList>(100, typename MyBoostList::allocator_type());
|
||||
::boost::movelib::unique_ptr<MyStdList> const pstdlist = ::boost::movelib::make_unique<MyStdList>(100);
|
||||
::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>(100u);
|
||||
if(!test::CheckEqualContainers(*pboostlist, *pstdlist)) return 1;
|
||||
}
|
||||
{ //List(List &&)
|
||||
::boost::movelib::unique_ptr<MyStdList> const stdlistp = ::boost::movelib::make_unique<MyStdList>(100);
|
||||
::boost::movelib::unique_ptr<MyBoostList> const boostlistp = ::boost::movelib::make_unique<MyBoostList>(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>(100u);
|
||||
::boost::movelib::unique_ptr<MyBoostList> const boostlistp2 = ::boost::movelib::make_unique<MyBoostList>(::boost::move(*boostlistp));
|
||||
if(!test::CheckEqualContainers(*boostlistp2, *stdlistp)) return 1;
|
||||
}
|
||||
{ //List(List &&, alloc)
|
||||
::boost::movelib::unique_ptr<MyStdList> const stdlistp = ::boost::movelib::make_unique<MyStdList>(100);
|
||||
::boost::movelib::unique_ptr<MyBoostList> const boostlistp = ::boost::movelib::make_unique<MyBoostList>(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>(100u);
|
||||
::boost::movelib::unique_ptr<MyBoostList> const boostlistp2 = ::boost::movelib::make_unique<MyBoostList>
|
||||
(::boost::move(*boostlistp), typename MyBoostList::allocator_type());
|
||||
if(!test::CheckEqualContainers(*boostlistp2, *stdlistp)) return 1;
|
||||
}
|
||||
{ //List operator=(List &&)
|
||||
::boost::movelib::unique_ptr<MyStdList> const stdlistp = ::boost::movelib::make_unique<MyStdList>(100);
|
||||
::boost::movelib::unique_ptr<MyBoostList> const boostlistp = ::boost::movelib::make_unique<MyBoostList>(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>(100u);
|
||||
::boost::movelib::unique_ptr<MyBoostList> const boostlistp2 = ::boost::movelib::make_unique<MyBoostList>();
|
||||
*boostlistp2 = ::boost::move(*boostlistp);
|
||||
if(!test::CheckEqualContainers(*boostlistp2, *stdlistp)) return 1;
|
||||
@@ -324,10 +325,10 @@ int list_test (bool copied_allocators_equal = true)
|
||||
return 1;
|
||||
}
|
||||
|
||||
for(int i = 0; i < max; ++i){
|
||||
IntType new_int(i);
|
||||
for(std::size_t i = 0; i < max; ++i){
|
||||
IntType new_int((int)i);
|
||||
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;
|
||||
@@ -362,7 +363,7 @@ int list_test (bool copied_allocators_equal = true)
|
||||
MyBoostList otherboostlist(boostlist.get_allocator());
|
||||
MyStdList otherstdlist;
|
||||
|
||||
int listsize = (int)boostlist.size();
|
||||
std::size_t listsize = boostlist.size();
|
||||
|
||||
if(push_data_t::execute(listsize, boostlist, stdlist)){
|
||||
return 1;
|
||||
@@ -375,7 +376,7 @@ int list_test (bool copied_allocators_equal = true)
|
||||
return 1;
|
||||
}
|
||||
|
||||
listsize = (int)boostlist.size();
|
||||
listsize = boostlist.size();
|
||||
|
||||
if(push_data_t::execute(listsize, boostlist, stdlist)){
|
||||
return 1;
|
||||
|
||||
@@ -108,17 +108,19 @@ int map_test_copyable(boost::container::dtl::true_type)
|
||||
boostmap.clear();
|
||||
boostmultimap.clear();
|
||||
stdmultimap.clear();
|
||||
|
||||
//Now try from convertible pair
|
||||
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));
|
||||
}
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
if(!CheckEqualContainers(boostmap, stdmap)) 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 =
|
||||
stdmultimap.equal_range(stdmultimap.begin()->first);
|
||||
|
||||
if( boost::container::iterator_distance(bret.first, bret.second) !=
|
||||
boost::container::iterator_distance(sret.first, sret.second) ){
|
||||
if( boost::container::iterator_udistance(bret.first, bret.second) !=
|
||||
boost::container::iterator_udistance(sret.first, sret.second) ){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ void test_pop_back_nd()
|
||||
template <typename It1, typename It2>
|
||||
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 )
|
||||
BOOST_TEST(*first1 == *first2);
|
||||
}
|
||||
@@ -290,6 +290,7 @@ void test_erase_nd()
|
||||
{
|
||||
static_vector<T, N> s;
|
||||
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 )
|
||||
s.push_back(T((int)i));
|
||||
@@ -299,8 +300,8 @@ void test_erase_nd()
|
||||
for ( size_t i = 0 ; i < N ; ++i )
|
||||
{
|
||||
static_vector<T, N> s1(s);
|
||||
It it = s1.erase(s1.begin() + i);
|
||||
BOOST_TEST(s1.begin() + i == it);
|
||||
It it = s1.erase(s1.begin() + dif_t(i));
|
||||
BOOST_TEST(s1.begin() + dif_t(i) == it);
|
||||
BOOST_TEST(s1.size() == N - 1);
|
||||
for ( size_t j = 0 ; j < i ; ++j )
|
||||
BOOST_TEST(s1[j] == T((int)j));
|
||||
@@ -315,8 +316,8 @@ void test_erase_nd()
|
||||
{
|
||||
static_vector<T, N> s1(s);
|
||||
size_t removed = i + n < N ? n : N - i;
|
||||
It it = s1.erase(s1.begin() + i, s1.begin() + i + removed);
|
||||
BOOST_TEST(s1.begin() + i == it);
|
||||
It it = s1.erase(s1.begin() + dif_t(i), s1.begin() + dif_t(i + removed));
|
||||
BOOST_TEST(s1.begin() + dif_t(i) == it);
|
||||
BOOST_TEST(s1.size() == N - removed);
|
||||
for ( size_t j = 0 ; j < i ; ++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)
|
||||
{
|
||||
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 )
|
||||
{
|
||||
static_vector<T, N> s1(s);
|
||||
|
||||
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
|
||||
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);
|
||||
for ( size_t j = 0 ; j < i ; ++j )
|
||||
BOOST_TEST(s1[j] == T((int)j));
|
||||
@@ -362,6 +364,7 @@ void test_insert_nd(T const& val)
|
||||
list<T> l;
|
||||
|
||||
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 )
|
||||
{
|
||||
@@ -376,8 +379,8 @@ void test_insert_nd(T const& val)
|
||||
for ( size_t i = 0 ; i <= h ; ++i )
|
||||
{
|
||||
static_vector<T, N> s1(s);
|
||||
It it = s1.insert(s1.begin() + i, val);
|
||||
BOOST_TEST(s1.begin() + i == it);
|
||||
It it = s1.insert(s1.begin() + dif_t(i), val);
|
||||
BOOST_TEST(s1.begin() + dif_t(i) == it);
|
||||
BOOST_TEST(s1.size() == h+1);
|
||||
for ( size_t j = 0 ; j < i ; ++j )
|
||||
BOOST_TEST(s1[j] == T((int)j));
|
||||
@@ -388,12 +391,12 @@ void test_insert_nd(T const& 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 )
|
||||
{
|
||||
static_vector<T, N> s1(s);
|
||||
It it = s1.insert(s1.begin() + i, n, val);
|
||||
BOOST_TEST(s1.begin() + i == it);
|
||||
It it = s1.insert(s1.begin() + dif_t(i), n, val);
|
||||
BOOST_TEST(s1.begin() + dif_t(i) == it);
|
||||
BOOST_TEST(s1.size() == h+n);
|
||||
for ( size_t j = 0 ; j < i ; ++j )
|
||||
BOOST_TEST(s1[j] == T((int)j));
|
||||
@@ -571,18 +574,19 @@ void test_emplace_2p()
|
||||
{
|
||||
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);
|
||||
BOOST_TEST(v.size() == N);
|
||||
BOOST_TEST_THROWS(v.emplace_back((int)N, 100 + (int)N), bad_alloc_t);
|
||||
BOOST_TEST(v.size() == N);
|
||||
for (int i = 0 ; i < int(N) ; ++i )
|
||||
BOOST_TEST(v[i] == T(i, 100 + i));
|
||||
for (int i = 0 ; i < (int)N ; ++i )
|
||||
BOOST_TEST(v[std::size_t(i)] == T(i, 100 + i));
|
||||
}
|
||||
|
||||
// emplace(pos, int, int)
|
||||
{
|
||||
typedef typename static_vector<T, N>::iterator It;
|
||||
typedef typename static_vector<T, N>::difference_type dif_t;
|
||||
|
||||
int h = N / 2;
|
||||
|
||||
@@ -593,14 +597,14 @@ void test_emplace_2p()
|
||||
for ( int i = 0 ; i <= h ; ++i )
|
||||
{
|
||||
static_vector<T, N> vv(v);
|
||||
It it = vv.emplace(vv.begin() + i, i+100, i+200);
|
||||
BOOST_TEST(vv.begin() + i == it);
|
||||
It it = vv.emplace(vv.begin() + dif_t(i), i+100, i+200);
|
||||
BOOST_TEST(vv.begin() + dif_t(i) == it);
|
||||
BOOST_TEST(vv.size() == size_t(h+1));
|
||||
for ( int j = 0 ; j < i ; ++j )
|
||||
BOOST_TEST(vv[j] == T(j, j+100));
|
||||
BOOST_TEST(vv[i] == T(i+100, i+200));
|
||||
BOOST_TEST(vv[std::size_t(j)] == T(j, j+100));
|
||||
BOOST_TEST(vv[std::size_t(i)] == T(i+100, i+200));
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +97,18 @@ struct string_literals<char>
|
||||
{
|
||||
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<>
|
||||
@@ -119,7 +131,7 @@ struct string_literals<wchar_t>
|
||||
wchar_t *buf = buffer;
|
||||
|
||||
while(1){
|
||||
int rem = number % 10;
|
||||
unsigned rem = number % 10;
|
||||
number = number / 10;
|
||||
|
||||
*buf = digits[rem];
|
||||
@@ -141,7 +153,7 @@ int string_test()
|
||||
typedef basic_string<CharType> BoostString;
|
||||
typedef vector<BoostString> BoostStringVector;
|
||||
|
||||
const int MaxSize = 100;
|
||||
const std::size_t MaxSize = 100;
|
||||
|
||||
{
|
||||
BoostStringVector *boostStringVect = new BoostStringVector;
|
||||
@@ -152,7 +164,7 @@ int string_test()
|
||||
CharType buffer [20];
|
||||
|
||||
//First, push back
|
||||
for(int i = 0; i < MaxSize; ++i){
|
||||
for(std::size_t i = 0; i < MaxSize; ++i){
|
||||
auxBoostString = string_literals<CharType>::String();
|
||||
auxStdString = string_literals<CharType>::String();
|
||||
string_literals<CharType>::sprintf_number(buffer, i);
|
||||
@@ -171,7 +183,7 @@ int string_test()
|
||||
}
|
||||
|
||||
//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();
|
||||
auxStdString = string_literals<CharType>::String();
|
||||
string_literals<CharType>::sprintf_number(buffer, i);
|
||||
@@ -186,7 +198,7 @@ int string_test()
|
||||
}
|
||||
|
||||
//push front
|
||||
for(int i = 0; i < MaxSize; ++i){
|
||||
for(std::size_t i = 0; i < MaxSize; ++i){
|
||||
auxBoostString = string_literals<CharType>::String();
|
||||
auxStdString = string_literals<CharType>::String();
|
||||
string_literals<CharType>::sprintf_number(buffer, i);
|
||||
@@ -201,7 +213,7 @@ int string_test()
|
||||
}
|
||||
|
||||
//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();
|
||||
auxStdString = string_literals<CharType>::String();
|
||||
string_literals<CharType>::sprintf_number(buffer, i);
|
||||
@@ -285,10 +297,10 @@ int string_test()
|
||||
if(!CheckEqualStringVector(boostStringVect, stdStringVect)) return 1;
|
||||
|
||||
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();
|
||||
|
||||
for(int i = 0; i < MaxSize; ++i){
|
||||
for(std::size_t i = 0; i < MaxSize; ++i){
|
||||
(*boostStringVect)[i].append(sufix);
|
||||
(*stdStringVect)[i].append(sufix);
|
||||
(*boostStringVect)[i].insert((*boostStringVect)[i].begin(),
|
||||
@@ -299,28 +311,28 @@ int string_test()
|
||||
|
||||
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((*stdStringVect)[i].begin(), (*stdStringVect)[i].end());
|
||||
}
|
||||
|
||||
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((*stdStringVect)[i].begin(), (*stdStringVect)[i].end());
|
||||
}
|
||||
|
||||
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(stdStringVect->begin(), stdStringVect->end());
|
||||
}
|
||||
|
||||
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].end(),
|
||||
string_literals<CharType>::String());
|
||||
|
||||
@@ -128,7 +128,7 @@ void test_equal_range(const C& a, std::initializer_list<unsigned> il)
|
||||
|
||||
for (auto&& elem : il)
|
||||
{
|
||||
b.emplace_back(elem);
|
||||
b.emplace_back((int)elem);
|
||||
}
|
||||
|
||||
test_equal_range(a, b);
|
||||
|
||||
@@ -99,15 +99,16 @@ template<class MyBoostVector, class MyStdVector>
|
||||
bool vector_copyable_only(MyBoostVector &boostvector, MyStdVector &stdvector, boost::container::dtl::true_type)
|
||||
{
|
||||
typedef typename MyBoostVector::value_type IntType;
|
||||
typedef typename MyBoostVector::difference_type difference_type;
|
||||
std::size_t size = boostvector.size();
|
||||
boostvector.insert(boostvector.end(), 50, IntType(1));
|
||||
stdvector.insert(stdvector.end(), 50, 1);
|
||||
boostvector.insert(boostvector.end(), 50u, IntType(1));
|
||||
stdvector.insert(stdvector.end(), 50u, 1);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return false;
|
||||
|
||||
{
|
||||
IntType move_me(1);
|
||||
boostvector.insert(boostvector.begin()+size/2, 50, boost::move(move_me));
|
||||
stdvector.insert(stdvector.begin()+size/2, 50, 1);
|
||||
boostvector.insert(boostvector.begin()+difference_type(size/2), 50u, boost::move(move_me));
|
||||
stdvector.insert(stdvector.begin()+difference_type(size/2), 50u, 1);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return false;
|
||||
}
|
||||
{
|
||||
@@ -164,32 +165,32 @@ bool vector_copyable_only(MyBoostVector &boostvector, MyStdVector &stdvector, bo
|
||||
}
|
||||
{ //Vector(n, T)
|
||||
::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::make_unique<MyBoostVector>(100, IntType(5));
|
||||
::boost::movelib::make_unique<MyBoostVector>(100u, IntType(5));
|
||||
if(!test::CheckEqualContainers(*boostvectorp, *stdvectorp)) return 1;
|
||||
}
|
||||
{ //Vector(n, T, alloc)
|
||||
::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::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;
|
||||
}
|
||||
{ //Vector(It, It)
|
||||
::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::make_unique<MyBoostVector>(100);
|
||||
::boost::movelib::make_unique<MyBoostVector>(100u);
|
||||
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp2 =
|
||||
::boost::movelib::make_unique<MyBoostVector>(boostvectorp->begin(), boostvectorp->end());
|
||||
if(!test::CheckEqualContainers(*boostvectorp2, *stdvectorp)) return 1;
|
||||
}
|
||||
{ //Vector(It, It, alloc)
|
||||
::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::make_unique<MyBoostVector>(100);
|
||||
::boost::movelib::make_unique<MyBoostVector>(100u);
|
||||
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp2 =
|
||||
::boost::movelib::make_unique<MyBoostVector>(boostvectorp->begin(), boostvectorp->end(), typename MyBoostVector::allocator_type());
|
||||
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::unique_ptr<MyBoostVector> const boostvectorp =
|
||||
::boost::movelib::make_unique<MyBoostVector>();
|
||||
stdvectorp->resize(100, int(9));
|
||||
boostvectorp->resize(100, IntType(9));
|
||||
stdvectorp->resize(100u, int(9));
|
||||
boostvectorp->resize(100u, IntType(9));
|
||||
if(!test::CheckEqualContainers(*boostvectorp, *stdvectorp)) return 1;
|
||||
}
|
||||
//operator=
|
||||
@@ -215,8 +216,8 @@ bool vector_copyable_only(MyBoostVector &boostvector, MyStdVector &stdvector, bo
|
||||
if(!test::CheckEqualContainers(bcopy2, scopy2)) return false;
|
||||
|
||||
//Assignment from a smaller vector
|
||||
bcopy2.erase(bcopy2.begin() + bcopy2.size()/2, bcopy2.end());
|
||||
scopy2.erase(scopy2.begin() + scopy2.size()/2, scopy2.end());
|
||||
bcopy2.erase(bcopy2.begin() + difference_type(bcopy2.size()/2), bcopy2.end());
|
||||
scopy2.erase(scopy2.begin() + difference_type(scopy2.size()/2), scopy2.end());
|
||||
bcopy = bcopy2;
|
||||
scopy = scopy2;
|
||||
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;
|
||||
|
||||
//Assignment from bigger vector with no capacity
|
||||
bcopy2.erase(bcopy2.begin() + bcopy2.size()/2, bcopy2.end());
|
||||
scopy2.erase(scopy2.begin() + scopy2.size()/2, scopy2.end());
|
||||
bcopy2.erase(bcopy2.begin() + difference_type(bcopy2.size()/2), bcopy2.end());
|
||||
scopy2.erase(scopy2.begin() + difference_type(scopy2.size()/2), scopy2.end());
|
||||
bcopy2.shrink_to_fit();
|
||||
MyStdVector(scopy2).swap(scopy2);
|
||||
|
||||
@@ -250,6 +251,7 @@ int vector_test()
|
||||
{
|
||||
typedef std::vector<int> MyStdVector;
|
||||
typedef typename MyBoostVector::value_type IntType;
|
||||
typedef typename MyBoostVector::difference_type difference_type;
|
||||
const int max = 100;
|
||||
|
||||
if(!test_range_insertion<MyBoostVector>()){
|
||||
@@ -257,32 +259,32 @@ int vector_test()
|
||||
}
|
||||
{ //Vector(n)
|
||||
::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::make_unique<MyStdVector>(100);
|
||||
::boost::movelib::make_unique<MyStdVector>(100u);
|
||||
if(!test::CheckEqualContainers(*boostvectorp, *stdvectorp)) return 1;
|
||||
}
|
||||
{ //Vector(n, alloc)
|
||||
::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::make_unique<MyStdVector>(100);
|
||||
::boost::movelib::make_unique<MyStdVector>(100u);
|
||||
if(!test::CheckEqualContainers(*boostvectorp, *stdvectorp)) return 1;
|
||||
}
|
||||
{ //Vector(Vector &&)
|
||||
::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::make_unique<MyBoostVector>(100);
|
||||
::boost::movelib::make_unique<MyBoostVector>(100u);
|
||||
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp2 =
|
||||
::boost::movelib::make_unique<MyBoostVector>(::boost::move(*boostvectorp));
|
||||
if(!test::CheckEqualContainers(*boostvectorp2, *stdvectorp)) return 1;
|
||||
}
|
||||
{ //Vector(Vector &&, alloc)
|
||||
::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::make_unique<MyBoostVector>(100);
|
||||
::boost::movelib::make_unique<MyBoostVector>(100u);
|
||||
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp2 =
|
||||
::boost::movelib::make_unique<MyBoostVector>
|
||||
(::boost::move(*boostvectorp), typename MyBoostVector::allocator_type());
|
||||
@@ -290,9 +292,9 @@ int vector_test()
|
||||
}
|
||||
{ //Vector operator=(Vector &&)
|
||||
::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::make_unique<MyBoostVector>(100);
|
||||
::boost::movelib::make_unique<MyBoostVector>(100u);
|
||||
::boost::movelib::unique_ptr<MyBoostVector> const boostvectorp2 =
|
||||
::boost::movelib::make_unique<MyBoostVector>();
|
||||
*boostvectorp2 = ::boost::move(*boostvectorp);
|
||||
@@ -305,8 +307,8 @@ int vector_test()
|
||||
MyBoostVector & boostvector = *boostvectorp;
|
||||
MyStdVector & stdvector = *stdvectorp;
|
||||
|
||||
boostvector.resize(100);
|
||||
stdvector.resize(100);
|
||||
boostvector.resize(100u);
|
||||
stdvector.resize(100u);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
boostvector.resize(200);
|
||||
@@ -358,7 +360,7 @@ int vector_test()
|
||||
boostvector.insert(boostvector.end()
|
||||
,boost::make_move_iterator(&aux_vect[0])
|
||||
,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);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
@@ -369,8 +371,8 @@ int vector_test()
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
}
|
||||
{
|
||||
boostvector.resize(100);
|
||||
stdvector.resize(100);
|
||||
boostvector.resize(100u);
|
||||
stdvector.resize(100u);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
IntType aux_vect[50];
|
||||
@@ -384,11 +386,11 @@ int vector_test()
|
||||
}
|
||||
typename MyBoostVector::size_type old_size = boostvector.size();
|
||||
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 + 50));
|
||||
if(boostvector.begin() + old_size/2 != insert_it) return 1;
|
||||
stdvector.insert(stdvector.begin() + old_size/2, aux_vect2, aux_vect2 + 50);
|
||||
if(boostvector.begin() + difference_type(old_size/2) != insert_it) return 1;
|
||||
stdvector.insert(stdvector.begin() + difference_type(old_size/2), aux_vect2, aux_vect2 + 50);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
|
||||
for(int i = 0; i < 50; ++i){
|
||||
@@ -401,12 +403,12 @@ int vector_test()
|
||||
}
|
||||
old_size = boostvector.size();
|
||||
//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 + 50))
|
||||
);
|
||||
if(boostvector.begin() + old_size/2 != insert_it) return 1;
|
||||
stdvector.insert(stdvector.begin() + old_size/2, aux_vect2, aux_vect2 + 50);
|
||||
if(boostvector.begin() + difference_type(old_size/2) != insert_it) return 1;
|
||||
stdvector.insert(stdvector.begin() + difference_type(old_size/2), aux_vect2, aux_vect2 + 50);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||
}
|
||||
|
||||
@@ -505,7 +507,7 @@ int vector_test()
|
||||
MyStdVector(stdvector).swap(stdvector);
|
||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return false;
|
||||
|
||||
boostvector.resize(100);
|
||||
boostvector.resize(100u);
|
||||
if(!test_nth_index_of(boostvector))
|
||||
return 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user