Boost logo

Boost :

Subject: Re: [boost] [gil] gcc fail with simple code
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2018-03-28 19:23:57


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<bits32s,bits32> {
>> typedef bits32 type;
>> type operator()(bits32s x) const
>> {
>> uint32_t a = static_cast<uint32_t>(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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk