alias for the thing to be called with the active member of the provided smart-union
type of smart-union to operate on
smart-union instance whose active field should be passed to Callable
union TestUnion { int a; float b; } alias SmartUnion!(TestUnion) TestSmartUnion; static struct ActiveUnionFieldPrinter { static void print ( T ) ( T t ) { Stdout.formatln("{}", t); } void printActiveUnionField ( ) { TestSmartUnion su; su.a = 23; callWithActive!(print)(su); } }
Calls the specified callable with the active field of the provided smart-union. If no field is active, does nothing.
Note: declared at module-scope (rather than nested inside the SmartUnion template) to work around limitations of template alias parameters. (Doing it like this allows it to be called with a local name.)