A
Alf P. Steinbach
This code is in support of some API functionality:
Can this be written in an even gooder way, for bestest possible code?
Disclaimer: the code has not been tested or even called.
Cheers,
- Alf
Code:
inline
auto can_inflate( gdi::Rect const& r, int const dx, int const dy )
-> bool
{
CPPX_XASSERT( INT_MIN/2 < dx && dx < INT_MAX/2 );
CPPX_XASSERT( INT_MIN/2 < dy && dy < INT_MAX/2 );
typedef unsigned long Unsigned_long;
auto const msb = ULONG_MAX - (ULONG_MAX >> 1);
return
(r.left & msb) == ((Unsigned_long( r.left ) - dx) & msb) &&
(r.top & msb) == ((Unsigned_long( r.top ) - dy) & msb) &&
(r.right & msb) == ((Unsigned_long( r.right ) + dx) & msb) &&
(r.bottom & msb) == ((Unsigned_long( r.bottom ) + dy) & msb);
}
Can this be written in an even gooder way, for bestest possible code?
Disclaimer: the code has not been tested or even called.
Cheers,
- Alf