Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-09-11 17:14:40

"Matthias Schabel" <boost_at_[hidden]> wrote:

Hi Matthias,

Until last year I lived near research park, just above Hogel Zoo. So you're
right in my old stomping grounds.

> Why give an explicit integer label to any of the values (except the
> starting value)? It seems to me that the point of an enum declaration
> is to guarantee unique values for each tag, but relying on having any
> specific value correspond to a given tag is dangerous. I would write
> it like this :
> enum
> {
> f_open = 0,
> f_input_closed,
> f_output_closed,
> f_output_buffered
> };

If all you want is unique values, this is fine. But in the cases I was
describing (from iostreams and regex) the goal is to define a set of constants
which can serve as bit flags. The easiest way to do this is for each constant to
have twice the value of the previous constant -- starting at 1 instead of 0, of
course ;-)

Thus the proliferation of <<'s

> Matthias


> ---------------------------
> Matthias Schabel, Ph.D.
> Utah Center for Advanced Imaging Research
> 729 Arapeen Drive
> Salt Lake City, UT 84108

Boost list run by bdawes at, gregod at, cpdaniel at, john at