ProtoObject and comparison for equality and ordering
Noob
noob at dlang.org
Thu May 16 17:31:19 UTC 2019
Any thoughts about the spaceship operator design as accepted for
C++20?
Not invented here, but there seems to be room for improvement:
https://stackoverflow.com/q/47485803
On Wednesday, 15 May 2019 at 00:32:32 UTC, Andrei Alexandrescu
wrote:
> ---
> import std.stdio;
>
> struct OverengineeredCmpResult {
> enum R { lt, eq, gt, ionno }
> private R payload;
> int opCmp(int alwaysZero) {
> writeln("b");
> return 0;
> }
> }
>
> struct A {
> OverengineeredCmpResult opCmp(A rhs) {
> writeln("a");
> return
> OverengineeredCmpResult(OverengineeredCmpResult.R.ionno);
> }
> }
>
> void main() {
> A a, b;
> if (a < b) {}
> }
> ---
More information about the Digitalmars-d
mailing list