What's the status of old-style operator overloads in D2?

Meta via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 22 15:54:41 PDT 2014


On Tuesday, 22 April 2014 at 21:35:31 UTC, Meta wrote:
> Does this work if test is in a different module from main?
>
> struct test
> {
> 	private int opBinary(string op: "*")(test other) { return 3; }
> 	public alias opMul = opBinary!"*";
> }
>
> void main()
> {
> 	test t1 = test();
> 	test t2 = test();
> 	auto n = t1 * t2;
> 	assert(n == 3);
> }

And it appears it does.


More information about the Digitalmars-d mailing list