Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2005-05-05 15:47:40


From: "Beman Dawes" <bdawes_at_[hidden]>
> "Thomas Witt" <witt_at_[hidden]> wrote in message
> news:d595jr$2d0$1_at_sea.gmane.org...
>
> >> There is also a nice simplicity in the current design; the functions
> >> always returns a value with one and only one flag set.
> >
> > In this case the fact that it is a bitmask type seems to be kind of
> > misleading. Isn't the whole point of a bitmask type to be able to have
> > multiple flags set at once?
>
> Multiple flags are or'ed together for tests:
>
> if ( (status(p) & (directory_flag|file_flag)) != 0 ) ...
>
> Isn't the usual way of the standard is to describe that as a "bitmask
> type"?

I think Thomas was looking at it from the other perspective, as
was I: it only ever returns one value, so why is it a bitmask.
Your example is compelling, however.

BTW, if you return a UDT, you can provide both (in)equality and
bitwise OR operators. The former would allow more
straightforward comparisons when you are checking for just one
flag.

-- 
Rob Stewart                           stewart_at_[hidden]
Software Engineer                     http://www.sig.com
Susquehanna International Group, LLP  using std::disclaimer;

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