On 26 November 2012 15:00, monarch_dodra <monarchdodra@gmail.com> wrote:
On Monday, 26 November 2012 at 12:46:10 UTC, Manu wrote:
On 11/26/12, Manu <turkeyman@gmail.com> wrote:
> 1.
>
> enum i = 10;
> pragma(msg, is(i == enum) || is(typeof(i) == enum)); // <- > false?!
>
> I can't find a way to identify that i is an enum, not a > variable; can not
> be assigned, has no address, etc.
It's not an enum, it's a manifest constant.
Well that's certainly not intuitive. I've never even heard that term
before. It looks awfully like an enum, with the whole 'enum' keyword and
all ;)
How do I detect that then?
The term enum (AFAIK) is comes from an old C++ hack, where you'd create an actual enum to represent variable that's useable compile-time.
Anyways, when you declare an actual enumerate, you have to declare:
1) The enum type
2) The enum values
3) The enum variable
So in your case, it would have to be:
--------
enum Enumerate
{
state1 = 10,
state2
}
Enumerate i = Enumerate.state1;
-----