enum behaivor. another rehash of the topic

monarch_dodra monarchdodra at gmail.com
Sun Dec 15 04:40:48 PST 2013


On Sunday, 15 December 2013 at 09:38:28 UTC, deadalnix wrote:
> Resulting in people giving name like TestT1, TestT2 as enum 
> values in C++. As a result, you end up with the same verbosity 
> as in D, without the possibility of using 'with'.

I've usually seen the "namespace" or "struct "approach, eg:

namespace CheckerBoardColor
// or struct CheckerBoardColor
{
     enum Enumeration
     {
         Red,
         Black,
     };
};

This allows using "CheckerBoardColor::Red", which (IMO) is nice 
and verbose. you can use "using CheckerBoardColor" for the 
equivalent of "with" (namespace only).

Unfortunatly, the actual enum "type" is 
"CheckerBoardColor::Enumeration", which is strangely verbose.


More information about the Digitalmars-d mailing list