What's the correct opEquals signature for structs?

Alex Rønne Petersen xtzgzorex at gmail.com
Tue Mar 13 11:48:48 PDT 2012


On 13-03-2012 19:43, Jesse Phillips wrote:
> On Tuesday, 13 March 2012 at 18:28:27 UTC, Johannes Pfau wrote:
>> My std.uuid module doesn't compile with the latest dmd. I guess it's
>> because of a wrong opEquals signature, this is what I have now:
>>
>> ----------
>> @safe pure nothrow bool opEquals(ref const UUID s) const
>> {
>> return s.data == this.data;
>> }
>> ----------
>
> I think Alex is right, does auto ref work for parameters?
>
> @safe pure nothrow equals_t opEquals(auto ref const UUID s) const

I think auto ref will only work if it is templatized (unfortunately). 
But that just might work for structs, since it's not an overridden 
function...

i.e.:

@safe pure nothrow equals_t opEquals()(auto ref const UUID s) const

-- 
- Alex


More information about the Digitalmars-d-learn mailing list