mirror of
https://github.com/boostorg/container.git
synced 2026-01-25 16:52:48 +01:00
Support GCC's -Wconversion -Wfloat-conversion -Warith-conversion -Wsign-conversion warnings.
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user