Support GCC's -Wconversion -Wfloat-conversion -Warith-conversion -Wsign-conversion warnings.

This commit is contained in:
Ion Gaztañaga committed 2021-10-16 15:56:54 +02:00
1 parent a4180b9e9f
commit 2eeee6cb4c
23 files changed
+337 -422

No files matched your search

+2 -2
View File
@@ -47,13 +47,13 @@ struct delete_disposer
int main()
{
const int MaxElem = 100;
const std::size_t MaxElem = 100;
std::vector<my_class> nodes(MaxElem);
//Fill all the nodes and insert them in the list
my_class_list list;
for(int i = 0; i < MaxElem; ++i) nodes[i].int_ = i;
for(std::size_t i = 0; i < MaxElem; ++i) nodes[i].int_ = (int)i;
list.insert(list.end(), nodes.begin(), nodes.end());
+4 -4
View File
@@ -57,7 +57,7 @@ typedef boost::intrusive::unordered_set
int main()
{
//Create MaxElem objects
const int MaxElem = 100;
const std::size_t MaxElem = 100;
std::vector<intrusive_data> nodes(MaxElem);
//Declare the intrusive containers
@@ -67,7 +67,7 @@ int main()
(unordered_set_t::bucket_traits(buckets, MaxElem));
//Initialize all the nodes
for(int i = 0; i < MaxElem; ++i) nodes[i].set(i);
for(std::size_t i = 0; i < MaxElem; ++i) nodes[i].set((int)i);
//Now insert them in both intrusive containers
list.insert(list.end(), nodes.begin(), nodes.end());
@@ -75,7 +75,7 @@ int main()
//Now check the iterator_to function
list_t::iterator list_it(list.begin());
for(int i = 0; i < MaxElem; ++i, ++list_it)
for(std::size_t i = 0; i < MaxElem; ++i, ++list_it)
if(list.iterator_to(nodes[i]) != list_it ||
list_t::s_iterator_to(nodes[i]) != list_it)
return 1;
@@ -83,7 +83,7 @@ int main()
//Now check unordered_set::s_iterator_to (which is a member function)
//and unordered_set::s_local_iterator_to (which is an static member function)
unordered_set_t::iterator unordered_set_it(unordered_set.begin());
for(int i = 0; i < MaxElem; ++i){
for(std::size_t i = 0; i < MaxElem; ++i){
unordered_set_it = unordered_set.find(nodes[i]);
if(unordered_set.iterator_to(nodes[i]) != unordered_set_it)
return 1;
+3 -3
View File
@@ -68,8 +68,8 @@ int main()
{
//Now create an intrusive list in shared memory:
//nodes and the container itself must be created in shared memory
const int MaxElem = 100;
const int ShmSize = 50000;
const std::size_t MaxElem = 100;
const std::size_t ShmSize = 50000;
const char *ShmName = get_shared_memory_name();
{
//Erase all old shared memory
@@ -88,7 +88,7 @@ int main()
pshm_vect->resize(MaxElem);
//Initialize all the nodes
for(int i = 0; i < MaxElem; ++i) (*pshm_vect)[i].set(i);
for(std::size_t i = 0; i < MaxElem; ++i) (*pshm_vect)[i].set((int)i);
//Now create the shared memory intrusive list
intrusive_list_t *plist = shm.construct<intrusive_list_t>(ip::anonymous_instance)();
+5 -5
View File
@@ -40,21 +40,21 @@ int main()
//as multiset's comparison predicate, so we can just push back
//all elements, which is more efficient than normal insertion
multiset<MyClass> mset;
for(int i = 0; i < 100; ++i) mset.push_back(values[i]);
for(std::size_t i = 0; i != 100u; ++i) mset.push_back(values[i]);
//Now check orderd invariant
multiset<MyClass>::const_iterator next(mset.cbegin()), it(next++);
for(int i = 0; i < 99; ++i, ++it, ++next) assert(*it < *next);
for(std::size_t i = 0; i < 99u; ++i, ++it, ++next) assert(*it < *next);
}
{ //Now the correct order for the set is the reverse order
//so let's push front all elements
multiset<MyClass, compare< std::greater<MyClass> > > mset;
for(int i = 0; i < 100; ++i) mset.push_front(values[i]);
for(std::size_t i = 0; i < 100u; ++i) mset.push_front(values[i]);
//Now check orderd invariant
multiset<MyClass, compare< std::greater<MyClass> > >::
const_iterator next(mset.cbegin()), it(next++);
for(int i = 0; i < 99; ++i, ++it, ++next) assert(*it > *next);
for(std::size_t i = 0; i < 99u; ++i, ++it, ++next) assert(*it > *next);
}
{ //Now push the first and the last and insert the rest
//before the last position using "insert_before"
@@ -62,7 +62,7 @@ int main()
mset.insert_before(mset.begin(), values[0]);
multiset<MyClass>::const_iterator pos =
mset.insert_before(mset.end(), values[99]);
for(int i = 1; i < 99; ++i) mset.insert_before(pos, values[i]);
for(std::size_t i = 1; i < 99u; ++i) mset.insert_before(pos, values[i]);
//Now check orderd invariant
multiset<MyClass>::const_iterator next(mset.cbegin()), it(next++);
+1 -1
View File
@@ -15,7 +15,7 @@
struct my_node
{
my_node(int i = 0, unsigned int priority = 0)
my_node(int i = 0, int priority = 0)
: prio_(priority), int_(i)
{}
my_node *parent_, *left_, *right_;
+1 -1
View File
@@ -66,7 +66,7 @@ int main()
//Create several MyClass objects, each one with a different value
std::vector<MyClass> values;
for(int i = 0; i < 100; ++i) values.push_back(MyClass(i, (i % 10)));
for(std::size_t i = 0; i < 100u; ++i) values.push_back(MyClass((int)i, unsigned(i % 10)));
BaseSet baseset;
MemberMultiset membermultiset;