vibe.d beta banner
get vibe.d
0.10.0

Asynchronous I/O that doesn’t get in your way, written in D

Enum safeOnly

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

enum safeOnly : void { ... }

Enum members

NameDescription

Example

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();
Authors

Sönke Ludwig

Copyright

Copyright 2015-2019, Sönke Ludwig.

License

www.boost.org/LICENSE_1_0.txt, Boost License 1.0.