220 33238 <93d6544c-8e99-4f68-ab84-b355a0ce5ca9@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Erich Keane <erich.keane@verizon.net>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Proposal "is_constexpr"
Date: Mon, 17 Jul 2017 15:27:49 -0700 (PDT)
Lines: 107
Approved: news@gmane.org
Message-ID: <93d6544c-8e99-4f68-ab84-b355a0ce5ca9@isocpp.org>
References: <803a7b14-34c2-4ee6-8c5a-154532143a6e@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1454_174121304.1500330469796"
X-Trace: blaine.gmane.org 1500330474 25277 195.159.176.226 (17 Jul 2017 22:27:54 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 17 Jul 2017 22:27:54 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCWZXNPJO4ION45UZMCRUBFA7HVMQ@isocpp.org Tue Jul 18 00:27:48 2017
Return-path: <std-proposals+bncBCWZXNPJO4ION45UZMCRUBFA7HVMQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qt0-f200.google.com ([209.85.216.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCWZXNPJO4ION45UZMCRUBFA7HVMQ@isocpp.org>)
	id 1dXEUU-000696-CL
	for gclcip-std-proposals@m.gmane.org; Tue, 18 Jul 2017 00:27:46 +0200
Original-Received: by mail-qt0-f200.google.com with SMTP id p25sf1572199qtp.4
        for <gclcip-std-proposals@m.gmane.org>; Mon, 17 Jul 2017 15:27:52 -0700 (PDT)
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
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=23M2CwtyTl36fLPsM3LsJO6mPQMx2b6N/bAO4fsYxos=;
        b=U/1L+sO93YVGo1oQC+jiaQ1l7d9psaJ5+2a7/moMH5wj+8lEx/SmsIjNyUFJTVAkyj
         QFGMA2D75SYpYGCDK/mkrIp2oPIuJMgniY6TrRhDDdXrqRV5ThzyX41GGxL4G1xK6b29
         RXElxZGZDfMHHKXsOnMZm2iuKCQUhJCvZ5onQBpWa6wi4DfgRo4UTv4lPGd+aOMzK0uS
         rRBMccy+yJDVB51PaBUyh8YK9V4vPZ1BQYqfScYrnobmIQ3Gj67MTyiWnavcaiEeg72A
         sTUWXahpNhjxbtb5DhaI80FdfqXYNlKsxMYZTufDUNYzpARHiaXsc62m/QS/9+StBKHf
         6IVQ==
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=23M2CwtyTl36fLPsM3LsJO6mPQMx2b6N/bAO4fsYxos=;
        b=CFl8AwjFZ4tRF9JTmJFXXgHUPFhKDk1hhTF9iMXL7zjA5daBGDb+3c501eQx8N2Ksu
         /FnaSPCh+bjeyZHrdZsSDxMbgmDykbmkKHpA1Ow/Lnket/xDduOWDdDbHbA+gOh6S7rG
         wWYZbQaOnHAaCVPwGPBeOTyOAgO7+EKzXGJiwFw4i0IX3e33yo7n6ptprTWfSroHG5ln
         qqEFGgnlC5ySUJj0DVVs+PHBnSqE9IThGMgrpgWHT2J7zi+R461OKWAY2IQNncBTE+Sj
         amqNeDbooRJlkl0us5WktnqJqjEDmd9W+NmuiXPjJ51ePx0ic7CK+AdIOtzEETSuVxxB
         Y8ow==
X-Gm-Message-State: AIVw1111sgCJNRtRpWRSuj/xGZp1sjrp/p0DcCtZX5pZArW2Bllr51qa
	jDxZw0IoJcaWb04Q
X-Received: by 10.237.33.213 with SMTP id m21mr15821521qtc.88.1500330471590;
        Mon, 17 Jul 2017 15:27:51 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.36.71.72 with SMTP id t69ls6286083itb.0.canary-gmail; Mon, 17
 Jul 2017 15:27:50 -0700 (PDT)
X-Received: by 10.31.153.84 with SMTP id b81mr87711vke.14.1500330470263;
        Mon, 17 Jul 2017 15:27:50 -0700 (PDT)
In-Reply-To: <803a7b14-34c2-4ee6-8c5a-154532143a6e@isocpp.org>
X-Original-Sender: erich.keane@verizon.net
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:33238
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/33238>

------=_Part_1454_174121304.1500330469796
Content-Type: multipart/alternative; 
	boundary="----=_Part_1455_1090816499.1500330469796"

------=_Part_1455_1090816499.1500330469796
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

In Kona, Daveed proposed this:=20
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0595r0.html

it made it through EWG, and seems to accomplish your goal.  Additionally,=
=20
since "is_constexpr" is a compile-time constant, the constant folder level=
=20
of optimization will just 'fix' it for the 'false' case.

BTW: No progress was made by Daveed in Toronto, but no idea if that was on=
=20
purpose, or just a ball dropped.

On Monday, July 17, 2017 at 3:15:53 AM UTC-7, dime...@gmail.com wrote:
>
> =E2=96=A1 Motivation
> In C++, the same semantic functions sometimes have to write two different=
=20
> versions, a constexpr version, an efficient general version.
> For example:
> constexpr auto StrLen(const char *s) {auto tp=3Ds;while(*s) s++;return s-=
tp;}
> auto StrLenSSE4(const char *s){...}
> =E2=96=A1 Proposal
> Gcc has a built-in function __builtin_constant_p (v) to determine whether=
=20
> a value is a compile time constant, but it can only be used for macros, a=
nd=20
> v can only be one literal.
> Can you provide a function of *is_constexpr*(v) to determine whether v is=
=20
> a compile time constant?
> In this way, the function above can use a unified interface.
> constexpr auto StrLen(const char *s){
>   if constexpr(*is_constexpr*(s)) {
>     auto tp=3Ds;while(*s) s++;return s-tp;
>   }
>   else return StrLenSSE4(s);
> }
>

--=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/93d6544c-8e99-4f68-ab84-b355a0ce5ca9%40isocpp.or=
g.

------=_Part_1455_1090816499.1500330469796
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">In Kona, Daveed proposed this: http://www.open-std.org/jtc=
1/sc22/wg21/docs/papers/2017/p0595r0.html<br><br>it made it through EWG, an=
d seems to accomplish your goal.=C2=A0 Additionally, since &quot;is_constex=
pr&quot; is a compile-time constant, the constant folder level of optimizat=
ion will just &#39;fix&#39; it for the &#39;false&#39; case.<br><br>BTW: No=
 progress was made by Daveed in Toronto, but no idea if that was on purpose=
, or just a ball dropped.<br><br>On Monday, July 17, 2017 at 3:15:53 AM UTC=
-7, dime...@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"marg=
in: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><d=
iv dir=3D"ltr"><font color=3D"#000000"><font color=3D"#0000ff">=E2=96=A1 Mo=
tivation</font><br>In C++, the same semantic functions sometimes have to wr=
ite two different versions, a constexpr version, an efficient general versi=
on.<br>For example:<br>constexpr auto StrLen(const char *s) {auto tp=3Ds;wh=
ile(*s) s++;return s-tp;}<br>auto StrLenSSE4(const char *s){...}<br><font c=
olor=3D"#0000ff">=E2=96=A1 Proposal</font><br>Gcc has a built-in function _=
_builtin_constant_p (v) to determine whether a value is a compile time cons=
tant, but it can only be used for macros, and v can only be one literal.<br=
>Can you provide a function of <font color=3D"#000000"><b>is_constexpr</b><=
/font>(v) to determine whether v is a compile time constant?<br>In this way=
, the function above can use a unified interface.<br>constexpr auto StrLen(=
const char *s){<br>=C2=A0 if constexpr(<b>is_constexpr</b>(s)) {<br>=C2=A0=
=C2=A0=C2=A0 auto tp=3Ds;while(*s) s++;return s-tp;<br>=C2=A0 }<br>=C2=A0 e=
lse return StrLenSSE4(s);<br>}</font></div></blockquote></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/93d6544c-8e99-4f68-ab84-b355a0ce5ca9%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/93d6544c-8e99-4f68-ab84-b355a0ce5ca9=
%40isocpp.org</a>.<br />

------=_Part_1455_1090816499.1500330469796--

------=_Part_1454_174121304.1500330469796--

.
