220 19207 <012fd35d-96fd-4775-835e-2105176c4f97@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Vlad from Moscow <vlad.moscow@mail.ru>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Overloading std::begin and std::end for std::pair
Date: Thu, 23 Jul 2015 10:36:46 -0700 (PDT)
Lines: 100
Approved: news@gmane.org
Message-ID: <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_737_309793220.1437673006283"
X-Trace: ger.gmane.org 1437673009 8858 80.91.229.3 (23 Jul 2015 17:36:49 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 23 Jul 2015 17:36:49 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCXLLRHD7IDRBL6MYSWQKGQEOUCVBHQ@isocpp.org Thu Jul 23 19:36:49 2015
Return-path: <std-proposals+bncBCXLLRHD7IDRBL6MYSWQKGQEOUCVBHQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ig0-f197.google.com ([209.85.213.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCXLLRHD7IDRBL6MYSWQKGQEOUCVBHQ@isocpp.org>)
	id 1ZIKQK-0006Ny-Qz
	for gclcip-std-proposals@m.gmane.org; Thu, 23 Jul 2015 19:36:49 +0200
Original-Received: by igbij6 with SMTP id ij6sf3267595igb.1
        for <gclcip-std-proposals@m.gmane.org>; Thu, 23 Jul 2015 10:36:48 -0700 (PDT)
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:message-id: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=5t+uSCz8lFdd7TjoybKuJz7r7TsnmHrzwNbssei5vLA=;
        b=YTdrr0w9MXtUUBADbtb8Z63d8iBRL5EUnKHaYK/JdycjYIkcTPfefZHssFgrz32Lr9
         qP1X7MTILhzArNesEctWG7uSSWlLlp46WAvjXjVTRGTMb5VmExHXeAQT4Eell1SNnzlL
         pY3jMpc+FxIDIYViRY0vB18vfqPAXWWF6H8Jk3a4obOmA96zrK7ozCseHJ9WMjOezyTg
         N/yjJPcMEuVOLlKeoUKud01MT9b7IO9PHPAbKsnuHCVBFPsLIK+ugy0TGp7j9xEGsULC
         8zIHFDcjpG2RqvyaUo9BKyd3nXXc02P9/laFrUu+sY+/kbQGGSd2o79WXLFaaXPDsDBo
         YrBw==
X-Gm-Message-State: ALoCoQnWRQk0++6ZeY6P0FJ+7WaGRpT73/4BdfZOxt3x/PPQlqp1cV5lytGlsXoROC804VASbK59
X-Received: by 10.182.165.196 with SMTP id za4mr9343569obb.20.1437673007996;
        Thu, 23 Jul 2015 10:36:47 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.92.246 with SMTP id b109ls1071769qge.83.gmail; Thu, 23 Jul
 2015 10:36:46 -0700 (PDT)
X-Received: by 10.140.94.166 with SMTP id g35mr204001qge.1.1437673006942;
        Thu, 23 Jul 2015 10:36:46 -0700 (PDT)
X-Original-Sender: vlad.moscow@mail.ru
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:19207
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/19207>

------=_Part_737_309793220.1437673006283
Content-Type: multipart/alternative; 
	boundary="----=_Part_738_963777742.1437673006283"

------=_Part_738_963777742.1437673006283
Content-Type: text/plain; charset=UTF-8

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;
}
}

int main()
{
    int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    
    for ( auto x : std::make_pair( a + 3, a + 7 ) ) std::cout << x << ' ';
    std::cout << std::endl;
    
    int b[][3] = { { 1, 2, 3 }, { 4, 5, 6 } };
    
    for ( auto x : std::make_pair( b[0] + 1, b[1] + 2 ) ) std::cout << x << 
' ';
    std::cout << std::endl;
}

The program output is

3 4 5 6 
2 3 4 5    

-- 

--- 
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_738_963777742.1437673006283
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<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 std::begin and std::e=
nd for standard class std::pair.</div><div><br></div><div>Here is a demonst=
rative program of the idea</div><div><br></div><div>#include &lt;iostream&g=
t;</div><div>#include &lt;utility&gt;</div><div><br></div><div>namespace st=
d<br>{=C2=A0=C2=A0=C2=A0 <br>template &lt;class Iterator&gt;<br>Iterator be=
gin( 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;class 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><br></div><div>int =
main()<br>{<br>=C2=A0=C2=A0=C2=A0 int a[] =3D { 0, 1, 2, 3, 4, 5, 6, 7, 8, =
9 };<br>=C2=A0=C2=A0=C2=A0 <br>=C2=A0=C2=A0=C2=A0 for ( auto x : std::make_=
pair( a + 3, a + 7 ) ) std::cout &lt;&lt; x &lt;&lt; &#39; &#39;;<br>=C2=A0=
=C2=A0=C2=A0 std::cout &lt;&lt; std::endl;</div><div>=C2=A0=C2=A0=C2=A0=C2=
=A0<br>=C2=A0=C2=A0=C2=A0 int b[][3] =3D { { 1, 2, 3 }, { 4, 5, 6 } };</div=
><div>=C2=A0=C2=A0=C2=A0=C2=A0<br>=C2=A0=C2=A0=C2=A0 for ( auto x : std::ma=
ke_pair( b[0] + 1, b[1] + 2 ) ) std::cout &lt;&lt; x &lt;&lt; &#39; &#39;;<=
br>=C2=A0=C2=A0=C2=A0 std::cout &lt;&lt; std::endl;<br>}</div><div><br></di=
v><div>The program output is</div><div><br></div><div>3 4 5 6 <br>2 3 4 5=
=C2=A0=C2=A0=C2=A0 <br></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_738_963777742.1437673006283--
------=_Part_737_309793220.1437673006283--

.
