220 39176 <0f77fb8d-5058-47e9-b1ec-519958786893@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Arthur O'Dwyer <arthur.j.odwyer@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 15:44:52 -0700 (PDT)
Lines: 183
Approved: news@gmane.org
Message-ID: <0f77fb8d-5058-47e9-b1ec-519958786893@isocpp.org>
References: <79029827-71df-4af1-ae50-607e96c5e322@isocpp.org>
 <CALmDwq07Aispgz_-pTGix=1vGpF1QupHUFgzw9D0bggGQL5_oQ@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_159664_1388953426.1531694692616"
X-Trace: blaine.gmane.org 1531694569 19203 195.159.176.226 (15 Jul 2018 22:42:49 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 15 Jul 2018 22:42:49 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDLZJYWNDQIOLHFP3ICRUBBVCHRTU@isocpp.org Mon Jul 16 00:42:45 2018
Return-path: <std-proposals+bncBDLZJYWNDQIOLHFP3ICRUBBVCHRTU@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yb0-f198.google.com ([209.85.213.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDLZJYWNDQIOLHFP3ICRUBBVCHRTU@isocpp.org>)
	id 1fepj1-0004tm-VD
	for gclcip-std-proposals@m.gmane.org; Mon, 16 Jul 2018 00:42:44 +0200
Original-Received: by mail-yb0-f198.google.com with SMTP id t14-v6sf21231005ybb.0
        for <gclcip-std-proposals@m.gmane.org>; Sun, 15 Jul 2018 15:44:55 -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=kfhFf0xO0C3ORfuznVjRU5csuKXgE5Q5PFlDPCYZJPM=;
        b=Vur39vNCoO1HybIUl8fCSuqL7pkRy2B50SstPT0sHiI3iMNsKGUsIVN1Wx3BIo7l9/
         jPomWqaVU1LPpVaymm/91FaZby6Q3rcX/vY7NSe1vkKFG9JwDslrsyncAI7lb4vimJ6Y
         FOb2w7SBQmeS4BUoHGTYanZq7PCPqs+VrFY21suLA+111JvwNdxD7L4lfiJx+uhNS9hA
         Q6th7OMwEnBmvK8IIofY//4iPxP34uMfwHwqVUiOH5/1ZuR6tY0N9N8Bkhesp8N1NtWD
         s3i5w3NTdu6/xEkJ2rdAhgVv+LKKDN1jDOMLSw6Zvs0qiE3QIew9+ojanA2hAzepvwMC
         wKxQ==
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
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=kfhFf0xO0C3ORfuznVjRU5csuKXgE5Q5PFlDPCYZJPM=;
        b=W13vlc6bMJMvoA3aI03R7O1j+HZ6XqkpoW2YUMOc5VoyvSpwKNUZi0oiTbgYwmoqij
         kurWsEIUU9Hd40pkqeYMY2MdA7ee3fQAaBl6RgPai9KgKNeIUI1yXyTEDfCsMz6GzogI
         k+wjiH9KrC0VxeEIP4p0i9L8oiLCCEXUiylhdomhxqfvaxTfeY6CCzxpDFa2e+bKsJ5S
         Q0PvdiRgc3lAJ+ZXyqO1B9E5K3CSTCMR3DhMZvpKrrXRulX4TqhoPSoNpc7Y9afqLtWF
         7lSvcbGyICZZR7d3f1yzGRMcrJB9J7OMbjR9bvDYgoaax4F6twIUzpGGeVRqg4YT4Dj5
         2K8Q==
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=kfhFf0xO0C3ORfuznVjRU5csuKXgE5Q5PFlDPCYZJPM=;
        b=graJ/ynE0XbNkct6XvykPPwKI/jh91qa8vJq8agMvCCsYahuqg5nLsocjZTuItC1pa
         Z95T4TFQ/iczLnDs7jc/6Q/A46ElwQqW9nWqAguX42Zi8NgQiFv9e2+qyxtJLpYZUw+N
         dSnEta+NvC0kWCi8Bqi/66zbS+cG1DTnoeI6ub558zrhMrKk4v4AeSz4Kffa4dFxf9+E
         O03m5VnJEKYsUZbuhTtR+hOeB5xPrH4HMDAfaTLITDLYTKGHYOZXdwCGQKf2NzRu6mWC
         R8SQLjHhOBkidkCMuh099x2P32e70YmbkRRHfQD11SVoWefZm1ZVmuGCWvJJw/AEPy+Y
         dkwA==
X-Gm-Message-State: AOUpUlHNa44qvZFGkO9W4RoneLgRfmMhYUXvsTeFTqG6+OyLn37+SzX/
	UbHu78HLxiBJQIBdowSyw4Wdvw==
X-Google-Smtp-Source: AAOMgpcaJuSqffzvv/yvzXzOPoh1+txWHhbsRNx0lrjDOhBjok0dOWk5e+kMog/jCtJFBlrUx0oNxg==
X-Received: by 2002:a81:6e08:: with SMTP id j8-v6mr4532347ywc.149.1531694694537;
        Sun, 15 Jul 2018 15:44:54 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a25:8008:: with SMTP id m8-v6ls3026297ybk.11.gmail; Sun, 15
 Jul 2018 15:44:53 -0700 (PDT)
X-Received: by 2002:a25:c5d2:: with SMTP id v201-v6mr1793130ybe.4.1531694693256;
        Sun, 15 Jul 2018 15:44:53 -0700 (PDT)
In-Reply-To: <CALmDwq07Aispgz_-pTGix=1vGpF1QupHUFgzw9D0bggGQL5_oQ@mail.gmail.com>
X-Original-Sender: arthur.j.odwyer@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:39176
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/39176>

------=_Part_159664_1388953426.1531694692616
Content-Type: multipart/alternative; 
	boundary="----=_Part_159665_1521112249.1531694692616"

------=_Part_159665_1521112249.1531694692616
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Another easy workaround would be to change the word `auto` to `bool`.
I would expect requires(x) to follow exactly the same rules as noexcept(x).=
=20
If it doesn't, that's a bug in my book.

=E2=80=93Arthur

On Sunday, July 15, 2018 at 2:38:44 AM UTC-7, Nicolas Lesser wrote:
>
> Yes, this is intended. See [temp.constr.atomic]p3.
>
> And I agree that any type implicitly convertible to bool should be allowe=
d.
>
> On Sun, Jul 15, 2018, 2:31 AM <toby....@gmail.com <javascript:>> wrote:
>
>> Apologies, if this is off-topic.
>>
>> It seems that the following doesn't compile in all versions of gcc that =
I=20
>> tried (7.2, 8.1, 9.0). It complains that the type of the value in the=20
>> "requires" clause is not bool, although the value is implicitly constexp=
r=20
>> convertible to bool.
>>
>>
>> template<typename T, T v>
>> constexpr auto is_even (std::integral_constant<T, v> =3D {})
>> {
>>   return std::bool_constant<(v % 2 =3D=3D 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 lin=
e=20
>> marked with (*), but might be better without? If this is not a bug in gc=
c,=20
>> I hoped someone would be able to make that change easily at this point.
>>
>> --=20
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=20
>> email to std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> To view this discussion on the web visit=20
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/79029827-71=
df-4af1-ae50-607e96c5e322%40isocpp.org=20
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/79029827-7=
1df-4af1-ae50-607e96c5e322%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoo=
ter>
>> .
>>
>

--=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/0f77fb8d-5058-47e9-b1ec-519958786893%40isocpp.or=
g.

------=_Part_159665_1521112249.1531694692616
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Another easy workaround would be to change the word `auto`=
 to `bool`.<div>I would expect requires(x) to follow exactly the same rules=
 as noexcept(x). If it doesn&#39;t, that&#39;s a bug in my book.</div><div>=
<br></div><div>=E2=80=93Arthur<br><br>On Sunday, July 15, 2018 at 2:38:44 A=
M UTC-7, Nicolas Lesser 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"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"javascript:" target=3D"_blank" gdf-obfuscate=
d-mailto=3D"Q1Rr0d7kCQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;=
javascript:&#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;=
;return true;">toby....@gmail.com</a>&gt; wrote:<br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex"><div dir=3D"ltr"><div>Apologies, if this is off-topic.</div><=
div><br></div><div>It seems that the following doesn&#39;t compile in all v=
ersions of gcc that I tried (7.2, 8.1, 9.0). It complains that the type of =
the value in the &quot;requires&quot; clause is not bool, although the valu=
e is implicitly constexpr convertible 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;</fon=
t></div><div><font face=3D"courier new, monospace">constexpr auto is_even (=
std::integral_constant&lt;T, v&gt; =3D {})</font></div><div><font face=3D"c=
ourier new, monospace">{</font></div><div><font face=3D"courier new, monosp=
ace">=C2=A0 return std::bool_constant&lt;(v % 2 =3D=3D 0)&gt; {};</font></d=
iv><div><font face=3D"courier new, monospace">}</font></div><div><font face=
=3D"courier new, monospace"><br></font></div><div><font face=3D"courier new=
, monospace">template&lt;typename 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, mono=
space">int some_function ()</font></div><div><font face=3D"courier new, mon=
ospace">{</font></div><div><font face=3D"courier new, monospace">=C2=A0 ret=
urn (v * 3);</font></div><div><font face=3D"courier new, monospace">}</font=
></div><div><font face=3D"courier new, monospace"><br></font></div><div><fo=
nt face=3D"courier new, monospace">int main ()</font></div><div><font face=
=3D"courier new, monospace">{</font></div><div><font face=3D"courier new, m=
onospace">=C2=A0 std::cout &lt;&lt; some_function&lt;int, 4&gt; () &lt;&lt;=
 &#39;\n&#39;;</font></div><div><font face=3D"courier new, monospace">}</fo=
nt></div></blockquote><div><br></div><div>Workarounds are, of course, to ap=
pend &quot;()&quot; or to prepend &quot;!!&quot; to the line marked with (*=
), but might be better without? If this is not a bug in gcc, I hoped someon=
e 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"javascript:" rel=3D"nofollow" target=3D"_blank" gdf-obfu=
scated-mailto=3D"Q1Rr0d7kCQAJ" onmousedown=3D"this.href=3D&#39;javascript:&=
#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true=
;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" rel=3D"nofollo=
w" target=3D"_blank" gdf-obfuscated-mailto=3D"Q1Rr0d7kCQAJ" onmousedown=3D"=
this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39=
;javascript:&#39;;return true;">std-pr...@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" rel=3D"nofollow" t=
arget=3D"_blank" onmousedown=3D"this.href=3D&#39;https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/79029827-71df-4af1-ae50-607e96c5e322%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" on=
click=3D"this.href=3D&#39;https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/79029827-71df-4af1-ae50-607e96c5e322%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/79029827-71df-4af1-<wbr>ae50-=
607e96c5e322%40isocpp.org</a><wbr>.<br>
</blockquote></div></div></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/0f77fb8d-5058-47e9-b1ec-519958786893%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0f77fb8d-5058-47e9-b1ec-519958786893=
%40isocpp.org</a>.<br />

------=_Part_159665_1521112249.1531694692616--

------=_Part_159664_1388953426.1531694692616--

.
