opEquals(const ref yadaYada)
lws
invalid at email.com
Mon Dec 14 21:20:47 PST 2009
On 2009-12-14 11:04:53 -0800, Leandro Lucarella <llucax at gmail.com> said:
> lws, el 14 de diciembre a las 08:31 me escribiste:
>> Unless I'm confused, classses are ALWAYS heap (unless explicitely
>> scoped) objects in D.
>
> Yes, and classes are always references too. But that's not even the point,
> the point is, the example was a struct :)
Even if they are always references, they behave as pass-by-value types.
Also, excuse me I read struct as class for some reason earlier.
(*doh!*)
This error-that-should-be-warning is for both types though.
>
>>>>> struct Foo {
>>>>> bool opEquals(const ref Foo rhs) const { // Only signature
>>>>> // that compiles.
>>>>> return true;
>>>>> }
>>>>> }
>>>>>
>>>>> Foo getFoo() {
>>>>> return Foo();
>>>>> }
>>>>>
>>>>> void main() {
>>>>> Foo foo = getFoo();
>>>>> bool isEqual = foo == getFoo();
>>>>> }
>>>>>
>>>>> Error: Foo.opEquals type signature should be const bool(ref const(Foo)) not
>>>>> const bool(Foo rhs)
>>>>>
>>>>> Will this be getting fixed witht he new operator overloading?
>
> [snip]
>> (And please don't top quote, argh! ;))
>
> !!!
More information about the Digitalmars-d
mailing list