Boost logo

Boost :

From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2003-01-20 18:36:35


On Mon, 20 Jan 2003 19:40:42 +0100, Gennaro Prota
<gennaro_prota_at_[hidden]> wrote:

>> enum {c = (1 << n) <= x};
>
>
>Wrong. The left-shift may give undefined behavior, because n can be
>greater than or equal to the number of value bits in an unsigned long
                                                         ^^^^^^^^^^^^^

In an int, sorry. I was thinking to the case below

>> enum {value = c*n + log2<(x>>(c*n)),(n/2)>::value};

where the left operand of >> has, of course, type unsigned long.

Genny.


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