Re: Append one enum to another?
Peter Olcott wrote:
I have two sets of concepts whereas one set of concepts naturally
forms a mathematical proper subset of the other. I must represent
these concepts in code, and enums are the most efficient and concise.
You say nothing about the way[s] those "concepts" or enums are going
to be used. Perhaps wrapping those in a class (or in two classes) is
what you need (or have already done). Keep in mind that inheritance is
a tricky thing.
In your second post you mentioned the form 'enum B = A + { blah };'.
What would it give you? What do you mean by "automatically
incorporated"? And what about Chris' suggestion with the
'end_of_enum_a' value used in 'B' to start the enumeration? Also, you
didn't at all respond to my comment that those enums are still two
different types.
Could it be that you simply need a set of numbers? What if you use an
array of int and a bunch of [named] references to its elements? You can
then use 'sizeof' to generate the second, bigger, array.
I can understand efficiency, I can understand conciseness. And it seems
that you're after ease of maintaining those as well. I don't know the
problems you're facing in the maintenance phase, but perhaps if you post
the code (before and after) and your maintenance concerns, something can
be proposed, like a couple of compile-time assertions and plenty of code
comments...
In the specific case I am creating a greatly simplified C++
interpreter and the subset concepts are data types and the superset
concepts are SymbolTable types, the SymbolTable has some of its own
specialized types such as Function ProtoType.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask