220 24348 <1604CAB7-DF4D-45B4-A5F8-E21F70491CB7@gmail.com> article
Path: news.gmane.org!not-for-mail
From: David Krauss <potswa@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: [tuple] extracting tuples out of a tuple
Date: Sat, 13 Feb 2016 18:03:26 +0800
Lines: 126
Approved: news@gmane.org
Message-ID: <1604CAB7-DF4D-45B4-A5F8-E21F70491CB7@gmail.com>
References: <CA+wfc1-FFqOJ9OSme_SpJAmGz+cshbMDVi_dLrF1ztbzkTN-WQ@mail.gmail.com> <n9ksdc$4so$1@ger.gmane.org> <CA+wfc18LVMDXhRYhkw0PxeOmPiOoqVteF7V+40EdOOYb2K1snA@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0 (Mac OS X Mail 9.1 \(3096.5\))
Content-Type: multipart/alternative; boundary="Apple-Mail=_6A8ED708-663E-4191-8621-BBFEA03F8D91"
X-Trace: ger.gmane.org 1455357825 22461 80.91.229.3 (13 Feb 2016 10:03:45 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 13 Feb 2016 10:03:45 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCW25A7E3QCRB5767O2QKGQEKBUICBQ@isocpp.org Sat Feb 13 11:03:39 2016
Return-path: <std-proposals+bncBCW25A7E3QCRB5767O2QKGQEKBUICBQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qk0-f200.google.com ([209.85.220.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCW25A7E3QCRB5767O2QKGQEKBUICBQ@isocpp.org>)
	id 1aUX3B-0001rT-BM
	for gclcip-std-proposals@m.gmane.org; Sat, 13 Feb 2016 11:03:37 +0100
Original-Received: by mail-qk0-f200.google.com with SMTP id u128sf159679383qkh.0
        for <gclcip-std-proposals@m.gmane.org>; Sat, 13 Feb 2016 02:03:37 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=from:content-type:message-id:mime-version:subject:date:references
         :to:in-reply-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=LQAZ2KFoYJ5Zk92kdwZuUA9i2ejRpmqJYp96/mile5g=;
        b=LREu90iyLvjFSWAkmUWK5k4AeF3c4oJCz4G/xSaXbZ7eQGYqNLQoF9DqTPMUfmDA3s
         nCZlUfzWh4Ad//J2wqqFqnYVm1ZvnBPvqI9KEKLDLbVI96UHvdPQ3BYatZTm+h0aEZGK
         EIIhPxafnab7tqhqoSNhTrW5J6Qyp9jQh26WlkbdB5n5HeHCq0JyVm8z8DFIij+xR/qy
         4J7chKbThdVXOkrQS/LRaq2bX0CbJF3I2V5DlCtRZU+6pRCf57A6gGDUhMGcHkV4zG5a
         eEMJjRHFIHEORw9OHfMxRojlPuA0lvvP17Pz+rSN1y8WUHNXi5EwcX9u0snn6iW225Jk
         u6Jw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:content-type:message-id:mime-version
         :subject:date:references:to:in-reply-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=LQAZ2KFoYJ5Zk92kdwZuUA9i2ejRpmqJYp96/mile5g=;
        b=Zqm4FLJxxNyRW6ETx1mxETU+odzvz4rnsLjWU7MxVzJ54oQg2w5VWw2iExlgYT4/OD
         iMnnieKKsAiPCE3kbG/xa9LzlvMqc/usQxiTkp0c1kd07QHSO9nEGjgeiFi5R3YQ2lY+
         8LyvYSwboJwMPecbYDolIMglQdSoPDGeO4jBOLVXrAkKDoF8S9YumXNcHcJ6R24G0R+H
         pA4lR3jNI8w6i3kzF/RySmmqdTokdukylKbtybzboRzebtMxtz49ZsVhjH3CIbRNP5OQ
         HR0eEOwy2ueHpNOvACm/umBuMdhlRDrars46XPeIkVEpg2eSWujNaAJre348IKYE1cEB
         X6vA==
X-Gm-Message-State: AG10YOTOQ/IdU52OeeYb4OVbSfVDCs8DFm5MGtxL9Ayjf0WLJg4EQjFx5i8/WjXYQzA5aw==
X-Received: by 10.129.130.71 with SMTP id s68mr6040570ywf.29.1455357816446;
        Sat, 13 Feb 2016 02:03:36 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.128.69 with SMTP id b66ls1121896iod.101.gmail; Sat, 13 Feb
 2016 02:03:35 -0800 (PST)
X-Received: by 10.98.14.79 with SMTP id w76mr8770331pfi.1.1455357815510;
        Sat, 13 Feb 2016 02:03:35 -0800 (PST)
Original-Received: from mail-pa0-x22e.google.com (mail-pa0-x22e.google.com. [2607:f8b0:400e:c03::22e])
        by mx.google.com with ESMTPS id tg6si26615064pab.0.2016.02.13.02.03.35
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Sat, 13 Feb 2016 02:03:35 -0800 (PST)
Received-SPF: pass (google.com: domain of potswa@gmail.com designates 2607:f8b0:400e:c03::22e as permitted sender) client-ip=2607:f8b0:400e:c03::22e;
Original-Received: by mail-pa0-x22e.google.com with SMTP id yy13so59404033pab.3
        for <std-proposals@isocpp.org>; Sat, 13 Feb 2016 02:03:35 -0800 (PST)
X-Received: by 10.66.124.170 with SMTP id mj10mr8738987pab.92.1455357815393;
        Sat, 13 Feb 2016 02:03:35 -0800 (PST)
Original-Received: from [172.20.10.2] ([121.54.54.157])
        by smtp.gmail.com with ESMTPSA id 70sm25040321pfs.78.2016.02.13.02.03.31
        for <std-proposals@isocpp.org>
        (version=TLSv1/SSLv3 cipher=OTHER);
        Sat, 13 Feb 2016 02:03:34 -0800 (PST)
In-Reply-To: <CA+wfc18LVMDXhRYhkw0PxeOmPiOoqVteF7V+40EdOOYb2K1snA@mail.gmail.com>
X-Mailer: Apple Mail (2.3096.5)
X-Original-Sender: potswa@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of potswa@gmail.com designates 2607:f8b0:400e:c03::22e as permitted
 sender) smtp.mailfrom=potswa@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:24348
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/24348>

--Apple-Mail=_6A8ED708-663E-4191-8621-BBFEA03F8D91
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2016=E2=80=9302=E2=80=9313, at 12:30 AM, Oliver Kowalke <oliver.kowalk=
e@gmail.com> wrote:
>=20
> I've had std::tie() in mind,

The special feature of tie is generating references. That seems orthogonal =
to slicing a sequence. Reference semantics should be used sparingly in gene=
ral.

How about a function to get a pack of references from a tuple,

template< typename ... t >
std::tuple< t & ... > tuple_ref( std::tuple< t ... > & );

and a generic slice function,

template< std::size_t first, std::size_t last, typename tuple_like >
std::tuple< std::tuple_element_t< tuple_like, N > ... > // N goes from firs=
t to last.
tuple_slice( tuple_like const & );

Then the example looks like,

std::tuple< int, std::string, std::string, double > tpl{ -1, "abc", "xyz", =
..5 };
std::tuple< int, std::string, std::string > tpl1;
std::tuple< std::string, double > tpl2;

tpl1 =3D tuple_slice< 0, 3 >( tpl );
tpl2 =3D tuple_slice< 2, 2 >( tpl );
std::tuple_cat( tuple_ref( tpl1 ), tuple_ref( tpl2 ) ) =3D tpl;

The bounds of the slice are explicit, but that looks more like a feature th=
an a bug.

--=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/.

--Apple-Mail=_6A8ED708-663E-4191-8621-BBFEA03F8D91
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2016=E2=80=9302=
=E2=80=9313, at 12:30 AM, Oliver Kowalke &lt;<a href=3D"mailto:oliver.kowal=
ke@gmail.com" class=3D"">oliver.kowalke@gmail.com</a>&gt; wrote:</div><br c=
lass=3D"Apple-interchange-newline"><div class=3D""><span style=3D"font-fami=
ly: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; f=
ont-weight: normal; letter-spacing: normal; orphans: auto; text-align: star=
t; text-indent: 0px; text-transform: none; white-space: normal; widows: aut=
o; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display:=
 inline !important;" class=3D"">I've had std::tie() in mind,</span><br styl=
e=3D"font-family: Helvetica; font-size: 12px; font-style: normal; font-vari=
ant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; te=
xt-align: start; text-indent: 0px; text-transform: none; white-space: norma=
l; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=
=3D""></div></blockquote></div><br class=3D""><div class=3D"">The special f=
eature of <font face=3D"Courier" class=3D"">tie</font> is generating refere=
nces. That seems orthogonal to slicing a sequence. Reference semantics shou=
ld be used sparingly in general.</div><div class=3D""><br class=3D""></div>=
<div class=3D"">How about a function to get a pack of references from a tup=
le,</div><div class=3D""><br class=3D""></div><div class=3D""><font face=3D=
"Courier" class=3D"">template&lt; typename ... t &gt;</font></div><div clas=
s=3D""><font face=3D"Courier" class=3D"">std::tuple&lt; t &amp; ... &gt; tu=
ple_ref( std::tuple&lt; t ... &gt; &amp; );</font></div><div class=3D""><br=
 class=3D""></div><div class=3D"">and a generic slice function,</div><div c=
lass=3D""><br class=3D""></div><div class=3D""><font face=3D"Courier" class=
=3D"">template&lt; std::size_t first, std::size_t last,&nbsp;typename tuple=
_like&nbsp;&gt;</font></div><div class=3D""><div class=3D""><span style=3D"=
font-family: Courier;" class=3D"">std::tuple&lt; std::tuple_element_t&lt; t=
uple_like, N &gt; ... &gt; // N goes from first to last.</span></div><div c=
lass=3D""><font face=3D"Courier" class=3D"">tuple_slice( tuple_like const &=
amp; );</font></div></div><div class=3D""><font face=3D"Courier" class=3D""=
><br class=3D""></font></div><div class=3D"">Then the example looks like,</=
div><div class=3D""><br class=3D""></div><div class=3D""><div class=3D""><f=
ont face=3D"Courier" class=3D"">std::<span tabindex=3D"-1" id=3D":1tt.15" c=
lass=3D"">tuple</span>&lt; int, std::string, std::string, double &gt;&nbsp;=
<span tabindex=3D"-1" id=3D":1tt.16" class=3D"">tpl</span>{ -1, "<span tabi=
ndex=3D"-1" id=3D":1tt.17" class=3D"">abc</span>", "<span tabindex=3D"-1" i=
d=3D":1tt.18" class=3D"">xyz</span>", .5 };<br class=3D"">std::<span tabind=
ex=3D"-1" id=3D":1tt.19" class=3D"">tuple</span>&lt; int, std::string, std:=
:string &gt; tpl1;<br class=3D"">std::<span tabindex=3D"-1" id=3D":1tt.20" =
class=3D"">tuple</span>&lt; std::string, double &gt; tpl2;<br class=3D""><b=
r class=3D"">tpl1 =3D&nbsp;tuple_slice&lt; 0, 3 &gt;(&nbsp;<span tabindex=
=3D"-1" id=3D":1tt.21" class=3D"">tpl )</span>;<br class=3D"">tpl2 =3D&nbsp=
;tuple_slice&lt; 2, 2 &gt;(&nbsp;<span tabindex=3D"-1" id=3D":1tt.22" class=
=3D"">tpl )</span>;<br class=3D""></font></div><div class=3D""><font face=
=3D"Courier" class=3D"">std::tuple_cat( tuple_ref( tpl1 ), tuple_ref( tpl2 =
) ) =3D tpl;<br class=3D""></font></div></div><div class=3D""><br class=3D"=
"></div><div class=3D"">The bounds of the slice are explicit, but that look=
s more like a feature than a bug.</div><div class=3D""><br class=3D""></div=
></body></html>

<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 />

--Apple-Mail=_6A8ED708-663E-4191-8621-BBFEA03F8D91--

.
