220 33234 <CAAE_HdJWNqFYUJvCDGGXE4oYF6vhVd5iFY3atKPjtH9pNRrAqg@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Daemon Snake <swac31@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Proposal "is_constexpr"
Date: Mon, 17 Jul 2017 17:13:42 +0200
Lines: 132
Approved: news@gmane.org
Message-ID: <CAAE_HdJWNqFYUJvCDGGXE4oYF6vhVd5iFY3atKPjtH9pNRrAqg@mail.gmail.com>
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/alternative; boundary="001a113f73d863d2cb055484d982"
X-Trace: blaine.gmane.org 1500304447 31968 195.159.176.226 (17 Jul 2017 15:14:07 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 17 Jul 2017 15:14:07 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCX2P6W5SEDBBPFIWPFQKGQE3IYLNYY@isocpp.org Mon Jul 17 17:14:02 2017
Return-path: <std-proposals+bncBCX2P6W5SEDBBPFIWPFQKGQE3IYLNYY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yw0-f199.google.com ([209.85.161.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCX2P6W5SEDBBPFIWPFQKGQE3IYLNYY@isocpp.org>)
	id 1dX7ih-0007ys-Vz
	for gclcip-std-proposals@m.gmane.org; Mon, 17 Jul 2017 17:14:00 +0200
Original-Received: by mail-yw0-f199.google.com with SMTP id z21sf110890570ywz.2
        for <gclcip-std-proposals@m.gmane.org>; Mon, 17 Jul 2017 08:14:05 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1500304445; cv=pass;
        d=google.com; s=arc-20160816;
        b=LlOIIfDNe4kEviJpGzP1V5jr0gYjehP1tbre6IIHVuGBvQHQwhP8hZgB99y4Orz30H
         ECHL3KdiMc7F5+DeKKVQ9ysob/sBQqhBT2xLQxI6wnYRZWUEK2y5Zgh1ehJ7Po8H/q4a
         W6O+3s3uVNbjtbNNe8DnavIDLov/agwJchF8tXNXyHIGqsRODgZ4TQtkiY0aYk0YoLnu
         pV7YUdvLhA3GCU8poLWphB/SbljUhRenlJdwHJIOmACIouGS/2tIUnyrTVMYApNVTUxT
         VqSd5om2PA36yHbya2shrk+zjAX7xhp1nf+GNR+uPZiA9mJVn4FKNBWkMZutr6Rm9DMy
         7lrQ==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:references:in-reply-to:mime-version:arc-authentication-results
         :arc-message-signature:dkim-signature:arc-authentication-results;
        bh=SzKmQjwTj9PQrgPtaePV2ypcjkxdL78h6uyvThPCXOk=;
        b=ISPwurl7FH4T25QGILcBQbtevSl02oUQ+o/Q6jg4E9mek/l/oBwpT5cajP3WJQbGgF
         0170RVwHm2+Xg6sYJ479RXZTxWPidCor8fmQ/F6txciia0pmWd2yaGASyRWeSbFdd8Gq
         bmRTMKHu5q9MyJI8MQTro26ZAjaEHPuC0jLRhgV/LJjDi6vVRkqTvjTG2MOcsB3A32xm
         lYMLDtw8cvDbwm2ozMNue7ebqcTFKsifkYc4fpyb8yB8h+gjXL43PLmaGfmMZE/vwj21
         QJ8Kxwdc+HtqOr/REM78sC7F98nFwkJlra07R6rBSwT4pKssSSkhi0v9zjBlv/tkyqV2
         s4WA==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.b=FRtHxml0;
       spf=pass (google.com: domain of swac31@gmail.com designates 2607:f8b0:4002:c05::244 as permitted sender) smtp.mailfrom=swac31@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=SzKmQjwTj9PQrgPtaePV2ypcjkxdL78h6uyvThPCXOk=;
        b=pQuDAsmXopiKQTMBKwRyc5vzrQz1vfWYvQ/Na2gjuutkJzifv+QuEH6HdnTFnDDaWr
         OcKfrVUn55iMOCMDd2qvAGys+HQgzGoyuq9wezaNHUVknC/cfSOEf4bGp7F7ykUyFwq0
         ufECmuxmFAaRpViRY+hG03uhJN7i1aPMusbGhYTy3SMEIIOL0gtBadtK69VvW5HohT2z
         cFD52+6gVDEpnxjHs4eS/0Ci9StY7bX0LvtVhsBiuS6AfQvVUk06HcuMS9+p689NPfCv
         k47AEzEXbMzOqnRs0PnqkEYMqtIN3N+ydJ8Vigvw+gtbJHm/8eLOYT7uR7suAlF6lw//
         IH2g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=SzKmQjwTj9PQrgPtaePV2ypcjkxdL78h6uyvThPCXOk=;
        b=PAzJ1c2kF9FjqHg0lpvXxqA9V20Lsy41jpdKjQINjMUMMztPhB82k/m0jBYNNhN7KF
         rvFI5oDa0chFmAuUMjxvylqjYg+Pn2OVKlPfuW0HrAidiFGs2nqmYWolROhuySmWrPa1
         tXTazuxGUyu0uqqzZjJShQgU+6zfUGKn/L/o8dL0G5MPYI1e6KLM8Bh0I5NJxt9NBdL3
         508qtR0AHR6DbqGBo65kMZziLeW+ZacjWV0bZ/gt3nIkr7X25ZALRSZSpJl87zbdtky9
         h6gUzTCGjiGV4HGxibLm56mDHpL3EOFXDSlAMm1FaiQjP7zKiUoJDUcfOzz6nCyO8Htx
         56sg==
X-Gm-Message-State: AIVw110zIsB3tP6SoPAxj4SVs3vLGPIafgCtB3rm4cpqpMsOEPciF9TE
	rOWLlVfF7QNSVfZw
X-Received: by 10.129.202.18 with SMTP id p18mr15457322ywi.157.1500304445276;
        Mon, 17 Jul 2017 08:14:05 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.36.1.211 with SMTP id 202ls3465210itk.12.canary-gmail; Mon, 17
 Jul 2017 08:14:03 -0700 (PDT)
X-Received: by 10.37.212.85 with SMTP id m82mr6961243ybf.99.1500304443796;
        Mon, 17 Jul 2017 08:14:03 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1500304443; cv=none;
        d=google.com; s=arc-20160816;
        b=ggdXsmzi07Jrcw+YXT207Bot3kAnBISgDwlnymyBJDs3XMDZ4ysSv3HpgeSrIMdi3M
         3gsJrDfXOCRUP6Z4ZppFaHf73XEvae2ucUzVUJuKobEu+KioH78oB+JhapAAJ3GZR6WB
         /AQttY5T/tyaG+FDGnFbMlZ4RZ5ucJlWhLaAw9UEynDISWIrrEbTD7yHnwxlQXb7c8QX
         43eCYD/nyEvC+Nwes+vr1Mndmv6kLZ/SCfgR4nveuP5zmxyoMbZKr83+eolSr0uzm94K
         2kry7NZMu8rmnJblD0JfExSy1fNaNx0Gtgh2V3UCL0iCH+eQuF75IkHmUk8NsuynsHJZ
         V3AQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:references:in-reply-to:mime-version
         :dkim-signature:arc-authentication-results;
        bh=YPCwkWa/x1dIIUNdkt2s8rllox+AKl7Jx5Pid/rYCr4=;
        b=NkLpO5uSD5z/oxaIwAR2CIUqCHU2N7E0C0B0TZ/nvLh/WljChKsBsRL8z5pzGebL/R
         fGpNlSm+VIPRTZqdIUYbNosX6DVdUXnfNkkhmkNRfKcjTiZ19KifRaxGnWtcDdvYutth
         ZJO/N/0MMrbesaBQ93ESfxHXawWf4kftfaT3wvc6/yjZMm0gML/7b6S3EvPtEu4KmVNU
         gNuQm9+0hWSsu2GsnehOl+buOTFOV7apz/dwBkbzT/XRTyZAB7Vz9Fc/2u8U/7oYc7OW
         jMYjdAYiuBsKFD+UaMVjKg3GKeqHk20oVUT39nOqdKWL7PJm+BUAv/2T7+44VvAyQdFo
         E/5g==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.b=FRtHxml0;
       spf=pass (google.com: domain of swac31@gmail.com designates 2607:f8b0:4002:c05::244 as permitted sender) smtp.mailfrom=swac31@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Original-Received: from mail-yw0-x244.google.com (mail-yw0-x244.google.com. [2607:f8b0:4002:c05::244])
        by mx.google.com with ESMTPS id x5si3487234ybd.449.2017.07.17.08.14.03
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 17 Jul 2017 08:14:03 -0700 (PDT)
Received-SPF: pass (google.com: domain of swac31@gmail.com designates 2607:f8b0:4002:c05::244 as permitted sender) client-ip=2607:f8b0:4002:c05::244;
Original-Received: by mail-yw0-x244.google.com with SMTP id v193so2928553ywg.0
        for <std-proposals@isocpp.org>; Mon, 17 Jul 2017 08:14:03 -0700 (PDT)
X-Received: by 10.129.94.198 with SMTP id s189mr17841303ywb.335.1500304443145;
 Mon, 17 Jul 2017 08:14:03 -0700 (PDT)
Original-Received: by 10.37.87.4 with HTTP; Mon, 17 Jul 2017 08:13:42 -0700 (PDT)
In-Reply-To: <803a7b14-34c2-4ee6-8c5a-154532143a6e@isocpp.org>
X-Original-Sender: swac31@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.b=FRtHxml0;       spf=pass (google.com: domain of
 swac31@gmail.com designates 2607:f8b0:4002:c05::244 as permitted sender)
 smtp.mailfrom=swac31@gmail.com;       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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:33234
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/33234>

--001a113f73d863d2cb055484d982
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi,

is_constexp(s) is not possible, nor likely currently as function arguments
are never constexpr.
The subject is highly controversial (possible ODR violations, etc...).
Read this discussion:
https://groups.google.com/a/isocpp.org/forum/?fromgroups#!search/is_constex=
pr/std-proposals/NErPRYCz3ZU/AOcjouU8BAAJ




2017-07-17 12:15 GMT+02:00 <dimeiyi24@gmail.com>:

> =E2=96=A1 Motivation
> In C++, the same semantic functions sometimes have to write two different
> 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
> a value is a compile time constant, but it can only be used for macros, a=
nd
> v can only be one literal.
> Can you provide a function of *is_constexpr*(v) to determine whether v is
> 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);
> }
>
> --
> 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
> email 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/803a7b14-34c2-4ee6-
> 8c5a-154532143a6e%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/803a7b14-34=
c2-4ee6-8c5a-154532143a6e%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>
> .
>

--=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/CAAE_HdJWNqFYUJvCDGGXE4oYF6vhVd5iFY3atKPjtH9pNRr=
Aqg%40mail.gmail.com.

--001a113f73d863d2cb055484d982
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi,</div><div><br></div>is_constexp(s) is not possibl=
e, nor likely currently as function arguments are never constexpr.<div>The =
subject is highly controversial (possible ODR violations, etc...).</div><di=
v>Read this discussion: <a href=3D"https://groups.google.com/a/isocpp.org/f=
orum/?fromgroups#!search/is_constexpr/std-proposals/NErPRYCz3ZU/AOcjouU8BAA=
J">https://groups.google.com/a/isocpp.org/forum/?fromgroups#!search/is_cons=
texpr/std-proposals/NErPRYCz3ZU/AOcjouU8BAAJ</a></div><div><div><br></div><=
div><br></div><div><div><br></div></div></div></div><div class=3D"gmail_ext=
ra"><br><div class=3D"gmail_quote">2017-07-17 12:15 GMT+02:00  <span dir=3D=
"ltr">&lt;<a href=3D"mailto:dimeiyi24@gmail.com" target=3D"_blank">dimeiyi2=
4@gmail.com</a>&gt;</span>:<br><blockquote class=3D"gmail_quote" style=3D"m=
argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"l=
tr"><font color=3D"#000000"><font color=3D"#0000ff">=E2=96=A1 Motivation</f=
ont><br>In C++, the same semantic functions sometimes have to write two dif=
ferent versions, a constexpr version, an efficient general version.<br>For =
example:<br>constexpr auto StrLen(const char *s) {auto tp=3Ds;while(*s) s++=
;return s-tp;}<br>auto StrLenSSE4(const char *s){...}<br><font color=3D"#00=
00ff">=E2=96=A1 Proposal</font><br>Gcc has a built-in function __builtin_co=
nstant_p (v) to determine whether a value is a compile time constant, but i=
t can only be used for macros, and v can only be one literal.<br>Can you pr=
ovide a function of <font color=3D"#000000"><strong>is_constexpr</strong></=
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(c=
onst char *s){<br>=C2=A0 if constexpr(<strong>is_constexpr</strong>(s)) {<b=
r>=C2=A0=C2=A0=C2=A0 auto tp=3Ds;while(*s) s++;return s-tp;<br>=C2=A0 }<br>=
=C2=A0 else return StrLenSSE4(s);<br>}</font></div><span class=3D"HOEnZb"><=
font color=3D"#888888">

<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" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">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/803a7b14-34c2-4ee6-8c5a-154532143a6e%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/803a=
7b14-34c2-4ee6-<wbr>8c5a-154532143a6e%40isocpp.org</a><wbr>.<br>
</font></span></blockquote></div><br></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/CAAE_HdJWNqFYUJvCDGGXE4oYF6vhVd5iFY3a=
tKPjtH9pNRrAqg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAAE_HdJWNqFYUJvC=
DGGXE4oYF6vhVd5iFY3atKPjtH9pNRrAqg%40mail.gmail.com</a>.<br />

--001a113f73d863d2cb055484d982--

.
