ProtoObject and comparison for equality and ordering
Steven Schveighoffer
schveiguy at gmail.com
Wed May 15 08:56:53 UTC 2019
On 5/14/19 9:36 PM, Eduard Staniloiu wrote:
> Jonathan's question got us to the point raised: maybe it doesn't make
> much sense to be able to compare two `ProtoObjects`, so maybe you
> shouldn't be able to. This would change the interface to
> ```
> interface Ordered(T)
> {
> int opCmp(scope const T rhs);
> }
> ```
>
> Now the attributes of `opCmp` will be inferred.
Just wanted to make sure you understand this is not the case. opCmp in
this instance is a virtual call, and will NOT have attributes inferred.
There isn't really a way to define an interface for this, nor do you
need to.
Just define the opCmp you want in your own interface/base object, and
then you can compare those. Almost nobody wants to compare 2 completely
unrelated objects.
-Steve
More information about the Digitalmars-d
mailing list