What's the correct opEquals signature for structs?

Alex Rønne Petersen xtzgzorex at gmail.com
Tue Mar 13 17:14:04 PDT 2012


On 14-03-2012 01:10, Jonathan M Davis wrote:
> On Tuesday, March 13, 2012 22:03:45 Alex Rønne Petersen wrote:
>> Did you see my other post? Maybe we could do something like this:
>>
>> equals_t opEquals()(const auto ref SysTime rhs) const pure nothrow
>
> That would probably work (though I wouldn't use equals_t, since it seems like
> an utterly pointless alias to me). Still, it shouldn't have to be templated to
> work with auto ref.
>
> - Jonathan M Davis

That's arguable...

The thing is, auto ref, when used on class methods cannot work. The 
reason is simple: Inheritance. An overriding method can't magically take 
both a value and a reference.

Obviously we can special-case auto ref on structs, but... is this really 
desirable?

-- 
- Alex


More information about the Digitalmars-d-learn mailing list