220 23910 <CADvuK0+Q3fX5wD0TqgjJ3MuuKbQwmazd8naia6MNX=NzHQVAmg@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: "Arthur O'Dwyer" <arthur.j.odwyer@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: RFC: Unpacking tuples to value sequences
Date: Wed, 20 Jan 2016 16:37:06 -0800
Lines: 144
Approved: news@gmane.org
Message-ID: <CADvuK0+Q3fX5wD0TqgjJ3MuuKbQwmazd8naia6MNX=NzHQVAmg@mail.gmail.com>
References: <n7jlvp$c44$1@ger.gmane.org>
	<f758483a-568d-4444-957f-41535c39be4e@isocpp.org>
	<c91a2d40-17da-4edc-b14b-4e166e9ecaeb@isocpp.org>
	<6f3ece34-e302-4d95-afd0-4c1924e8a780@isocpp.org>
	<n7locq$q98$1@ger.gmane.org>
	<e4a9f750-0608-47ac-9d91-f1201b016b99@isocpp.org>
	<n7lqmm$2d3$1@ger.gmane.org>
	<6ad65a24-8a2e-4053-b9c9-80d296d98e7d@isocpp.org>
	<n7m5v9$346$1@ger.gmane.org>
	<72de7daf-93af-4e55-95ea-67898bd2a5f6@isocpp.org>
	<n7o939$vj0$1@ger.gmane.org>
	<22792c37-ba68-4a13-af1c-8b8247d3d22a@isocpp.org>
	<n7onju$vs1$2@ger.gmane.org>
	<CADvuK0L2b4usBNdJCnXEW8yS4SNQDrPfEBw-OAAJAibwALGRMQ@mail.gmail.com>
	<41870a42-b687-4f21-a8b1-d00a239aff01@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a1145392c62f0930529cd4da9
X-Trace: ger.gmane.org 1453336633 1845 80.91.229.3 (21 Jan 2016 00:37:13 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 21 Jan 2016 00:37:13 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDLZJYWNDQILHUEAWUCRUBFG4O63M@isocpp.org Thu Jan 21 01:37:12 2016
Return-path: <std-proposals+bncBDLZJYWNDQILHUEAWUCRUBFG4O63M@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lb0-f197.google.com ([209.85.217.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDLZJYWNDQILHUEAWUCRUBFG4O63M@isocpp.org>)
	id 1aM3FN-0000Gh-Ie
	for gclcip-std-proposals@m.gmane.org; Thu, 21 Jan 2016 01:37:09 +0100
Original-Received: by mail-lb0-f197.google.com with SMTP id p10sf8510198lbo.0
        for <gclcip-std-proposals@m.gmane.org>; Wed, 20 Jan 2016 16:37:09 -0800 (PST)
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:date:message-id:subject:from:to
         :content-type: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=SA7hjg4BJcnZ9XFvaGZ7EQ3kPNy3UDxmdKm9Qpjg6dc=;
        b=lQHQTKJSlAg++YAmQwGPo+9MSVvvw8s45FXusBonZdQ3Rf0IZnSRjqVpigCV5VSli5
         73XMVDpR2wCA/bkdmry4I+NWCwuX+Cw2fimCFZZ/1sUK9wyzZIlhALDlCRlmtfLvKoOR
         a3Fd9SG7veCwjsa3idQjpetTKjGfhubxS1+dCcJNfjLduVqPW9DqA8nQaU2Mi/rhgXjk
         quFxpXo0HOhL/NEb7FcgTA8xyi3ne8uT76cOcRv/I/ufkC/4L9n0TP+4b0vY2X80rsuI
         moZn+S2Y3nfwHXx62gXp27tMRy7427orxr3Jg6FH5aQ6xAV/VFIIEkYJLZjnM7HUGDSA
         AEXg==
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:date
         :message-id:subject:from:to:content-type: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=SA7hjg4BJcnZ9XFvaGZ7EQ3kPNy3UDxmdKm9Qpjg6dc=;
        b=AneYt2qPn8PBv6lBWOCJa7a5uUp3ymqz5giwVW5rBuEg2+M4EE3PP63z7NhMGhQKFx
         oG1Jbfw3EmMrAEo5gMiMg9SH9t/98tqADMmIHN+6D+5xj/T7p4UCChCaGG3Khk+ehRhW
         /okfmdu64e2aZR3vtIBX378mVtV6bby2dS/0dZmaR7GJFtu0LjyyHsonAGQUGpgoqkDj
         rDzLpyDMsYpUR17MpodtN+v7j43NTxI6H/f85M+h5U6kPOcof0JqsQQZiwzSFz0ao4s7
         b6KSC9y/kBv7iAD6Qssau8+nEM98kTsI+6eZaWLmVo0BwfR47EEDF2XsIJe3zjvnIl+X
         GGjQ==
X-Gm-Message-State: AG10YOSJQqBNFP8PXY2DQpStOh7co2hEuNQPWTsUCkkOfuEyFYx+PHn5aSSb5jkRPVpSvw==
X-Received: by 10.28.142.21 with SMTP id q21mr28269wmd.1.1453336628852;
        Wed, 20 Jan 2016 16:37:08 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.105.136 with SMTP id z8ls264614wmh.46.gmail; Wed, 20 Jan
 2016 16:37:07 -0800 (PST)
X-Received: by 10.28.223.67 with SMTP id w64mr7133788wmg.28.1453336627135;
        Wed, 20 Jan 2016 16:37:07 -0800 (PST)
Original-Received: from mail-wm0-x22b.google.com (mail-wm0-x22b.google.com. [2a00:1450:400c:c09::22b])
        by mx.google.com with ESMTPS id ld8si56808074wjc.77.2016.01.20.16.37.07
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 20 Jan 2016 16:37:07 -0800 (PST)
Received-SPF: pass (google.com: domain of arthur.j.odwyer@gmail.com designates 2a00:1450:400c:c09::22b as permitted sender) client-ip=2a00:1450:400c:c09::22b;
Original-Received: by mail-wm0-x22b.google.com with SMTP id r129so152374100wmr.0
        for <std-proposals@isocpp.org>; Wed, 20 Jan 2016 16:37:07 -0800 (PST)
X-Received: by 10.28.179.84 with SMTP id c81mr7050023wmf.30.1453336626914;
 Wed, 20 Jan 2016 16:37:06 -0800 (PST)
Original-Received: by 10.27.19.201 with HTTP; Wed, 20 Jan 2016 16:37:06 -0800 (PST)
In-Reply-To: <41870a42-b687-4f21-a8b1-d00a239aff01@isocpp.org>
X-Original-Sender: arthur.j.odwyer@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of arthur.j.odwyer@gmail.com designates 2a00:1450:400c:c09::22b as
 permitted sender) smtp.mailfrom=arthur.j.odwyer@gmail.com;       dkim=pass
 header.i=@gmail.com;       dmarc=pass (p=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-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:23910
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/23910>

--001a1145392c62f0930529cd4da9
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Wed, Jan 20, 2016 at 4:03 PM, T. C. <rs2740@gmail.com> wrote:

> On Wednesday, January 20, 2016 at 6:41:58 PM UTC-5, Arthur O'Dwyer wrote:
>
>>
>> template<class TupleLike>
>> void print_to_stream(std::ostream& stream, const TupleLike& x)
>> {
>>     auto commaize =3D [](auto&& x) {
>>         return [&x](std::ostream& out) -> std::ostream& { return out << =
x
>> << ", "; };
>>     };
>>
>>     (stream << "begin, " << ... << commaize(x~)) << "end";
>> }
>>
>>
> If you can write stream twice, then a comma fold will do:
>
> ((stream << "begin, ") , ... , (stream << x~ << ", ")) << "end";
>
> Also, I'm fairly sure you need to parenthesize stream << "begin, ". The
> grammar only allows a cast-expression there.
>

I bet you're right. :)  The above compiles with GCC 6.0 on Wandbox (if you
replace x~ with std::get<I>(x) of course) and fails for unrelated reasons
with Clang 3.9. But I can totally believe that GCC 6.0 has bugs and/or
helpful extensions in this area.

Personally, I was shocked that

    return (a * b) + ...;

failed to compile on either Clang or GCC =E2=80=94 and with a completely un=
helpful
syntax error! It took me tens of minutes to discover what I was doing wrong
(mostly spent trying to figure out if these compilers claimed to support
fold-expressions at all).

Is there a grammatical reason to *require* parentheses around every single
fold-expression, or was it just someone's idea of being "helpful"?

=E2=80=93Arthur

--=20

---=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.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-propos=
als/.

--001a1145392c62f0930529cd4da9
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wed, Jan 20, 2016 at 4:03 PM, T. C. <span dir=3D"ltr">&=
lt;<a href=3D"mailto:rs2740@gmail.com" target=3D"_blank">rs2740@gmail.com</=
a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div class=3D"gmail_quot=
e"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left=
:1px #ccc solid;padding-left:1ex">On Wednesday, January 20, 2016 at 6:41:58=
 PM UTC-5, Arthur O&#39;Dwyer wrote:<br><span class=3D""><blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_quote"><div><di=
v><font face=3D"monospace, monospace"><br></font></div><div><font face=3D"m=
onospace, monospace">template&lt;class TupleLike&gt;</font></div><div><font=
 face=3D"monospace, monospace">void print_to_stream(std::ostream&amp; strea=
m, const TupleLike&amp; x)</font></div><div><font face=3D"monospace, monosp=
ace">{</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 a=
uto commaize =3D [](auto&amp;&amp; x) {</font></div><div><font face=3D"mono=
space, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return [&amp;x](std::ostream&=
amp; out) -&gt; std::ostream&amp; { return out &lt;&lt; x &lt;&lt; &quot;, =
&quot;; };</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=
=A0 };</font></div><div><font face=3D"monospace, monospace"><br></font></di=
v><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 (stream &lt;&lt; &=
quot;begin, &quot; &lt;&lt; ... &lt;&lt; commaize(x~)) &lt;&lt; &quot;end&q=
uot;;</font></div><div><font face=3D"monospace, monospace">}</font></div></=
div><div><br></div></div></div></blockquote><div><br></div></span><div>If y=
ou can write=C2=A0<span style=3D"color:rgb(0,0,0);font-family:monospace;bac=
kground-color:rgb(250,250,250)">stream=C2=A0</span>twice, then a comma fold=
 will do:</div><div><br></div><div style=3D"border:1px solid rgb(187,187,18=
7);word-wrap:break-word;background-color:rgb(250,250,250)"><code><div><span=
 style=3D"color:#660">((</span><span style=3D"color:#000">stream </span><sp=
an style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> </span><=
span style=3D"color:#080">&quot;begin, &quot;</span><span style=3D"color:#6=
60">)</span><span style=3D"color:#000"> </span><span style=3D"color:#660">,=
</span><span style=3D"color:#000"> </span><span style=3D"color:#660">...</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#660">,</span><=
span style=3D"color:#000"> </span><span style=3D"color:#660">(</span><span =
style=3D"color:#000">stream </span><span style=3D"color:#660">&lt;&lt;</spa=
n><span style=3D"color:#000"> x</span><span style=3D"color:#660">~</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#660">&lt;&lt;</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#080">&quot;, &quot=
;</span><span style=3D"color:#660">))</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#080">&quot;end&quot;</span><span style=3D"color=
:#660">;</span></div></code></div><div><br></div><div>Also, I&#39;m fairly =
sure you need to parenthesize=C2=A0<span style=3D"font-family:monospace,mon=
ospace">stream &lt;&lt; &quot;begin, &quot;</span>. The grammar only allows=
 a cast-expression there.<br></div></blockquote><div><br></div><div>I bet y=
ou&#39;re right. :) =C2=A0The above compiles with GCC 6.0 on Wandbox (if yo=
u replace <font face=3D"monospace, monospace">x~</font> with <font face=3D"=
monospace, monospace">std::get&lt;I&gt;(x)</font> of course) and fails for =
unrelated reasons with Clang 3.9. But I can totally believe that GCC 6.0 ha=
s bugs and/or helpful extensions in this area.</div><div><br></div><div>Per=
sonally, I was shocked that</div><div><br></div><div><font face=3D"monospac=
e, monospace">=C2=A0 =C2=A0 return (a * b) + ...;</font></div></div><br></d=
iv><div class=3D"gmail_extra">failed to compile on either Clang or GCC =E2=
=80=94 and with a completely unhelpful syntax error! It took me tens of min=
utes to discover what I was doing wrong (mostly spent trying to figure out =
if these compilers claimed to support fold-expressions at all).</div><div c=
lass=3D"gmail_extra"><br></div><div class=3D"gmail_extra">Is there a gramma=
tical reason to <i>require</i> parentheses around every single fold-express=
ion, or was it just someone&#39;s idea of being &quot;helpful&quot;?</div><=
div class=3D"gmail_extra"><br></div><div class=3D"gmail_extra">=E2=80=93Art=
hur</div></div>

<p></p>

-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />

--001a1145392c62f0930529cd4da9--

.
