enum detection

Kenji Hara k.hara.pg at gmail.com
Thu Nov 22 09:36:02 PST 2012


On Thursday, 22 November 2012 at 15:10:08 UTC, Jack Applegame 
wrote:
> How to detect enum member?
>
> struct A {
>   enum id = 10;
>   int b;
>   char c;
> }
> foreach(ident; __traits(allMembers, A)) {
>   // is ident enum or not?
> }

Actual field might have `offsetof` builtin property.

(not tested)
   static if (is(typeof(mixin("A."~ident~".offsetof")))) {}

Kenji Hara


More information about the Digitalmars-d-learn mailing list