import capstone.api; import capstone.x86; auto cs = new CapstoneX86(ModeFlags(Mode.bit32)); auto x86reg = new X86Register(cs, X86RegisterId.eip); SafeUnion!X86OpValue safeVal; assertThrown(safeVal.imm); // Not initialised safeVal.reg = x86reg; assertThrown(safeVal.imm); // cannot access the `long` since a `X86Register` is currently stored safeVal.imm = 42; assertNotThrown(safeVal.imm); // can access the `long` now // Corresponding operations on a regular union go unnoticed X86OpValue unsafeVal; unsafeVal.reg = x86reg; assertNotThrown(unsafeVal.imm);
Constructs a SafeUnion wrapping the specified union type
Enables access of the stored value through the field names of the wrapped union.