opCall() @property

Zhenya zheny at list.ru
Fri Jun 29 12:54:42 PDT 2012


On Friday, 29 June 2012 at 19:37:50 UTC, Namespace wrote:
> 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);
> }

I see, I just thought that opCall @ property equivalent opAssign 
and wanted to check it out, and now I would be interested to 
understand why it is not


More information about the Digitalmars-d-learn mailing list