Re: enum detection

2012-11-22 Thread Jack Applegame
On Thursday, 22 November 2012 at 17:36:03 UTC, Kenji Hara wrote: Actual field might have `offsetof` builtin property. (not tested) static if (is(typeof(mixin("A."~ident~".offsetof" {} Yes, it works! Thanks.

Re: enum detection

2012-11-22 Thread Jack Applegame
On Thursday, 22 November 2012 at 17:36:03 UTC, Kenji Hara wrote: Actual field might have `offsetof` builtin property. (not tested) static if (is(typeof(mixin("A."~ident~".offsetof" {} Yes, it works! Thanks.

Re: enum detection

2012-11-22 Thread bearophile
Have you tried is(ident == enum) ? Sorry, ignore this answer, I was too much distracted. Bye, bearophile

Re: enum detection

2012-11-22 Thread Kenji Hara
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

Re: enum detection

2012-11-22 Thread bearophile
Jack Applegame: How to detect enum member? struct A { enum id = 10; int b; char c; } foreach(ident; __traits(allMembers, A)) { // is ident enum or not? } Have you tried is(ident == enum) ? Bye, bearophile

Re: enum detection

2012-11-22 Thread Andrej Mitrovic
On 11/22/12, 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? > } That's not an enum, that's a manifest constant. This is an enum: struct A { enum id { x = 10

enum detection

2012-11-22 Thread Jack Applegame
How to detect enum member? struct A { enum id = 10; int b; char c; } foreach(ident; __traits(allMembers, A)) { // is ident enum or not? }