On Tuesday, 6 May 2014 at 11:09:37 UTC, Andrey wrote:
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));
That's because `StrToBob.bob.stringof` is "bob". You can use this
instead:
import std.traits;
enum offsetof(alias typenfield) =
mixin(fullyQualifiedName!(typenfield) ~ ".offsetof");