C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Manifold comparison operator

From: Lénárd Szolnoki <cpp_at_[hidden]>
Date: Tue, 26 Sep 2023 16:09:00 +0100
On Tue, 2023-09-26 at 12:29 +0200, Fabio Alemagna via Std-Proposals
wrote:
> Il giorno mar 26 set 2023 alle ore 11:13 Bjorn Reese
> <breese_at_[hidden]> ha scritto:
> >
> > On 9/24/23 16:05, Fabio Alemagna via Std-Proposals wrote:
> >
> > > It seems to be working fine, but comments and corrections are
> > > greatly welcome.
> >
> > Here is a simplification that uses std::apply:
> >
> > https://godbolt.org/z/9bn4jn5v7
>
> That looks indeed neater at some levels, but you did away with the
> type check, which renders the construct not able to deal with a
> heterogeneous set of value types any longer.
>
> However, meanwhile I came up with a revised version that uses
> policies
> and free functions rather than subclasses, to achieve the same syntax
> but with a leaner and more composable implementation.
>
> https://godbolt.org/z/4Wv7rq4se

I don't know how to interpret `all_of(a, b) < any_of(c, d)` at a
glance.

Is this "for every x in {a, b} exists y in {c, d} so that x < y", or is
it "there exists a y in {c, d} so that for every x in {a, b} x < y".

I think these two are probably equivalent if a,b,c,d have a total
order, otherwise I don't think they necessarily are.

For the partial order where a < c and b < d are true and other
comparisons are false the first statement is true and the second
statement is false.

all_of(a,b) == any_of(a,b) is a similar example.

Cheers,
Lénárd

Received on 2023-09-26 15:09:06