220 39168 <79029827-71df-4af1-ae50-607e96c5e322@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: toby.brull@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Concepts requires clause should allow types that
 constexpr implicitly convert to bool?
Date: Sat, 14 Jul 2018 17:31:00 -0700 (PDT)
Lines: 97
Approved: news@gmane.org
Message-ID: <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/mixed; 
	boundary="----=_Part_134683_1546255666.1531614660505"
X-Trace: blaine.gmane.org 1531614537 6329 195.159.176.226 (15 Jul 2018 00:28:57 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 15 Jul 2018 00:28:57 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCSZVKUG2IJRBRNLVLNAKGQEDNT6YUQ@isocpp.org Sun Jul 15 02:28:53 2018
Return-path: <std-proposals+bncBCSZVKUG2IJRBRNLVLNAKGQEDNT6YUQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yw0-f200.google.com ([209.85.161.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCSZVKUG2IJRBRNLVLNAKGQEDNT6YUQ@isocpp.org>)
	id 1feUuB-0001YG-Vj
	for gclcip-std-proposals@m.gmane.org; Sun, 15 Jul 2018 02:28:52 +0200
Original-Received: by mail-yw0-f200.google.com with SMTP id p8-v6sf1151846ywl.14
        for <gclcip-std-proposals@m.gmane.org>; Sat, 14 Jul 2018 17:31:03 -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:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=fWLeiWKD1XysH4A4Sl1rdNLM8GexYBFVu+mY3+toKhs=;
        b=kRefM4d/7PnO8S5hR6eXZQjwTXJQwhhfwXtijsIr1oU/XMj++PwuYigJCOdRysIKky
         A/ANp7UBpqC7Uiipb3hobUmJeaSfaBEqA4KpKqdYI2GuqYxpnZxdS/2Eg2W+3XkiXPFq
         ccJ6LaNI5ZODD35rSo+I0gEtDZAAmd72lI3Wjdie74uU+JCgR/gR6xUbNSJoR8hD/COh
         XzukHu7EiPdFIJ5o43/UwXBN4pZ0CjtWHEc/NKGCZVZcPCYBClvmtf9LbhBbaT25/tJx
         UouS2tUbnWiaS/eQ6Cnt2a4H1PwHWjbd8KBGsZRDNzGC+okaR3Yt+rkw+cJS/AyhBZhX
         1y8g==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=fWLeiWKD1XysH4A4Sl1rdNLM8GexYBFVu+mY3+toKhs=;
        b=AYcG/aOycyTcgVeh0SVxPsWMY3SRGRbmoaGWa7W9vUGi/i2Xj7ZchyYR2YCm7OHB4c
         Tqt4OTOhe3iUR7OVI0BGHPibA68d9cDwtFBdRI5JhfsOYQJZwtWoFuo06zKRDdTbNBEJ
         B2W963FBVwaN22IxheSXTsK1lE8B4MYlXg2tsArZauNZUs3xOwyEBAmNkkrnG9q4uybv
         PPBAPp6xiH8ztBB5YGw3jFeSqRhgSegiYv0F473Y4dv9Eu/totnOr1kMMvb9wUSidit3
         j+7zfslQY6rtB94wPGF8mqeO8B5KZq6nzahRQkH6D26ayRIMdicGtSo/dOilA/q0PqQE
         qb9Q==
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: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=fWLeiWKD1XysH4A4Sl1rdNLM8GexYBFVu+mY3+toKhs=;
        b=c6/ahVVHksA1bBMkq4hRvSrrSnSrwkvPYyzEJZtuNMb1UR4w7vJLlVg5kD8FvaAQYd
         xxcXQO0sGOYOOS36LogYYmLTgk+r79QYbLGveED7vVbmipMp/72EZ7izldSaxu5opWSy
         FlkxwhDtW4G88cBWZ6DUXosHiSVrp3NEYIC75Rwg3v9c/y17OtW0s9DIyA5eQ/rlw0WW
         QruZqZPdw1L3x1RWb97pmCKfRj1dbjQMTlyDPqb3Kex+K2AgNo9Q0wSFn6NSUIMMwCBM
         Wbmz92D0+V0j5D06sRY0ihAQl7d3e05Hgqt0I3Fhlepci9sh5hW/d8Vg/2gxnk/1yiVo
         jE8g==
X-Gm-Message-State: AOUpUlHXYYerYO4YvylvQSMqWOJqhMNDR+FHqPZ7cb52mjYVs9wkN2bg
	IT8xUB26UQT2HKdlVTYd1p2w7A==
X-Google-Smtp-Source: AAOMgpeCgAW/756Da3mlAxUXErk47Xk9pV5n8W0uo7CPvSpKVfzQTDqhYotwsOIbbtU2Z32lhWZ9jA==
X-Received: by 2002:a81:ac0a:: with SMTP id k10-v6mr3550451ywh.135.1531614662783;
        Sat, 14 Jul 2018 17:31:02 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a25:3881:: with SMTP id f123-v6ls7830287yba.16.gmail; Sat,
 14 Jul 2018 17:31:01 -0700 (PDT)
X-Received: by 2002:a5b:349:: with SMTP id q9-v6mr1366942ybp.7.1531614661166;
        Sat, 14 Jul 2018 17:31:01 -0700 (PDT)
X-Original-Sender: toby.brull@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:39168
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/39168>

------=_Part_134683_1546255666.1531614660505
Content-Type: multipart/alternative; 
	boundary="----=_Part_134684_1833482427.1531614660506"

------=_Part_134684_1833482427.1531614660506
Content-Type: text/plain; charset="UTF-8"

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.

------=_Part_134684_1833482427.1531614660506
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<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 versions of gcc=
 that I tried (7.2, 8.1, 9.0). It complains that the type of the value in t=
he &quot;requires&quot; clause is not bool, although the value is implicitl=
y constexpr convertible to bool.</div><div><br></div><div><br></div><blockq=
uote style=3D"margin: 0 0 0 40px; border: none; padding: 0px;"><div><font f=
ace=3D"courier new, monospace">template&lt;typename T, T v&gt;</font></div>=
<div><font face=3D"courier new, monospace">constexpr auto is_even (std::int=
egral_constant&lt;T, v&gt; =3D {})</font></div><div><font face=3D"courier n=
ew, monospace">{</font></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"courier new, monospace">}</font></div><div><font face=3D"cour=
ier new, monospace"><br></font></div><div><font face=3D"courier new, monosp=
ace">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, monospace">i=
nt 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><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">int main ()</font></div><div><font face=3D"cour=
ier new, monospace">{</font></div><div><font face=3D"courier new, monospace=
">=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">}</font></div=
></blockquote><div><br></div><div>Workarounds are, of course, to append &qu=
ot;()&quot; or to prepend &quot;!!&quot; to the line marked with (*), but m=
ight 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.</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/79029827-71df-4af1-ae50-607e96c5e322%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/79029827-71df-4af1-ae50-607e96c5e322=
%40isocpp.org</a>.<br />

------=_Part_134684_1833482427.1531614660506--

------=_Part_134683_1546255666.1531614660505--

.
