Re: opCmp with and without const

2019-12-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, December 6, 2019 12:03:45 AM MST berni44 via Digitalmars-d-learn wrote: > In std.typecons, in Tuple there are two opCmp functions, that are > almost identical; they only differ by one being const and the > other not: > > int opCmp(R)(R rhs) > if

Re: opCmp with and without const

2019-12-06 Thread Basile B. via Digitalmars-d-learn
On Friday, 6 December 2019 at 07:03:45 UTC, berni44 wrote: In std.typecons, in Tuple there are two opCmp functions, that are almost identical; they only differ by one being const and the other not: int opCmp(R)(R rhs) if (areCompatibleTuples!(typeof(this), R, "<")) {

Re: opCmp with and without const

2019-12-05 Thread Paul Backus via Digitalmars-d-learn
On Friday, 6 December 2019 at 07:03:45 UTC, berni44 wrote: My real question is: Can this code duplication be avoided somehow? (I ask, because I've got a PR running, which increases the size of these functions and it doesn't feel good to have two long, almost identical functions.) You can use

opCmp with and without const

2019-12-05 Thread berni44 via Digitalmars-d-learn
In std.typecons, in Tuple there are two opCmp functions, that are almost identical; they only differ by one being const and the other not: int opCmp(R)(R rhs) if (areCompatibleTuples!(typeof(this), R, "<")) { static foreach (i; 0 .. Types.length)