220 39170 <CALmDwq07Aispgz_-pTGix=1vGpF1QupHUFgzw9D0bggGQL5_oQ@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Nicolas Lesser <blitzrakete@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Concepts requires clause should allow types that
 constexpr implicitly convert to bool?
Date: Sun, 15 Jul 2018 11:38:30 +0200
Lines: 134
Approved: news@gmane.org
Message-ID: <CALmDwq07Aispgz_-pTGix=1vGpF1QupHUFgzw9D0bggGQL5_oQ@mail.gmail.com>
References: <79029827-71df-4af1-ae50-607e96c5e322@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="0000000000007b6afa0571067af8"
X-Trace: blaine.gmane.org 1531647398 7908 195.159.176.226 (15 Jul 2018 09:36:38 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 15 Jul 2018 09:36:38 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDXKNLEUTADRBIVMVTNAKGQEKRC6F2I@isocpp.org Sun Jul 15 11:36:34 2018
Return-path: <std-proposals+bncBDXKNLEUTADRBIVMVTNAKGQEKRC6F2I@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f72.google.com ([209.85.218.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDXKNLEUTADRBIVMVTNAKGQEKRC6F2I@isocpp.org>)
	id 1fedSD-0001z5-P3
	for gclcip-std-proposals@m.gmane.org; Sun, 15 Jul 2018 11:36:34 +0200
Original-Received: by mail-oi0-f72.google.com with SMTP id 22-v6sf16342131oix.0
        for <gclcip-std-proposals@m.gmane.org>; Sun, 15 Jul 2018 02:38:44 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1531647524; cv=pass;
        d=google.com; s=arc-20160816;
        b=GBBe9M7MPLHhDHaTaxgUTN8JX7nFn7rbiKfB+OOCYgFtrV/x8KUxzx23XjDGcnI8FX
         Dy+/F0yNVZ+u3RiMt+GU2F64XYAdNV17WRsDy48liWhvHz1VlL1whQCTr2lGKRDgDKe9
         UYIZeFGKgwqs6ekXyj+Z6Avh0gmxcz3PmFHWNWiMsn8Q52KnFfPCDOXWm7dEcQsTJ1L/
         IzOYIIunWMPjZGnNogjT2B3nl/qSYBVv6Pzb/9krCJfLgX0xzCVE05jkLjYen1E5u0AW
         24nV7SHDjXJEwHfZuLBY9+0SGwjTtTZSHTSIEdlu+LvRvS2ok1+Wwr4CpIPBFK6gUBb3
         ZNPg==
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:in-reply-to:references:mime-version:arc-authentication-results
         :arc-message-signature:dkim-signature:arc-authentication-results;
        bh=K7+airUFNs1RH208OlD27jDshq8zZUgkK0mF97w9K+4=;
        b=luvB0ejoZq2zhx/aY4aGkg23c1KKhQ2G3FwZIoUAjAYeHFSx6afWc3qKHTOtqyfjmB
         0wgQIsJe8SIC8L7DEnPXRqx9HB1lMQK8KTZiKcMqCWboFum3lWTqw7jicHoG2oadGY6H
         esak4VM/HUJ/VlbTcNsLjt/VH8tfZvvIJTuX0dn6TEnQ/gv8sTlhFOIMgMRCl6BQPgH2
         lgON+0MhmViAmgpVMKq/xOBRr0fvUpM5z1bwd4ckrH6oIZRZA7JabXsSoGhOFah8keM6
         LjJydAVUnAAfk8NHV8pBQiJUvp86hqZkuXQWpGvJoW3tjAlTNmfHb801c4jCS4awq9C9
         ldZA==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=laM9tUlm;
       spf=pass (google.com: domain of blitzrakete@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=blitzrakete@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE 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:references:in-reply-to: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=K7+airUFNs1RH208OlD27jDshq8zZUgkK0mF97w9K+4=;
        b=I4OhSNCJC9AhF8BrjCAdQ1NjUb5RBj/AITX0eTojNgH5kSoCOjBwJRJsuXo3eKTuX9
         UhRDtjo2dp+FCUezd/7QUBDknX72M5QXn4zgAXgTzpN4fWZLFjYvtsGsjg+15HDCsZkR
         MuXvDgK8e/42ysBNT7aM3IQX1z19Vn/mAvBL/7m6LFaU5BCMkLjLEC4OKXPRVhGLHExm
         w+I73tCsfHKdzR8AWC0vxwrwnm/VefjFmf+I3/2RyKoX4vju7nKvNMBkrvd/qE5YVke8
         E/g/chQj7b0bzEUoU7a/QGUAG03+xZTO+aV4M/P4mdcAP0qiEPX3/inF+AYfqO7z4hgf
         oJhg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:references:in-reply-to: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=K7+airUFNs1RH208OlD27jDshq8zZUgkK0mF97w9K+4=;
        b=PqIwE9fHLkMXTtd6O8iyFeb7XD4/A35U2HBe96SfwPz8MhlT/FwR6nPXzqvmx35oWz
         GjRLFPoXGiTLMSuVlzDTiXi2teQ8/GdO9IfJVz5dSGrQTUUnHeQfAko/YgF5gcNesf+C
         lPUiXp2lOsjD6Nm1rXgGt0Y4Xw1eEg91I9LME7jYt04URWD3xOa9Uq6ZN0neRnRXBOb6
         JPmpYN/1z5choTxBF79ZNQ7bQXg/tXAImvYlMB/FIi6+mu2Q9m9qKHz93emcPSiB+VDb
         MCDwxPKyCy3RTla3Pcv50QEadQOlcYp8UmnPKPSU0pAaThRFGa4nFNxAaLHYLxKA7zw7
         OEHA==
X-Gm-Message-State: AOUpUlGeNksjJJwjfvvyWVDGgrQ5pSChRhO9Kfrw7fg9wkoCIEkffvQT
	KhgyQt7XnqQ34ilFqTuiVIphow==
X-Google-Smtp-Source: AAOMgpda/xT2ZdoCKWgvMnpHO6Bdcig7rQ+enhs3Sjwc1PFuqrlZsQj5ZNdraeGEbvi+hFT0NONppw==
X-Received: by 2002:aca:c042:: with SMTP id q63-v6mr8339900oif.103.1531647523914;
        Sun, 15 Jul 2018 02:38:43 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:aca:c0d4:: with SMTP id q203-v6ls19957784oif.14.gmail; Sun,
 15 Jul 2018 02:38:42 -0700 (PDT)
X-Received: by 2002:aca:dad7:: with SMTP id r206-v6mr13111650oig.271.1531647522751;
        Sun, 15 Jul 2018 02:38:42 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1531647522; cv=none;
        d=google.com; s=arc-20160816;
        b=QXSQ0m8uViuCilb9ueF0VUNLovWviGCpsfwsuFahzkuxCPz2yrx20a6IHAQ0vF9dvW
         TqNZnk02LeyhP3sc9Ig4S+32csp4CJETczjDh0U+xsFXYDAsvRApICyMpr9dkfnCJwrP
         hQu2DyRiakaYOi040L2ophEfGw6xEOvtTN6jzH0bMkX3ebjO6zdjUT1x/37NZOkDfJZQ
         NzuuQwXV9tpx1rHLT4YCDHjyyIjKDfnkLdA7+xalrDco5juCFmgeXl5i/UYtn1Va8nGd
         fHUjkq3iEhCjLhuwa79VkjgZpwK7f/zEze3b3R5vGGxUACcIRhNb2e2cOFad7IdHYH0j
         1kKg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:in-reply-to:references:mime-version
         :dkim-signature:arc-authentication-results;
        bh=+nZNajx977f5tmpedks+mx1Jq8iTdCa1moPkaR2FXzk=;
        b=M5lfj8twrJA7RYcFcex4lEK3z2xBcXMIQYg80HycR6Z6t0uz88g+1NJk+m5yM8uK1S
         F4REyPBCaFWJX1dk9W03sjQG/PWlnN2c5hrYfGWZCb8MbrC77d7vjfSFTO2kd/MIA05J
         YUV2yfhRBvdsKGeICx4RV069dVk4GnC0C3/Pgh60JVWJQb6VT3mvdrXd9DiTwNrYgNLm
         gaMDDnxiQpyfo9CXiWunlKjz/VhRh9FsMLVMBguIeAk5il3b2PiLqDmLzI+hrf9ZcEeo
         s2gIAipJ/gqh/oSsqyfZnO+EAgBCXs7S80arJzBzEzpJ8wKrKMqUUkb0aVtIW1XB04HB
         UH8g==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=laM9tUlm;
       spf=pass (google.com: domain of blitzrakete@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=blitzrakete@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id d89-v6sor17401334oic.136.2018.07.15.02.38.42
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Sun, 15 Jul 2018 02:38:42 -0700 (PDT)
Received-SPF: pass (google.com: domain of blitzrakete@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 2002:aca:5155:: with SMTP id f82-v6mr14374204oib.272.1531647522202;
 Sun, 15 Jul 2018 02:38:42 -0700 (PDT)
In-Reply-To: <79029827-71df-4af1-ae50-607e96c5e322@isocpp.org>
X-Original-Sender: blitzrakete@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=laM9tUlm;       spf=pass
 (google.com: domain of blitzrakete@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=blitzrakete@gmail.com;       dmarc=pass
 (p=NONE sp=QUARANTINE 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-Spam-Checked-In-Group: 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:39170
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/39170>

--0000000000007b6afa0571067af8
Content-Type: text/plain; charset="UTF-8"

Yes, this is intended. See [temp.constr.atomic]p3.

And I agree that any type implicitly convertible to bool should be allowed.

On Sun, Jul 15, 2018, 2:31 AM <toby.brull@gmail.com> wrote:

> Apologies, if this is off-topic.
>
> It seems that the following doesn't compile in all versions of gcc that I
> tried (7.2, 8.1, 9.0). It complains that the type of the value in the
> "requires" clause is not bool, although the value is implicitly constexpr
> convertible to bool.
>
>
> template<typename T, T v>
> constexpr auto is_even (std::integral_constant<T, v> = {})
> {
>   return std::bool_constant<(v % 2 == 0)> {};
> }
>
> template<typename T, T v>
>   requires is_even (std::integral_constant<T, v> {})  // (*)
> int some_function ()
> {
>   return (v * 3);
> }
>
> int main ()
> {
>   std::cout << some_function<int, 4> () << '\n';
> }
>
>
> Workarounds are, of course, to append "()" or to prepend "!!" to the line
> marked with (*), but might be better without? If this is not a bug in gcc,
> I hoped someone would be able to make that change easily at this point.
>
> --
> 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/79029827-71df-4af1-ae50-607e96c5e322%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/79029827-71df-4af1-ae50-607e96c5e322%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CALmDwq07Aispgz_-pTGix%3D1vGpF1QupHUFgzw9D0bggGQL5_oQ%40mail.gmail.com.

--0000000000007b6afa0571067af8
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto"><div>Yes, this is intended. See [temp.constr.atomic]p3.</=
div><div dir=3D"auto"><br></div><div dir=3D"auto">And I agree that any type=
 implicitly convertible to bool should be allowed.</div><div dir=3D"auto"><=
br><div class=3D"gmail_quote" dir=3D"auto"><div dir=3D"ltr">On Sun, Jul 15,=
 2018, 2:31 AM  &lt;<a href=3D"mailto:toby.brull@gmail.com">toby.brull@gmai=
l.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"lt=
r"><div>Apologies, if this is off-topic.</div><div><br></div><div>It seems =
that the following doesn&#39;t compile in all versions of gcc that I tried =
(7.2, 8.1, 9.0). It complains that the type of the value in the &quot;requi=
res&quot; clause is not bool, although the value is implicitly constexpr co=
nvertible to bool.</div><div><br></div><div><br></div><blockquote style=3D"=
margin:0 0 0 40px;border:none;padding:0px"><div><font face=3D"courier new, =
monospace">template&lt;typename T, T v&gt;</font></div><div><font face=3D"c=
ourier new, monospace">constexpr auto is_even (std::integral_constant&lt;T,=
 v&gt; =3D {})</font></div><div><font face=3D"courier new, monospace">{</fo=
nt></div><div><font face=3D"courier new, monospace">=C2=A0 return std::bool=
_constant&lt;(v % 2 =3D=3D 0)&gt; {};</font></div><div><font face=3D"courie=
r new, monospace">}</font></div><div><font face=3D"courier new, monospace">=
<br></font></div><div><font face=3D"courier new, monospace">template&lt;typ=
ename T, T v&gt;</font></div><div><font face=3D"courier new, monospace">=C2=
=A0 requires is_even (std::integral_constant&lt;T, v&gt; {})=C2=A0 // (*)</=
font></div><div><font face=3D"courier new, monospace">int some_function ()<=
/font></div><div><font face=3D"courier new, monospace">{</font></div><div><=
font face=3D"courier new, monospace">=C2=A0 return (v * 3);</font></div><di=
v><font face=3D"courier new, monospace">}</font></div><div><font face=3D"co=
urier new, monospace"><br></font></div><div><font face=3D"courier new, mono=
space">int main ()</font></div><div><font face=3D"courier new, monospace">{=
</font></div><div><font face=3D"courier new, monospace">=C2=A0 std::cout &l=
t;&lt; some_function&lt;int, 4&gt; () &lt;&lt; &#39;\n&#39;;</font></div><d=
iv><font face=3D"courier new, monospace">}</font></div></blockquote><div><b=
r></div><div>Workarounds are, of course, to append &quot;()&quot; or to pre=
pend &quot;!!&quot; to the line marked with (*), but might be better withou=
t? If this is not a bug in gcc, I hoped someone would be able to make that =
change easily at this point.</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" target=3D"_=
blank" rel=3D"noreferrer">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank" rel=3D"noreferrer">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/79029827-71df-4af1-ae50-607e96c5e322%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank" =
rel=3D"noreferrer">https://groups.google.com/a/isocpp.org/d/msgid/std-propo=
sals/79029827-71df-4af1-ae50-607e96c5e322%40isocpp.org</a>.<br>
</blockquote></div></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/CALmDwq07Aispgz_-pTGix%3D1vGpF1QupHUF=
gzw9D0bggGQL5_oQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALmDwq07Aispgz=
_-pTGix%3D1vGpF1QupHUFgzw9D0bggGQL5_oQ%40mail.gmail.com</a>.<br />

--0000000000007b6afa0571067af8--

.
