>> One can use Color::Brown to solve ambiguities if necessary

That would be invalid C++. If a given compiler accepts it then the compiler is not strictly conforming. See the C++ Standard section 7.2 and section 9.2 p1. A scoping operator prefixed to an enumerand refers to the enclosing scope (class or namespace).

Also, the following is invalid C++, as it introduces multiple identical enumerands into the enclosing scope:

enum Color {
  Red,
  Blue
}

enum Politics{
  Red,
  Blue
}

Note that this above collision occurs only if the enumerations are within the same scope, so if they are within different classes then there isn't a problem. I personally use ColorRed, ColorBlue, etc. in order to avoid any ambiguity for the reader of the code and to increase clarity. It's rather like providing the scoping name that the language doesn't strictly permit. But that's just me. But I think a sufficiently descriptive name can make this unnecessary.

Paul



On Wed, Oct 1, 2008 at 4:01 PM, Eric Seidel <[EMAIL PROTECTED]> wrote:
enum Color {
  Brown,
  Red,
  Blue
}

I've always been a fan of this, personally... One can use Color::Brown to solve ambiguities if necessary, but stick with just Brown in most scenarios.

PK 


_______________________________________________
webkit-dev mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

Reply via email to