Boost logo

Boost :

From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2001-09-24 09:02:49


----- Original Message -----
From: Darin Adler <darin_at_[hidden]>
To: Boost <boost_at_[hidden]>
Sent: Friday, September 21, 2001 9:21 PM
Subject: Re: [boost] Review: "int" and "gcd"

> on 9/21/01 2:24 PM, Fernando Cacciola at fcacciola_at_[hidden] wrote:
>
> > * I don't have any 'boost\limits.hpp'. I have installed boost 1.21.1,
which
> > I believe is the latest release.
>
> The latest release is 1.24.0 and it does include <boost/limits.hpp>. See
> <http://www.boost.org> for information about the latest releases.
>
Oh. I missed that one!

> > * The template parameters specifying the number of bits is of type
'int'. I
> > think it should be 'std::size_t'.
>
> I don't agree. There's no special reason to use size_t for numbers of
bits.
>
'int' is signed, but the 'number of bits' is a finite quantity.
Why use a *signed* integer to represent a finite quantity? Just becuase the
maxiumn size fits the maximun positive number representable with the signed
type? I don't think so. I think that values that cannot be negative should
be represented with unsigned types.
Consider, for instance, the std::bitset interface; or consider
'integer_mask.hpp', also in this review.

> > * What's the idea of the 'do { ... } while ( false ) ; ' construct?
>
> That's a standard C macro idiom for turning a set of statements into a
> single statement. It prevents problems with hanging ifs. Here's a
simplified
> example.
>
> #define CALL_IF_0(num, func) if (!num) func()
>
> if (b)
> CALL_IF_0(n, f);
> else
> g();
>
> In the code above, the else gets attached to the if statement inside the
> macro. The do while false idiom fixes this:
>
> #define CALL_IF_0(num, func) do { if (!num) func() } while (false)
>
> if (b)
> CALL_IF_0(n, f);
> else
> g();
>
> The else gets attached to the proper if.
>
I see, thanks!

Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com


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