Thread overview | ||||||
---|---|---|---|---|---|---|
|
October 30, 2015 How can I distinguish an enum constant from an actual enum at compile time? | ||||
---|---|---|---|---|
| ||||
I want to be able to do something like this: enum a = 32 enum b = { q,w,e,r,t,y } CtType ctype = getCtType!(a); // -> Would become CtType.enumConstant CtType ctype1 = getCtType!(b); // -> Would become CtType.enum_ |
October 30, 2015 Re: How can I distinguish an enum constant from an actual enum at compile time? | ||||
---|---|---|---|---|
| ||||
Posted in reply to TheFlyingFiddle | On Friday, 30 October 2015 at 11:46:43 UTC, TheFlyingFiddle wrote:
> I want to be able to do something like this:
>
> enum a = 32
> enum b = { q,w,e,r,t,y }
>
> CtType ctype = getCtType!(a); // -> Would become CtType.enumConstant
> CtType ctype1 = getCtType!(b); // -> Would become CtType.enum_
Never mind if found out how:
pragma(msg, is(b == enum)); //True
pragma(msg, is(a == enum)); //False.
|
October 30, 2015 Re: How can I distinguish an enum constant from an actual enum at compile time? | ||||
---|---|---|---|---|
| ||||
Posted in reply to TheFlyingFiddle | On Friday, 30 October 2015 at 12:03:50 UTC, TheFlyingFiddle wrote:
> pragma(msg, is(b == enum)); //True
> pragma(msg, is(a == enum)); //False.
enum isEnum(alias e) = is(e == enum);
isEnum!(a)
isEnum!(b)
;)
|
October 30, 2015 Re: How can I distinguish an enum constant from an actual enum at compile time? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gary Willoughby | On Friday, 30 October 2015 at 12:18:21 UTC, Gary Willoughby wrote:
> On Friday, 30 October 2015 at 12:03:50 UTC, TheFlyingFiddle wrote:
>> pragma(msg, is(b == enum)); //True
>> pragma(msg, is(a == enum)); //False.
>
> enum isEnum(alias e) = is(e == enum);
>
> isEnum!(a)
> isEnum!(b)
>
> ;)
isEnum!(isEnum)
|
Copyright © 1999-2021 by the D Language Foundation