2
0
mirror of https://github.com/boostorg/gil.git synced 2026-02-01 08:32:10 +00:00

Add explicit conversion of arithmetic result to expected result type

Fixes warnings due to implicit promotion of operands, then implicit
conversion.
This commit is contained in:
Mateusz Łoskot
2018-09-28 23:37:46 +02:00
parent ed96c9cdf1
commit e4e72b5ee4

View File

@@ -27,10 +27,17 @@ void error_if(bool condition);
struct increment {
template <typename Incrementable> void operator()(Incrementable& x) const { ++x; }
};
struct prev {
struct prev
{
template <typename Subtractable>
typename channel_traits<Subtractable>::value_type operator()(const Subtractable& x) const { return x-1; }
auto operator()(const Subtractable& x) const -> typename channel_traits<Subtractable>::value_type
{
using return_type = typename channel_traits<Subtractable>::value_type;
return static_cast<return_type>(x - 1);
}
};
struct set_to_one{ int operator()() const { return 1; } };
// Construct with two pixel types. They must be compatible and the second must be mutable