From e4e72b5ee473d80315b8f751fe762187e795f198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20=C5=81oskot?= Date: Fri, 28 Sep 2018 23:37:46 +0200 Subject: [PATCH] Add explicit conversion of arithmetic result to expected result type Fixes warnings due to implicit promotion of operands, then implicit conversion. --- test/pixel.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/pixel.cpp b/test/pixel.cpp index b6e333c71..55cc096dc 100644 --- a/test/pixel.cpp +++ b/test/pixel.cpp @@ -27,10 +27,17 @@ void error_if(bool condition); struct increment { template void operator()(Incrementable& x) const { ++x; } }; -struct prev { + +struct prev +{ template - typename channel_traits::value_type operator()(const Subtractable& x) const { return x-1; } + auto operator()(const Subtractable& x) const -> typename channel_traits::value_type + { + using return_type = typename channel_traits::value_type; + return static_cast(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