Need help with movement from C to D

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue May 6 07:45:10 PDT 2014


On Tuesday, 6 May 2014 at 14:25:01 UTC, Artur Skawina via 
Digitalmars-d-learn wrote:
> I'm not sure why you'd want to wrap the .offsetof expression in
> a template, but it can easily be done like this:
>
>    enum offsetOf(alias A, string S) = mixin("A."~S~".offsetof");

Great, that's even shorter.

Somehow I was fixated on converting the symbol to a string first, 
but of course the name is directly available in the mixin:

     enum offsetof(alias typenfield) = 
mixin("typenfield.offsetof");


More information about the Digitalmars-d-learn mailing list