Destructors, const structs, and opEquals
so
so at so.do
Sun Dec 5 05:10:36 PST 2010
> Huh? I don't think you understand what I mean. inout only implicitly
> converts to const. Example:
>
> struct S
> {
> bool opEquals(S rhs){return false;}
> }
>
> struct T
> {
> S s;
> bool opEquals(auto ref inout T rhs) inout {
> return s == rhs.s; // error, cannot call S.opEquals(S rhs) with
> parameters (inout S) inout
> }
> }
>
> You gain nothing from making opEquals of Tuple inout vs. const.
>
> IMO all opEquals should be const functions, and the parameter should be
> const if it is marked as ref, or it contains references.
You are right. Reading it again, using inout is wrong here, both as
parameter and function qualifier.
Only thing missing here is auto ref being broken(?). Using inout in
parameter list already giving error here as it should.
--
Using Opera's revolutionary email client: http://www.opera.com/mail/
More information about the Digitalmars-d
mailing list