use c++-stype casts + compare the same types

This commit is contained in:
Artem Pavlenko 2018-11-20 14:35:36 +00:00
parent 65e98c1940
commit 9406eb4c44

View file

@ -39,10 +39,11 @@ image_dimensions<max_size>::image_dimensions(int width, int height)
: width_(width),
height_(height)
{
int64_t area = (int64_t)width * (int64_t)height;
std::int64_t area = static_cast<std::int64_t>(width) * static_cast<std::int64_t>(height);
if (width < 0) throw std::runtime_error("Invalid width for image dimensions requested");
if (height < 0) throw std::runtime_error("Invalid height for image dimensions requested");
if (area > max_size) throw std::runtime_error("Image area too large based on image dimensions");
if (area > static_cast<std::int64_t>(max_size))
throw std::runtime_error("Image area too large based on image dimensions");
}
template <std::size_t max_size>