Qualified class opEquals()
Paul Backus
snarwin at gmail.com
Tue Dec 25 00:32:55 UTC 2018
On Monday, 24 December 2018 at 22:58:03 UTC, Per Nordlöw wrote:
> Is it in the following code possible to make the statement
>
> assert(car1 == car2);
>
> in the function testEqual() compile in a `@safe pure nothrow
> @nogc context`?
No, because equality comparison between classes lowers to
`object.opEquals` [1], which takes both parameters as `Object`.
If you call car1.opEquals(car2) directly, it should work.
[1]
https://github.com/dlang/druntime/blob/master/src/object.d#L1051
More information about the Digitalmars-d-learn
mailing list