fix some warnings

This commit is contained in:
Alex Fabijanic 2017-10-20 11:47:29 -05:00
parent 5de43daf38
commit 1101439eb0
2 changed files with 30 additions and 13 deletions

View File

@ -401,13 +401,29 @@ private:
template <typename F, typename T>
void POCO_UNUSED checkUpperLimit(const F& from) const
{
// casting to type of smaller size AND
// 'from' is greater than 'T' max value
if ((sizeof(T) < sizeof(F)) &&
(from > static_cast<F>(std::numeric_limits<T>::max())))
{
throw RangeException("Value too large.");
}
else
if (from > std::numeric_limits<T>::max())
// casting to type of equal/bigger size AND
// 'F' is signed AND
// 'T' is unsigned AND
// 'from' is negative
else if (std::numeric_limits<F>::is_signed &&
!std::numeric_limits<T>::is_signed && from < 0)
{
throw RangeException("Value too small.");
}
// casting to type of equal/bigger size AND
// 'F' is unsigned AND
// 'T' is signed AND
// 'from' is greater than 'T' max value
else if (!std::numeric_limits<F>::is_signed &&
std::numeric_limits<T>::is_signed &&
static_cast<Poco::UInt64>(from) > std::numeric_limits<T>::max())
{
throw RangeException("Value too large.");
}

View File

@ -79,9 +79,10 @@ namespace
{
}
NonDefaultConstructible operator=(int val)
NonDefaultConstructible& operator=(int val)
{
_val = val;
return *this;
}
bool operator == (const NonDefaultConstructible& other) const