From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-05-09 08:41:27
Beman Dawes wrote:
> "Peter Dimov" <pdimov_at_[hidden]> wrote in message
>> You don't need a name because the user will never test for this
>> category. if( status() & other_flag )
>> // OK, so what do I do here?
>> The other categories have expectations attached, so testing for them
>> makes sense.
> What you might do in the code above is report the fact that an
> "other" has been discovered, or execute a fallback procedure, or
A fallback only makes sense if a test fails, not when it succeeds.
int r = status();
if( r & directory_flag )
else if( r & file_flag )
// implementation defined, but in general file-like
Note that the code is resilient to future changes introducing other
if( r & other_flag )
When the "other" category is split to "device" and "other other", the
meaning of the above code changes. It no longer falls back when it
encounters a device, but it did before.
Explicit tests for "other" or "unknown" are evil and will not pass a
sensible code review anyway.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk