From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: "François Dumont" <frs.dumont@gmail.com>
Cc: "libstdc++" <libstdc++@gcc.gnu.org>
Subject: Re: Add three way lower_bound
Date: Thu, 1 Sep 2022 07:47:55 +0100 [thread overview]
Message-ID: <CAH6eHdRVikdpQSqGvOrnuVNhKD7za0mutsjZSYFLKhaby86wfg@mail.gmail.com> (raw)
In-Reply-To: <e6c92783-399a-1e23-eaef-fe3bea91f275@gmail.com>
On Wed, 23 Jun 2021, 21:34 François Dumont via Libstdc++, <
libstdc++@gcc.gnu.org> wrote:
> Hi
>
> Following the message to propose an alternative lower_bound and the
> reply to use three way comparison I try to implement this.
>
> Before going further I wonder if this is something possible ?
>
> The purpose of the:
>
> if constexpr (three_way_comparable<>)
>
> is to make sure that we use it only if there is a proper <=> operator
> defined. Afai understood what is in <compare> we can have the
> __synth3way for any type as long as < exist. But I think that if <=> is
> implemented in terms of < then it might be too expensive, the actual
> lower_bound might already be implemented this way.
>
> My main concerns is of course Standard conformity, could it be ok ?
>
I don't think so. For a built-in type like int I don't think using <=> will
be faster. For a class type type with overloaded operator< it's observable
whether it gets called or not, so this patch would be a change in
observable behaviour. I think we have to use < instead.
> François
>
>
WARNING: multiple messages have this Message-ID
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: "François Dumont" <frs.dumont@gmail.com>
Cc: "libstdc++" <libstdc++@gcc.gnu.org>
Subject: Re: Add three way lower_bound
Date: Thu, 1 Sep 2022 07:47:55 +0100 [thread overview]
Message-ID: <CAH6eHdRVikdpQSqGvOrnuVNhKD7za0mutsjZSYFLKhaby86wfg@mail.gmail.com> (raw)
Message-ID: <20220901064755.PuMx_IFpvtxM-gQaQ160fBVEY1gZGaXvNqytAQtJXtg@z> (raw)
In-Reply-To: <e6c92783-399a-1e23-eaef-fe3bea91f275@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1098 bytes --]
On Wed, 23 Jun 2021, 21:34 François Dumont via Libstdc++, <
libstdc++@gcc.gnu.org> wrote:
> Hi
>
> Following the message to propose an alternative lower_bound and the
> reply to use three way comparison I try to implement this.
>
> Before going further I wonder if this is something possible ?
>
> The purpose of the:
>
> if constexpr (three_way_comparable<>)
>
> is to make sure that we use it only if there is a proper <=> operator
> defined. Afai understood what is in <compare> we can have the
> __synth3way for any type as long as < exist. But I think that if <=> is
> implemented in terms of < then it might be too expensive, the actual
> lower_bound might already be implemented this way.
>
> My main concerns is of course Standard conformity, could it be ok ?
>
I don't think so. For a built-in type like int I don't think using <=> will
be faster. For a class type type with overloaded operator< it's observable
whether it gets called or not, so this patch would be a change in
observable behaviour. I think we have to use < instead.
> François
>
>
next prev parent reply other threads:[~2022-09-01 6:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-23 20:34 François Dumont
2022-09-01 5:01 ` François Dumont
2022-09-01 6:47 ` Jonathan Wakely [this message]
2022-09-01 6:47 ` Jonathan Wakely
2022-09-07 4:53 ` François Dumont
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAH6eHdRVikdpQSqGvOrnuVNhKD7za0mutsjZSYFLKhaby86wfg@mail.gmail.com \
--to=jwakely.gcc@gmail.com \
--cc=frs.dumont@gmail.com \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).