opCall() @property

Namespace rswhite4 at googlemail.com
Fri Jun 29 12:37:49 PDT 2012


This works:

import std.stdio;

struct X {
private:
	bool _x;

public:
	this(bool x) {
		_x = x;
	}

	@property
	bool Get() inout {
		return this._x;
	}

	alias Get this;

	typeof(this) opAssign(bool x) {
		this._x = x;

		return this;
	}
}

void main()
{
	X a = false;
	writeln(a);
	a = true;
	writeln(a);
}



More information about the Digitalmars-d-learn mailing list