220 26317 <CAJnLdObbLAvViULXGAq=R7oP++Y5+WHNKu0C2BapoZwDXLnR4A@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: "'Edward Catmur' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: statement folding on variadic templates
 parameters pack
Date: Mon, 13 Jun 2016 15:14:18 +0100
Lines: 105
Approved: news@gmane.org
Message-ID: <CAJnLdObbLAvViULXGAq=R7oP++Y5+WHNKu0C2BapoZwDXLnR4A@mail.gmail.com>
References: <1e3daa7c-e10a-4589-8118-26f47bc1a0df@isocpp.org>
 <f11d3266-3407-4c00-a578-5d07beeb1071@isocpp.org> <CAOfiQq=hhVBJAQ3Ekeo6mkWxPasnURXOW6r8zNo8oOk93ptbAQ@mail.gmail.com>
 <CADvuK0K+_d_h1eby+nFE0wmdK+3+B=zFOG5nLp1H15jRTo0Jgg@mail.gmail.com>
 <2d8458f8-27b2-464f-a16e-fc866ccfd2cd@isocpp.org> <b448d4b9-c76d-4d27-8b16-0e005478320f@isocpp.org>
 <d90bb3eb-e1d4-4a29-bb7e-63c097f49f96@isocpp.org> <bf02cde4-5da6-4a0b-903f-8b9230d4869c@isocpp.org>
 <CALbYwOymuWcO0WO6aSGCd1iv-dTUxPXP1BMYDdv5Pfcafw_xcQ@mail.gmail.com>
 <CAJnLdOZ5L0P6qdoer6jntOjtYwCTpV_VEGJv6bZUmGk6zmoQ2g@mail.gmail.com>
 <a731ae2e-9519-4d03-81ec-506b7bbda8b5@isocpp.org> <CAFk2RUZBSMsJOkjDaU=9xz4iJ9qNadygbPiB004oCh2p3jfgFg@mail.gmail.com>
 <55892254-d646-4cc3-b10c-a0f0a5eb665c@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a11479a861893ea05352981a7
X-Trace: ger.gmane.org 1465827268 20817 80.91.229.3 (13 Jun 2016 14:14:28 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 13 Jun 2016 14:14:28 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDZLZTXF7UJBBO777K5AKGQENRDKACA@isocpp.org Mon Jun 13 16:14:28 2016
Return-path: <std-proposals+bncBDZLZTXF7UJBBO777K5AKGQENRDKACA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-it0-f72.google.com ([209.85.214.72])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDZLZTXF7UJBBO777K5AKGQENRDKACA@isocpp.org>)
	id 1bCSdG-0006AW-8I
	for gclcip-std-proposals@m.gmane.org; Mon, 13 Jun 2016 16:14:26 +0200
Original-Received: by mail-it0-f72.google.com with SMTP id z189sf102158718itg.2
        for <gclcip-std-proposals@m.gmane.org>; Mon, 13 Jun 2016 07:14:20 -0700 (PDT)
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:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=inEWHLgX1t4QI4w0IqzxnuMJ67fGl5kTBMzZsg2qcno=;
        b=aqwgvCG6QsFh/zHM7obUgSMpeAbZezLQiROHFNwAA1p6kkDDOjhGu5aGbX9ZHoNmPF
         Gu6Te9gXXvMxk32MrdBd2qQGFjyQkzjfQztr2+uKt37x5yjDKZJBNnRIdMM+BJN1jjxX
         mJWbS1U/y5WyTIE3XADTHXalljmbpIU8GSI053B2SPa+Ic/rRmrb4spHo7zE+P3vEbiF
         B6Nh8ZIWdweZjw8zxLhEdVYrduQbZsUpm/NNNYQb0VKCp+4cHOB1fU5wQe8X+399rP2L
         mOqIjuMBXnlhSCO7nYLAZxpcKPquoApWoZ2lMph1iH9HChrMvVzy9OMrPSS1vQfHOQzc
         uXcg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        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=inEWHLgX1t4QI4w0IqzxnuMJ67fGl5kTBMzZsg2qcno=;
        b=VIDk+yJGn00cAW3DNYuHRSFXkDO2BNwFvdPUnzWV9xKsDsdwckZOoUMlkA/et9mMTP
         /7N0oZXiensr2cfP6d/A8Sk7x/iTuxhQGmbsKTnhlsnwQ7NPk5paOw1jxvnH2OSrQ4df
         6WnvCV248fCXCDLT1aQTMwJjX4KyQ0e5/s50aOJojbjqHblsY2EYF83qnn04Tj/erJLD
         wFsQJDT46Hg+Pn4MwUFNZXPGhhVqsjB7Md65NdK+mvstqDgocs0xb+X0tqcOwgAQMotd
         uTHuQxukLxtiXdIPZdcx45zixTNVfKvAms8RubIHRKjNZdgP/aZWVwJNYQk1+nfTCOfP
         2zXA==
X-Gm-Message-State: ALyK8tIQH6bz5UTU//HCwfILkftIVJc5V7xRxC15FpZne2c3anLZfYnjkq5fuRbMSZGcfA==
X-Received: by 10.107.13.77 with SMTP id 74mr12572772ion.4.1465827260389;
        Mon, 13 Jun 2016 07:14:20 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.80.170 with SMTP id c39ls3309505qgd.28.gmail; Mon, 13 Jun
 2016 07:14:19 -0700 (PDT)
X-Received: by 10.55.124.130 with SMTP id x124mr14962937qkc.113.1465827259537;
        Mon, 13 Jun 2016 07:14:19 -0700 (PDT)
Original-Received: from mail-qk0-x22d.google.com (mail-qk0-x22d.google.com. [2607:f8b0:400d:c09::22d])
        by mx.google.com with ESMTPS id s5si15276047qkc.169.2016.06.13.07.14.19
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 13 Jun 2016 07:14:19 -0700 (PDT)
Received-SPF: pass (google.com: domain of ecatmur@googlemail.com designates 2607:f8b0:400d:c09::22d as permitted sender) client-ip=2607:f8b0:400d:c09::22d;
Original-Received: by mail-qk0-x22d.google.com with SMTP id p10so39457413qke.3
        for <std-proposals@isocpp.org>; Mon, 13 Jun 2016 07:14:19 -0700 (PDT)
X-Received: by 10.55.217.148 with SMTP id q20mr15050433qkl.62.1465827259354;
 Mon, 13 Jun 2016 07:14:19 -0700 (PDT)
Original-Received: by 10.237.55.198 with HTTP; Mon, 13 Jun 2016 07:14:18 -0700 (PDT)
In-Reply-To: <55892254-d646-4cc3-b10c-a0f0a5eb665c@isocpp.org>
X-Original-Sender: ecatmur@googlemail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@googlemail.com;       spf=pass (google.com: domain of
 ecatmur@googlemail.com designates 2607:f8b0:400d:c09::22d as permitted
 sender) smtp.mailfrom=ecatmur@googlemail.com;       dmarc=pass (p=QUARANTINE
 dis=NONE) header.from=googlemail.com
X-Original-From: Edward Catmur <ecatmur@googlemail.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:26317
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/26317>

--001a11479a861893ea05352981a7
Content-Type: text/plain; charset=UTF-8

On Mon, Jun 13, 2016 at 10:33 AM, Giovanni Piero Deretta <
gpderetta@gmail.com> wrote:

> On Sunday, June 12, 2016 at 11:25:50 AM UTC+1, Ville Voutilainen wrote:
>>
>> On 12 June 2016 at 13:23,  <inkwizyt...@gmail.com> wrote:
>> > This code should be fast as manually written switch, it would be
>> trivial for
>> > compiler to create jump table to have best performance.
>>
>>
>> I'm sure the open-source compilers will happily accept an extension
>> patch that shows how trivial it is.
>>
>
> For what is worth, you can abuse GCC statement expressions plus variadics
> to get variadic expansion of switch statements. Although 'case' in
> statement expressions is explicitly documented not to be supported, it does
> work in practice (nothing I would use in production of course).
>

That's amazing! I couldn't get it to work in any version after 4.9.2,
though; is there a trick I'm missing?

  switch (i) {
    ([](...){})(({ case I : g<I>(), ({ return; }), 0; })... );
  }


> So, while I wouldn't call it trivial, it seems to me that it souldn't be
> too hard to implement the extension in GCC, and you could even consider
> statement expressions as existing practice.
>

Absolutely; it'd be a nice hack to work on.

-- 
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/CAJnLdObbLAvViULXGAq%3DR7oP%2B%2BY5%2BWHNKu0C2BapoZwDXLnR4A%40mail.gmail.com.

--001a11479a861893ea05352981a7
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On M=
on, Jun 13, 2016 at 10:33 AM, Giovanni Piero Deretta <span dir=3D"ltr">&lt;=
<a href=3D"mailto:gpderetta@gmail.com" target=3D"_blank">gpderetta@gmail.co=
m</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margi=
n:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204=
);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr">On Sunday, Jun=
e 12, 2016 at 11:25:50 AM UTC+1, Ville Voutilainen wrote:<span class=3D""><=
blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l=
eft-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;pa=
dding-left:1ex">On 12 June 2016 at 13:23, =C2=A0&lt;<a rel=3D"nofollow">ink=
wizyt...@gmail.com</a>&gt; wrote:
<br>&gt; This code should be fast as manually written switch, it would be t=
rivial for
<br>&gt; compiler to create jump table to have best performance.
<br>
<br>
<br>I&#39;m sure the open-source compilers will happily accept an extension
<br>patch that shows how trivial it is.
<br></blockquote></span><div><br>For what is worth, you can abuse GCC state=
ment expressions plus variadics to get variadic expansion of switch stateme=
nts. Although &#39;case&#39; in statement expressions is explicitly documen=
ted not to be supported, it does work in practice (nothing I would use in p=
roduction of course).<br></div></div></blockquote><div><br></div><div>That&=
#39;s amazing! I couldn&#39;t get it to work in any version after 4.9.2, th=
ough; is there a trick I&#39;m missing?</div><div><br></div><div><div><font=
 face=3D"monospace, monospace">=C2=A0 switch (i) {</font></div><div><font f=
ace=3D"monospace, monospace">=C2=A0 =C2=A0 ([](...){})(({ case I : g&lt;I&g=
t;(), ({ return; }), 0; })... );</font></div><div><font face=3D"monospace, =
monospace">=C2=A0 }</font></div></div><div>=C2=A0</div><blockquote class=3D=
"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;borde=
r-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><di=
v dir=3D"ltr"><div>So, while I wouldn&#39;t call it trivial, it seems to me=
 that it souldn&#39;t be too hard to implement the extension in GCC, and yo=
u could even consider statement expressions as existing practice.<br></div>=
</div></blockquote><div><br></div><div>Absolutely; it&#39;d be a nice hack =
to work on.</div></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/CAJnLdObbLAvViULXGAq%3DR7oP%2B%2BY5%2=
BWHNKu0C2BapoZwDXLnR4A%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoo=
ter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAJnLdObb=
LAvViULXGAq%3DR7oP%2B%2BY5%2BWHNKu0C2BapoZwDXLnR4A%40mail.gmail.com</a>.<br=
 />

--001a11479a861893ea05352981a7--

.
