implementing default opCmp
Ali Çehreli
acehreli at yahoo.com
Thu Nov 19 18:57:39 UTC 2020
On 11/19/20 6:12 AM, Steven Schveighoffer wrote:
> On 11/18/20 6:06 PM, ag0aep6g wrote:
>> int opCmp(S other)
>> {
>> import std.typecons: tuple;
>> return tuple(this.tupleof).opCmp(tuple(other.tupleof));
>> }
>
>
> Ah, excellent solution! I hadn't thought of that.
>
> -Steve
That's what I use as well.
S can be replaced with something like 'typeof(this)' (or perhaps 'ref
const(typeof(this))' and throw some inout in there :) ) and the whole
thing can be mixed-in whereever needed.
Ali
More information about the Digitalmars-d-learn
mailing list