On Monday, 5 May 2014 at 17:55:37 UTC, Meta wrote:


enum offsetof(T, string field) = mixin(type.stringof ~ "." ~ field ~ ".offsetof");

To ensure that a syntactically valid symbol is passed as the type.

Interestingly, but this code doesn't compile:

enum offsetof(typenfield) = mixin(type.stringof ~ ".offsetof");

writeln(offsetof!(StrToBob.bob));

Reply via email to