220 19211 <e61080cb-ca1f-4426-a6be-4618ffe88cfe@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Sean Middleditch <sean.middleditch@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Overloading std::begin and std::end for std::pair
Date: Thu, 23 Jul 2015 12:04:26 -0700 (PDT)
Lines: 102
Approved: news@gmane.org
Message-ID: <e61080cb-ca1f-4426-a6be-4618ffe88cfe@isocpp.org>
References: <012fd35d-96fd-4775-835e-2105176c4f97@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1220_396501332.1437678266187"
X-Trace: ger.gmane.org 1437678272 31741 80.91.229.3 (23 Jul 2015 19:04:32 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 23 Jul 2015 19:04:32 +0000 (UTC)
Cc: vlad.moscow@mail.ru
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCDODCNR2QPRBPHVYSWQKGQETUE6YLA@isocpp.org Thu Jul 23 21:04:30 2015
Return-path: <std-proposals+bncBCDODCNR2QPRBPHVYSWQKGQETUE6YLA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ie0-f197.google.com ([209.85.223.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCDODCNR2QPRBPHVYSWQKGQETUE6YLA@isocpp.org>)
	id 1ZILnC-0001sE-3A
	for gclcip-std-proposals@m.gmane.org; Thu, 23 Jul 2015 21:04:30 +0200
Original-Received: by iebyd10 with SMTP id yd10sf5227568ieb.2
        for <gclcip-std-proposals@m.gmane.org>; Thu, 23 Jul 2015 12:04:29 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:content-type: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=TAU+C7MPFUNerdOg8UMjqvTf3STuKcAhECuISWldVd0=;
        b=pbJwXO7Z3H7/f+VPm4vzwQujp8Sy8DeF+f5UvpOrkxGosZxwf8RVefA3Z6R6LJrr9M
         zI3S9DcebfoDFGR4xzwHTa0D8s3ifXxcCF9rXZicQummEq8b5ZxDeeCaigfHanry6H4B
         O5Q9ZKBVHxOWcgAavo2RJ0WqdL9N9t5a2cOHE+dfHSmbFV5qgHwps7tqLW+8dqHZireo
         NBHiE3lK/ckoqMDl784gqvRNluX5lo8OGrk+DSl49Sg7a5ntqzJrSyqAxZmHvxrPPDnZ
         RXgB5F+ukdHktdnTxkQi3MZ2nUY+ZPB5+cUuzRztsA+Tf/FJ12w5co+IYfWOhVbmxXcJ
         AZHw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to
         :references:subject:mime-version:content-type: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=TAU+C7MPFUNerdOg8UMjqvTf3STuKcAhECuISWldVd0=;
        b=B2K8AqNqEVOIMctllIMEFW3CcKLmGIYaxWAefeOjUiLX9AqlZ7quW2efnoRdgGHnju
         jkVWTLyuyng3ijFomuth26L0WHVLjKfOfX6P+cYQE2wV238543os1a5fbGiEgBU2bOgr
         9q5Vb4cAhZ75UolaTkaNPfQZkCzth7A+U5WACu3c/oiAx0dg1qFDtJrdBr8DTzSCrP1Z
         cn5LnVOU6PVQKGpO1/5anMDvZjHw5UAicgLlByT90om8K3n4cEc6i79sATOs/qGK57nJ
         elwLKS5TIVCXYY9/4k5g1zcfS1ZnAY2AnLlcdG8E6rX3/MQpoH0l+ovtsSx3AZPcPkC+
         v7ZA==
X-Gm-Message-State: ALoCoQnLQ9TAOCAXgZ9wBGNfa3oG0AU3k83q7rgXBBacAU8bd7dL8tmLlviCql0UevqYTMCtOCwi
X-Received: by 10.182.94.240 with SMTP id df16mr9490039obb.17.1437678269313;
        Thu, 23 Jul 2015 12:04:29 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.91.4 with SMTP id ca4ls37559obb.2.gmail; Thu, 23 Jul 2015
 12:04:28 -0700 (PDT)
X-Received: by 10.182.224.166 with SMTP id rd6mr133959obc.21.1437678268424;
        Thu, 23 Jul 2015 12:04:28 -0700 (PDT)
In-Reply-To: <012fd35d-96fd-4775-835e-2105176c4f97@isocpp.org>
X-Original-Sender: Sean.Middleditch@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: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://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>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:19211
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/19211>

------=_Part_1220_396501332.1437678266187
Content-Type: multipart/alternative; 
	boundary="----=_Part_1221_222889290.1437678266187"

------=_Part_1221_222889290.1437678266187
Content-Type: text/plain; charset=UTF-8

This is solved by ranges (there's a proposal in flight derived from 
https://github.com/ericniebler/range-v3). You're trying to treat 
std::pair<iterator, iterator> as a range between the two iterators, which 
is not semantically correct for all possible pairs of iterators. I'd rather 
just leave pair alone and let the ranges proposal solve this by replacing 
the handle of STL uses of pair<iterator, iterator> with a range<iterator>.

In your example it's also solved by array_view, which is really just a form 
of range.

An additional nice thing about the ranges is that begin, end, size, 
operator[], etc. can all be added to the range type as member functions (as 
appropriate for the iterator category).

On Thursday, July 23, 2015 at 10:36:46 AM UTC-7, Vlad from Moscow wrote:
>
> I'd like to  suggest very simple and at the same time very useful  
> overloaded functions std::begin and std::end for standard class std::pair.
>
> Here is a demonstrative program of the idea
>
> #include <iostream>
> #include <utility>
>
> namespace std
> {    
> template <class Iterator>
> Iterator begin( const std::pair<Iterator, Iterator> &p )
> {
>     return p.first;
> }
> template <class Iterator>
> Iterator end( const std::pair<Iterator, Iterator> &p )
> {
>     return p.second;
> }
> }
>

-- 

--- 
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_1221_222889290.1437678266187
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">This is solved by ranges (there&#39;s a proposal in flight=
 derived from https://github.com/ericniebler/range-v3). You&#39;re trying t=
o treat std::pair&lt;iterator, iterator&gt; as a range between the two iter=
ators, which is not semantically correct for all possible pairs of iterator=
s. I&#39;d rather just leave pair alone and let the ranges proposal solve t=
his by replacing the handle of STL uses of pair&lt;iterator, iterator&gt; w=
ith a range&lt;iterator&gt;.<div><br></div><div>In your example it&#39;s al=
so solved by array_view, which is really just a form of range.<br><div><br>=
</div><div>An additional nice thing about the ranges is that begin, end, si=
ze, operator[], etc. can all be added to the range type as member functions=
 (as appropriate for the iterator category).<br><br>On Thursday, July 23, 2=
015 at 10:36:46 AM UTC-7, Vlad from Moscow wrote:<blockquote class=3D"gmail=
_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;p=
adding-left: 1ex;"><div dir=3D"ltr"><div>I&#39;d like to =C2=A0suggest very=
 simple and=C2=A0at the same time very useful=C2=A0 overloaded functions st=
d::begin and std::end for standard class std::pair.</div><div><br></div><di=
v>Here is a demonstrative program of the idea</div><div><br></div><div>#inc=
lude &lt;iostream&gt;</div><div>#include &lt;utility&gt;</div><div><br></di=
v><div>namespace std<br>{=C2=A0=C2=A0=C2=A0 <br>template &lt;class Iterator=
&gt;<br>Iterator begin( const std::pair&lt;Iterator, Iterator&gt; &amp;p )<=
br>{<br>=C2=A0=C2=A0=C2=A0 return p.first;<br>}</div><div>template &lt;clas=
s Iterator&gt;<br>Iterator end( const std::pair&lt;Iterator, Iterator&gt; &=
amp;p )<br>{<br>=C2=A0=C2=A0=C2=A0 return p.second;<br>}<br>}</div></div></=
blockquote></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"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_1221_222889290.1437678266187--
------=_Part_1220_396501332.1437678266187--

.
