220 23905 <CADvuK0L2b4usBNdJCnXEW8yS4SNQDrPfEBw-OAAJAibwALGRMQ@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 15:41:55 -0800
Lines: 149
Approved: news@gmane.org
Message-ID: <CADvuK0L2b4usBNdJCnXEW8yS4SNQDrPfEBw-OAAJAibwALGRMQ@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>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a1145ab580a67110529cc8816
X-Trace: ger.gmane.org 1453333326 18082 80.91.229.3 (20 Jan 2016 23:42:06 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 20 Jan 2016 23:42:06 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDLZJYWNDQIMLNUAWUCRUBGXLKHM2@isocpp.org Thu Jan 21 00:42:00 2016
Return-path: <std-proposals+bncBDLZJYWNDQIMLNUAWUCRUBGXLKHM2@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f69.google.com ([209.85.215.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDLZJYWNDQIMLNUAWUCRUBGXLKHM2@isocpp.org>)
	id 1aM2Ny-0004JW-Vk
	for gclcip-std-proposals@m.gmane.org; Thu, 21 Jan 2016 00:41:59 +0100
Original-Received: by mail-lf0-f69.google.com with SMTP id b134sf8956414lfe.2
        for <gclcip-std-proposals@m.gmane.org>; Wed, 20 Jan 2016 15:41:58 -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=iOpLcycK7uARnUm+t30yyuDuoDurKZy7hcxb2uXHUew=;
        b=y42TqlKA1kheXqB6uKub/0cKi8uL+Oy8VgfVPKRVi98xZgzMd3z2ObTT6ekUFHLhjg
         gmkLndkiCNUoMb+u8FMpzVMWdO2JI6NcEmv35bRJ1B8KRUhr9VTCu3snp31bUds3feaj
         vyujSj+eHcyUKLCMxELJ/bfvd+uMmwaccdzn6fCTZRJRa6cGopcHM4cM1IQGPPAuyAN6
         ePphjBuWVtWGW70hsYIaqC42D4UHoRgk3KeYyulHSgTK7o7QnHwbWJLet7HGYErYk+ZW
         5hHII5zxaxrhKIOJNhjGPdghDWmlDFD0Z1eGl45yylaAOA8G185OJq3QjWOCRHAnHw75
         5xPg==
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=iOpLcycK7uARnUm+t30yyuDuoDurKZy7hcxb2uXHUew=;
        b=mG8lJKdMngigw4cDUyMnyYGyyLVRHodTxK4Omui6kd52V46K0xZQdl/TcL4merLfFv
         mrXGU1mLmV/z6vbHEyeFgtHUehBpUgrggj/ZbNinxIuaLjrFQtRE9tlLpsmY5f7wXe1F
         JMOKXaYjUR9rtZj51dddXA6rkW+03Tl6M0q34BM1ZK1BS0B19EFflFbyUvB8SUhEv32y
         2yg6KYIIJXTFvAWgosEAQ0AS0WmdP70YcV1TLcxrSSXBDmFvLctp6ZMARcQDHsvqx1Dn
         Q43q9sG2ENBsmf7pSm13ynCEAI6gjO9mraHfQ+2d12DHFxkvb5+jmBJNrFJWYlF7mY2Z
         An5g==
X-Gm-Message-State: ALoCoQmKmrNASAnRpo1ZMn2UxXqE8wVggTfcGeI+M1CxQwJTTnN6WOinEKJ6wo8rHRu36MLD5JeYKfkwuzsKwH9ie8e7DVu7ng==
X-Received: by 10.25.15.106 with SMTP id e103mr5073031lfi.9.1453333317942;
        Wed, 20 Jan 2016 15:41:57 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.142.18 with SMTP id q18ls232178wmd.0.gmail; Wed, 20 Jan
 2016 15:41:56 -0800 (PST)
X-Received: by 10.28.63.22 with SMTP id m22mr6305220wma.59.1453333316329;
        Wed, 20 Jan 2016 15:41:56 -0800 (PST)
Original-Received: from mail-wm0-x22e.google.com (mail-wm0-x22e.google.com. [2a00:1450:400c:c09::22e])
        by mx.google.com with ESMTPS id e4si42498860wjy.109.2016.01.20.15.41.56
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 20 Jan 2016 15:41:56 -0800 (PST)
Received-SPF: pass (google.com: domain of arthur.j.odwyer@gmail.com designates 2a00:1450:400c:c09::22e as permitted sender) client-ip=2a00:1450:400c:c09::22e;
Original-Received: by mail-wm0-x22e.google.com with SMTP id 123so153125719wmz.0
        for <std-proposals@isocpp.org>; Wed, 20 Jan 2016 15:41:56 -0800 (PST)
X-Received: by 10.28.145.204 with SMTP id t195mr6938736wmd.91.1453333316000;
 Wed, 20 Jan 2016 15:41:56 -0800 (PST)
Original-Received: by 10.27.19.201 with HTTP; Wed, 20 Jan 2016 15:41:55 -0800 (PST)
In-Reply-To: <n7onju$vs1$2@ger.gmane.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::22e 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:23905
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/23905>

--001a1145ab580a67110529cc8816
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Wed, Jan 20, 2016 at 11:36 AM, Matthew Woehlke <mwoehlke.floss@gmail.com=
>
wrote:

>
> Okay, having said that, I *can* think of one case... can you show how
> you would simplify this code?
>
>   stream << "begin" << get<0>(x) << get<1>(x)
>          << ... << get<N>(x) << "end";
>
> (Rules: 'stream' must be named exactly once, and no fair creating a
> helper function. Strong preference to avoid assigning 'stream' to a
> scratch variable.)
>

Sure!

    // Nicol's syntax
    (stream << "begin" << ... << [*]x) << "end";
    // Arthur's syntax
    (stream << "begin" << ... << x~) << "end";


> For bonus points, include `", "` between each item of `x` (okay to
> include after the last item also).
>

This is significantly harder!  I think it would have to look something like
this:
http://melpon.org/wandbox/permlink/oLcM3ZjH45oTbI7T

template<class F>
auto operator<< (std::ostream& out, F&& f) -> decltype(f(out))  // SFINAE
{
    return f(out);  // maybe C++17 should provide this overload already
}

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";
}

Messy, but not positively horrible. What would it look like in your
(Matthew's) proposal?

=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/.

--001a1145ab580a67110529cc8816
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wed, Jan 20, 2016 at 11:36 AM, Matthew Woehlke <span di=
r=3D"ltr">&lt;<a href=3D"mailto:mwoehlke.floss@gmail.com" target=3D"_blank"=
>mwoehlke.floss@gmail.com</a>&gt;</span> wrote:<br><div class=3D"gmail_extr=
a"><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,=
204);border-left-style:solid;padding-left:1ex"><br>
Okay, having said that, I *can* think of one case... can you show how<br>
you would simplify this code?<br>
<br>
=C2=A0 stream &lt;&lt; &quot;begin&quot; &lt;&lt; get&lt;0&gt;(x) &lt;&lt; =
get&lt;1&gt;(x)<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&lt;&lt; ... &lt;&lt; get&lt;N&gt;(x) &lt=
;&lt; &quot;end&quot;;<br>
<br>
(Rules: &#39;stream&#39; must be named exactly once, and no fair creating a=
<br>
helper function. Strong preference to avoid assigning &#39;stream&#39; to a=
<br>
scratch variable.)<br></blockquote><div><br></div><div>Sure!</div><div><br>=
</div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 // Nicol&#39;s=
 syntax</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =
(stream &lt;&lt; &quot;begin&quot; &lt;&lt; ... &lt;&lt; [*]x) &lt;&lt; &qu=
ot;end&quot;;</font></div><div><font face=3D"monospace, monospace">=C2=A0 =
=C2=A0 // Arthur&#39;s syntax</font></div><div><font face=3D"monospace, mon=
ospace">=C2=A0 =C2=A0 (stream &lt;&lt; &quot;begin&quot; &lt;&lt; ... &lt;&=
lt; x~) &lt;&lt; &quot;end&quot;;</font></div><div>=C2=A0</div><blockquote =
class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1=
px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:=
1ex">For bonus points, include `&quot;, &quot;` between each item of `x` (o=
kay to<br>
include after the last item also).<br></blockquote><div><br></div><div>This=
 is significantly harder!=C2=A0 I think it would have to look something lik=
e this:</div><div></div><div><a href=3D"http://melpon.org/wandbox/permlink/=
oLcM3ZjH45oTbI7T">http://melpon.org/wandbox/permlink/oLcM3ZjH45oTbI7T<br></=
a></div><div><br></div><div><div><font face=3D"monospace, monospace">templa=
te&lt;class F&gt;</font></div><div><font face=3D"monospace, monospace">auto=
 operator&lt;&lt; (std::ostream&amp; out, F&amp;&amp; f) -&gt; decltype(f(o=
ut)) =C2=A0// SFINAE</font></div><div><font face=3D"monospace, monospace">{=
</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 return =
f(out); =C2=A0// maybe C++17 should provide this overload already</font></d=
iv><div><font face=3D"monospace, monospace">}</font></div><div><font face=
=3D"monospace, monospace"><br></font></div><div><font face=3D"monospace, mo=
nospace">template&lt;class TupleLike&gt;</font></div><div><font face=3D"mon=
ospace, monospace">void print_to_stream(std::ostream&amp; stream, const Tup=
leLike&amp; x)</font></div><div><font face=3D"monospace, monospace">{</font=
></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 auto commaize=
 =3D [](auto&amp;&amp; x) {</font></div><div><font face=3D"monospace, monos=
pace">=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></div><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&quot;;</font><=
/div><div><font face=3D"monospace, monospace">}</font></div></div><div><br>=
</div><div>Messy, but not positively horrible. What would it look like in y=
our (Matthew&#39;s) proposal?</div><div><br></div><div>=E2=80=93Arthur</div=
></div></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 />

--001a1145ab580a67110529cc8816--

.
