safeOnly

User-defined attribute to enable only safe calls on the given member(s).

Examples

union Fields
{
	int intval;
	@safeOnly int *ptr;
}

// only safe operations allowed on pointer field
@safe void test() {
	TaggedAlgebraic!Fields x = 1;
	x += 5; // only applies to intval
	auto p = new int(5);
	x = p;
	*x += 5; // safe pointer ops allowed
	assert(*p == 10);
}

test();

Meta