
"Rob Stewart" <stewart@sig.com> wrote in message news:200409101906.i8AJ6M921012@lawrencewelk.systems.susq.com...
From: "Jonathan Turkanis" <technews@kangaroologic.com>
enum { f_open = 1, f_input_closed = f_open << 1, f_output_closed = f_input_closed << 1, f_output_buffered = f_output_closed << 1 };
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 };
You can easily spot that the values are in ascending order and you don't have to replicate the name of the preceding enumerator (which would make reordering a pain, should that be needed).
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. Jonathan.