220 31496 <26e2c972-3c64-4f62-a856-e7490621958e@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Dan Raviv <dan.raviv@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: overloading by constexpr (round 2?)
Date: Tue, 7 Mar 2017 10:01:01 -0800 (PST)
Lines: 149
Approved: news@gmane.org
Message-ID: <26e2c972-3c64-4f62-a856-e7490621958e@isocpp.org>
References: <CAFdMc-2q3KpV+m5cfWr6b02XmHVUdxsNCNAVFG+mzCv0QY7ZRg@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_891_2045239084.1488909661211"
X-Trace: blaine.gmane.org 1488909669 4796 195.159.176.226 (7 Mar 2017 18:01:09 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 7 Mar 2017 18:01:09 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBC5YJREBWAGRBXPK7PCQKGQE5A5M25I@isocpp.org Tue Mar 07 19:01:05 2017
Return-path: <std-proposals+bncBC5YJREBWAGRBXPK7PCQKGQE5A5M25I@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ua0-f200.google.com ([209.85.217.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBC5YJREBWAGRBXPK7PCQKGQE5A5M25I@isocpp.org>)
	id 1clJPw-0000RR-NJ
	for gclcip-std-proposals@m.gmane.org; Tue, 07 Mar 2017 19:01:00 +0100
Original-Received: by mail-ua0-f200.google.com with SMTP id 62sf18633594uas.1
        for <gclcip-std-proposals@m.gmane.org>; Tue, 07 Mar 2017 10:01:07 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=rCyiTHeHaxWCRDyFk4SdveoTgj+BYloFq1BmujzfmgA=;
        b=e0fyXBYuuxwcJ3RsvCQ/iIIJA03ntlf4BbIyHDANtTw9OeMHsOoerY29/1M73Fq9dn
         Gu6kx1H2vgkcQUOwUwOBHQkbB/KNvruTV0WCvBzzXDJWeEz/Yg77X4/RYZevWk1k3V34
         rQ1Lge3DPtp5hagtZthiUHuWcEihGTCCCGZHdUZHh63eBXQlDNYFeXjXb+B4mbWeNISr
         03r8kGnmkHnWbIqqt/jQBZM9IbrhH9Ng4qwI71GCMsnND/cD+rCm/vt70Uwu5TUn5NGo
         I4FmfedgCmOf6cHlFaVictw18MfSlNLy5vPzbmzE/o/KJI1tYtQa6/g+LyVLg8Puauxv
         aOWQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=rCyiTHeHaxWCRDyFk4SdveoTgj+BYloFq1BmujzfmgA=;
        b=sAfgrJ+zgJCO7fqilKbMWVfyBDGYrgS3dBwNaATznnKm/ovroscx/asSzoTzdclSx3
         ET7YQDWBJ1hh95QkfC/syrXRaBN+WF9OsDlnRy5fMoR4xT4VLVMo/t+BilVuHbzEkFTr
         QZrlW/GmXo7yM4+o4qO3sEidQjgkb03R1MqF5huz2oQ4HeCu9JOrWAFJU/m/m17EA6kp
         en5LjkvCKhk9VYHKMIYuPFi9oIeiTC7oC9oTgtKBhfTXrjRJs4VJ6UMqhghl+EKsOqf2
         Uq0LGy6PwWB+EekVw3e+h6GvBHzRwBsyG+4brhSes80ePJoIScD+gdjdusNMpxzG13q8
         +QuQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=rCyiTHeHaxWCRDyFk4SdveoTgj+BYloFq1BmujzfmgA=;
        b=cv/g87yCcpF3TmiT36BePaIKjxCo3uyq1yXTGzl+yZ0xClrBGHvOYJ815mq+jNquw+
         Ljpqnp1ep5c7/qHY1pSE/XJ/vnCPVyRk/KX8xKCO5K+ntI2OCtp/rawGjFrHoZT/KIwu
         aQjNlW9NWHYWs7dzxBuWIiSyPCzG9rJynPS0S+zAz9axVStIjPuYU9XIKyk+eKozFd+r
         saIOoP+6KfQ119Gn60Mk71x1eyEhfrlzafK5ub8bA0XSnpMZZju0chXDWn49dyPADxr2
         a5xvm/oOIAPK8VvtpnUwN+vkYzsaWxA+TPUc6j3Hy3kaGI/52Fa4JciKYK0A4nj9eGmq
         JQiQ==
X-Gm-Message-State: AMke39nootljgFIJ8pv8pBWIbfCZSm9NFBQ72rnflRKlfO8pWkWWXYVI1buX27hJJvPyKA==
X-Received: by 10.31.41.17 with SMTP id p17mr108513vkp.19.1488909662726;
        Tue, 07 Mar 2017 10:01:02 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.44.99 with SMTP id f90ls1197227otb.24.gmail; Tue, 07 Mar
 2017 10:01:01 -0800 (PST)
X-Received: by 10.157.32.3 with SMTP id n3mr301645ota.1.1488909661723;
        Tue, 07 Mar 2017 10:01:01 -0800 (PST)
In-Reply-To: <CAFdMc-2q3KpV+m5cfWr6b02XmHVUdxsNCNAVFG+mzCv0QY7ZRg@mail.gmail.com>
X-Original-Sender: dan.raviv@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:31496
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/31496>

------=_Part_891_2045239084.1488909661211
Content-Type: multipart/alternative; 
	boundary="----=_Part_892_959834260.1488909661212"

------=_Part_892_959834260.1488909661212
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

+1
It would remove one roadblock to making basic STL math/algorithm functions=
=20
constexpr, since one argument against it is that a non-constexpr=20
implementation might allow for better runtime (when these functions indeed=
=20
run at runtime).

On Monday, March 6, 2017 at 8:15:54 PM UTC+2, dgutson wrote:
>
> I'm proposing the ability to provide two versions of a function,=20
> overloaded by the constexpr specifier: one constexpr version and another=
=20
> non-constexpr version, and let the compiler use the appropriate one=20
> according to the context.
>
> A slightly similar subject has been discussed before (
> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/oxijwTY-ft4/=
discussion=20
> ).
> Additionally, people seems to be interested in detecting constexpr-ness=
=20
> (e.g.=20
> http://stackoverflow.com/questions/15232758/detecting-constexpr-with-sfin=
ae)=20
> to achieve the same "manually".
>
> I'm talking about to make this simpler:
>
> constexpr int f()
> {
>     return 1;
> }
>
> int f()
> {
>     return 2;
> }
>
> constexpr auto a =3D f();    // a =3D 1
> auto fun =3D std::function<int(void)>(f);
> int b =3D fun();   // b =3D 2
>
> If there is some interest, I can star working in a gcc fork as a prototyp=
e.
>
> BRgds,
>
>     Daniel.
>
>
> --=20
> Who=E2=80=99s got the sweetest disposition?
> One guess, that=E2=80=99s who?
> Who=E2=80=99d never, ever start an argument?
> Who never shows a bit of temperament?
> Who's never wrong but always right?
> Who'd never dream of starting a fight?
> Who get stuck with all the bad luck?=20
>
>

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/26e2c972-3c64-4f62-a856-e7490621958e%40isocpp.or=
g.

------=_Part_892_959834260.1488909661212
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">+1<div>It would remove one roadblock to making basic STL m=
ath/algorithm functions constexpr, since one argument against it is that a =
non-constexpr implementation might allow for better runtime (when these fun=
ctions indeed run at runtime).</div><div><br>On Monday, March 6, 2017 at 8:=
15:54 PM UTC+2, dgutson wrote:<blockquote class=3D"gmail_quote" style=3D"ma=
rgin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">=
<div dir=3D"ltr"><div><div>I&#39;m proposing the ability to provide two ver=
sions of a function,=20
overloaded by the constexpr specifier: one constexpr version and another
 non-constexpr version, and let the compiler use the appropriate one=20
according to the context.<br></div><div><br></div>A slightly similar subjec=
t has been discussed before (<a href=3D"https://groups.google.com/a/isocpp.=
org/d/topic/std-proposals/oxijwTY-ft4/discussion" target=3D"_blank" rel=3D"=
nofollow" onmousedown=3D"this.href=3D&#39;https://groups.google.com/a/isocp=
p.org/d/topic/std-proposals/oxijwTY-ft4/discussion&#39;;return true;" oncli=
ck=3D"this.href=3D&#39;https://groups.google.com/a/isocpp.org/d/topic/std-p=
roposals/oxijwTY-ft4/discussion&#39;;return true;">https://groups.google.co=
m/a/<wbr>isocpp.org/d/topic/std-<wbr>proposals/oxijwTY-ft4/<wbr>discussion<=
/a> ).<br></div><div>Additionally, people seems to be interested in detecti=
ng constexpr-ness (e.g. <a href=3D"http://stackoverflow.com/questions/15232=
758/detecting-constexpr-with-sfinae" target=3D"_blank" rel=3D"nofollow" onm=
ousedown=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fst=
ackoverflow.com%2Fquestions%2F15232758%2Fdetecting-constexpr-with-sfinae\x2=
6sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPo3AX-xJYFXlFCYzAupI6x3DTKQ&#39;;ret=
urn true;" onclick=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%=
3A%2F%2Fstackoverflow.com%2Fquestions%2F15232758%2Fdetecting-constexpr-with=
-sfinae\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPo3AX-xJYFXlFCYzAupI6x3DTK=
Q&#39;;return true;">http://stackoverflow.com/<wbr>questions/15232758/detec=
ting-<wbr>constexpr-with-sfinae</a>) to achieve the same &quot;manually&quo=
t;.<br><br></div><div>I&#39;m talking about to make this simpler:<br></div>=
<br><div>constexpr int f()<br>{<br></div><div>=C2=A0=C2=A0=C2=A0 return 1;<=
br></div><div>}<br><br></div><div>int f()<br>{<br></div><div>=C2=A0=C2=A0=
=C2=A0 return 2;<br></div><div>}<br><br></div><div>constexpr auto a =3D f()=
;=C2=A0=C2=A0=C2=A0 // a =3D 1<br></div><div>auto fun =3D std::function&lt;=
int(void)&gt;(f);<br></div><div>int b =3D fun();=C2=A0=C2=A0 // b =3D 2<br>=
<br></div><div><div>If there is some interest, I can star working in a gcc =
fork as a prototype.<br><br></div><div>BRgds,<br><br></div><div>=C2=A0=C2=
=A0=C2=A0 Daniel.<br><br><br></div><div>-- <br><div>Who=E2=80=99s got the s=
weetest disposition?<br>One guess, that=E2=80=99s who?<br>Who=E2=80=99d nev=
er, ever start an argument?<br>Who never shows a bit of temperament?<br>Who=
&#39;s never wrong but always right?<br>Who&#39;d never dream of starting a=
 fight?<br>Who get stuck with all the bad luck? </div>
</div></div><br></div>
</blockquote></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/26e2c972-3c64-4f62-a856-e7490621958e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/26e2c972-3c64-4f62-a856-e7490621958e=
%40isocpp.org</a>.<br />

------=_Part_892_959834260.1488909661212--

------=_Part_891_2045239084.1488909661211--

.
