|
Boost : |
From: Matthias Schabel (boost_at_[hidden])
Date: 2004-09-11 16:43:07
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
};
This seems to solve the insertion problem transparently, whether at the
end or in the middle...
Matthias
>>> This is a pain to read and maintain. You should write them like
>>> this:
>>>
>>> enum
>>> {
>>> f_open = 1<<0,
>>> f_input_closed = 1<<1,
>>> f_output_closed = 1<<2,
>>> f_output_buffered = 1<<3
>>> };
>>>
>> I stole this idiom from John Maddock: http://tinyurl.com/4no5s. It's
>> supposed to
>> make insertion in the middle easier. I think it's the vector vs. list
>> tradeoff.
------------------------------------------------------------------------
---------------------------
Matthias Schabel, Ph.D.
Utah Center for Advanced Imaging Research
729 Arapeen Drive
Salt Lake City, UT 84108
801-587-9413 (work)
801-585-3592 (fax)
801-706-5760 (cell)
801-484-0811 (home)
mschabel at ucair med utah edu
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk