I wish all qualifiers were revisited with an eye for simplification

rikki cattermole rikki at cattermole.co.nz
Tue Aug 4 18:05:34 UTC 2020

Alternative syntax (even though it is in the template parameters, it is 
in fact erased and should not end in duplication):

T(U) first(void T=inout, U)(T(U)[] data) {
	assert(data.length > 0);
	return data[0];


struct Foo(void Qual=inout) {
	private int[] _payload;
	this(Qual int[] payload) void(Qual) {
		this._payload = payload;
	@property Qual(int)[] payload() void(Qual) {
		return this._payload;


void assign(void Writable=inout, void Readable=inout)(ref Writable(int)* 
a,Readable(int)* b,ref Writable(int)* c,Readable(int)* d) {


Qual(int)* id(void Qual=inout)(Qual(int)* p) {
     return p;


static assert(is(typeof(&id!mutable)==int* function(int*)))
static assert(is(typeof(&id!immutable)==immutable(int)* 
static assert(is(typeof(&id!const)==const(int)* function(const(int)*)))

That random mutable identifier tho...

More information about the Digitalmars-d mailing list