digitalmars.D.learn - How can I distinguish an enum constant from an actual enum at compile
- TheFlyingFiddle (6/6) Oct 30 2015 I want to be able to do something like this:
- TheFlyingFiddle (4/10) Oct 30 2015 Never mind if found out how:
- Gary Willoughby (5/7) Oct 30 2015 enum isEnum(alias e) = is(e == enum);
- Gary Willoughby (2/10) Oct 30 2015 isEnum!(isEnum)
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_
Oct 30 2015
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.
Oct 30 2015
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) ;)
Oct 30 2015
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:isEnum!(isEnum)pragma(msg, is(b == enum)); //True pragma(msg, is(a == enum)); //False.enum isEnum(alias e) = is(e == enum); isEnum!(a) isEnum!(b) ;)
Oct 30 2015