Sometime .offsetof does not compile. Adding a cast can make it compile template Test( uint memberOffset ){} class MyClass { int flags2; mixin Test!(cast(uint)flags2.offsetof) t1; // compiles ok mixin Test!(cast(int)flags2.offsetof) t2; // compiles ok mixin Test!(flags2.offsetof) t3; // Error: no property 'offsetof' for type 'int' }
https://github.com/D-Programming-Language/dmd/pull/230
This problem occurs also in D2.
https://github.com/D-Programming-Language/dmd/commit/031f1694a5dd10b0b65bd77ef7bb9965e2e027d3 https://github.com/D-Programming-Language/dmd/commit/d49cb8906c2e3b39bcf0ac2e6b36ed13510cc432