Check -INT_MIN case in safe.hpp negate operator

This commit is contained in:
Nathan Hourt 2015-03-02 09:50:31 -05:00
parent e71ea52075
commit b393ddc1da

View file

@ -33,7 +33,12 @@ namespace fc {
}
safe& operator *= ( T v ) { value *= v; return *this; }
safe& operator -= ( const safe& b ) { return *this += safe(-b.value); }
safe operator -()const{ return safe(-value); }
safe operator -()const
{
if( value == std::numeric_limits<T>::min() )
FC_CAPTURE_AND_THROW( overflow_exception, (value) );
return safe(-value);
}
friend safe operator - ( const safe& a, const safe& b )
{