28 Mar
2018
28 Mar
'18
7:23 p.m.
On 03/28/18 22:10, Stefan Seefeld via Boost wrote:
On 28.03.2018 14:48, Christian Henning via Boost wrote:
I would suggest casting to unsigned first and then performing the math.
I assume this is what you meant:
template <> struct channel_convert_to_unsigned<bits32s> : public std::unary_function
{ typedef bits32 type; type operator()(bits32s x) const { uint32_t a = static_cast (x); a += (1 << 31); return static_cast<bits32>(a); } };
Or simply replace `static_cast<bits32>(x+(1<<31))` by `static_cast<bits32>(x)+(1<<31)` (i.e., cast `x` rather than the full expression).
Rather: static_cast<bits32>(x)+(static_cast<bits32>(1)<<31) to make it compatible with older C++ versions.