220 19219 <39cfa99d-72ab-469c-ab4f-066a9caf628d@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: "T. C." <rs2740@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 13:10:56 -0700 (PDT)
Lines: 328
Approved: news@gmane.org
Message-ID: <39cfa99d-72ab-469c-ab4f-066a9caf628d@isocpp.org>
References: <012fd35d-96fd-4775-835e-2105176c4f97@isocpp.org>
 <dc79f59b-77d2-45f6-96ad-50c704cb873d@isocpp.org>
 <70492682-c1ac-4d67-9c00-fe8d841aae63@isocpp.org>
 <f4f76dbb-96d2-432f-82ed-0df45658f72c@isocpp.org>
 <424cd221-d1c7-4baf-b074-b7f44ee5c82e@isocpp.org>
 <58625b71-98be-4acb-9815-af1ec2113cc6@isocpp.org>
 <ae00798f-2944-44ae-a526-4b8e2aeba2ac@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_878_567141446.1437682257087"
X-Trace: ger.gmane.org 1437682262 32079 80.91.229.3 (23 Jul 2015 20:11:02 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 23 Jul 2015 20:11:02 +0000 (UTC)
Cc: vlad.moscow@mail.ru
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCQ43G7NQIIRBUUUYWWQKGQECJICIPA@isocpp.org Thu Jul 23 22:11:02 2015
Return-path: <std-proposals+bncBCQ43G7NQIIRBUUUYWWQKGQECJICIPA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pa0-f70.google.com ([209.85.220.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCQ43G7NQIIRBUUUYWWQKGQECJICIPA@isocpp.org>)
	id 1ZIMpY-0002w7-Ik
	for gclcip-std-proposals@m.gmane.org; Thu, 23 Jul 2015 22:11:00 +0200
Original-Received: by pacck2 with SMTP id ck2sf5708464pac.0
        for <gclcip-std-proposals@m.gmane.org>; Thu, 23 Jul 2015 13:10:59 -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=ppUkDh/YjqfmBu3QUxQfX3+jRfQ9nKo+/7LzWH9HOoQ=;
        b=cDqrmNzQHBd/UeDtQV8M8xY3nHaqe5eW7r06mIkuZYEwI5fDcuAQb0SNCjt/BOJz7T
         HQfH+hynpexthJ6qUcwhWJ3NV7vkEMZbhU6tMc/2Or06+oEOxx78pBuOc1ybOJGXNFXF
         rssERucGbYD2JDKQVfB4bcEr9YhKOzHw8V4yPHubGy9dK1y8f2a02mR36iOCGkITK70b
         hp/LGrEgPTS1CDadlIrNC0K/RN+ng3tmYBvrE3hQ2dQ/EH3iagImu0JP3N/SXoD4ITKm
         0I+4vDhayAj6sRKAkMwUxX+u9E3TSxz1o70wWV+TjKJHwqxzSmzEVBxHud4JpHRgFipF
         /8Qw==
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=ppUkDh/YjqfmBu3QUxQfX3+jRfQ9nKo+/7LzWH9HOoQ=;
        b=cr5XVJg5tT7IvXYXWlhf3p9W0uUpeeD7dzsCvwvcnWcBJ9D9obol0f6qxjLK7q6Lnh
         e9JJ/WqK87xny8YGTgzGn14u4goLodUZFOptU4khMglk/7PN+jzAwNSINQ9FeH9Pe8v2
         77ILfH+qJZRD6FBHhj1qWSfMeWl45gCyp8l3FaLoKjD0nZWB9GyL3nPVYzcbzR6qw1xP
         U2qD3G9v1Ldy4q+gJOh7rjTRE2FwLoD3b8tDYXm9HsGkJvspqKflBEiVPNVfAMvtXt9T
         B1wC4xCx2I0pvL/MJ74coLQAnLEM11juShQKhChcJsPxoXvZx0DU3Tf9srT9WZeXcimq
         rMGQ==
X-Gm-Message-State: ALoCoQlC10MWMjfiOydczAiU3oXDQkFX8MkAsju4BXU1vqH3a6F+T/cJ9OdBg/dtkgLlNFyS1mi1
X-Received: by 10.70.49.77 with SMTP id s13mr10094195pdn.14.1437682259054;
        Thu, 23 Jul 2015 13:10:59 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.83.7 with SMTP id i7ls1206482qgd.74.gmail; Thu, 23 Jul
 2015 13:10:57 -0700 (PDT)
X-Received: by 10.140.36.170 with SMTP id p39mr232918qgp.28.1437682257737;
        Thu, 23 Jul 2015 13:10:57 -0700 (PDT)
In-Reply-To: <ae00798f-2944-44ae-a526-4b8e2aeba2ac@isocpp.org>
X-Original-Sender: rs2740@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:19219
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/19219>

------=_Part_878_567141446.1437682257087
Content-Type: multipart/alternative; 
	boundary="----=_Part_879_1570981853.1437682257087"

------=_Part_879_1570981853.1437682257087
Content-Type: text/plain; charset=UTF-8

There *were* std::begin/end overloads for std::pair. They were removed 
before C++11 was published, because the committee decided that they 
shouldn't exist, for all the reasons Sean pointed out (also, 
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2995.pdf).

Allowing code like `for(auto p : std::minmax_element(b, e)) { /* stuff */ 
}` to silently compile and cause UB at run time half the time isn't a great 
idea, IMO.

Of course, you don't need to convince me, but given the previous rejection 
of this idea, the Ranges TS on the horizon, and the trivially implemented 
workaround, I'm doubtful that it would find much support in the committee.

On Thursday, July 23, 2015 at 3:35:12 PM UTC-4, Vlad from Moscow wrote:
>
> How is it related to std:;pair?! You can with the same success use 
> iterators in any algorithm that do not make a range and what? Do you 
> suggest not to use algorithms?
>
> On Thursday, July 23, 2015 at 10:29:23 PM UTC+3, T. C. wrote:
>>
>> They existed in an earlier C++0x draft, and were removed by that LWG 
>> issue before C++11 was published.
>>
>> Not all pairs of iterators are ranges. Not even all pairs of iterators 
>> returned by functions in the standard library are ranges,
>> as your own code with minmax_element demonstrates.
>>
>> Besides, a range class that wraps a pair of iterators is trivial to 
>> implement.
>>
>> On Thursday, July 23, 2015 at 3:15:05 PM UTC-4, Vlad from Moscow wrote:
>>>
>>> There is nothing said about introducing functions std::begin and 
>>> std:;end for std::pair.
>>>
>>> On Thursday, July 23, 2015 at 9:52:23 PM UTC+3, T. C. wrote:
>>>>
>>>> http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#1381
>>>>
>>>>
>>>> On Thursday, July 23, 2015 at 2:30:02 PM UTC-4, Vlad from Moscow wrote:
>>>>>
>>>>> And one more example :)
>>>>>
>>>>> #include <iostream>
>>>>> #include <utility>
>>>>> #include <vector>
>>>>> #include <algorithm>
>>>>> #include <iterator>
>>>>>
>>>>> 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()
>>>>> {
>>>>>     std::vector<int> v = { 3, 4, 0, 5, 1, 6, 9, 7, 8 };
>>>>>     
>>>>>     for ( auto x : v ) std::cout << x << ' ';
>>>>>     std::cout << std::endl;
>>>>>     auto p = std::minmax_element( v.begin(), v.end() );
>>>>>     
>>>>>     if ( std::distance( v.begin(), p.second ) < std::distance( 
>>>>> v.begin(), p.first ) )
>>>>>     {
>>>>>         std::swap( p.first, p.second );
>>>>>     }        
>>>>>     for ( auto x : p ) std::cout << x << ' ';
>>>>>     std::cout << std::endl;
>>>>> }    
>>>>>
>>>>> The program output is
>>>>>
>>>>> 3 4 0 5 1 6 9 7 8 
>>>>> 0 5 1 6
>>>>>
>>>>> On Thursday, July 23, 2015 at 8:57:38 PM UTC+3, Vlad from Moscow wrote:
>>>>>
>>>>>> Another example
>>>>>>
>>>>>> #include <iostream>
>>>>>> #include <utility>
>>>>>> #include <vector>
>>>>>>
>>>>>> 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()
>>>>>> {
>>>>>>     std::vector<int> v = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
>>>>>>     
>>>>>>     for ( auto x : std::make_pair( v.begin(), v.end() ) ) std::cout 
>>>>>> << x << ' ';
>>>>>>     std::cout << std::endl;
>>>>>>     
>>>>>>     for ( auto x : std::make_pair( v.rbegin(), v.rend() ) ) std::cout 
>>>>>> << x << ' ';
>>>>>>     std::cout << std::endl;
>>>>>> }    
>>>>>>
>>>>>> The program output is
>>>>>>
>>>>>> 0 1 2 3 4 5 6 7 8 9 
>>>>>> 9 8 7 6 5 4 3 2 1 0
>>>>>>
>>>>>> Enjoy!:)
>>>>>>
>>>>>> On Thursday, July 23, 2015 at 8:36:46 PM UTC+3, 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;
>>>>>>> }
>>>>>>> }
>>>>>>>
>>>>>>> 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_879_1570981853.1437682257087
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">There *were* std::begin/end overloads for std::pair. They =
were removed before C++11 was published, because the committee decided that=
 they shouldn&#39;t exist, for all the reasons Sean pointed out (also, http=
://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2995.pdf).<div><br></d=
iv><div>Allowing code like `for(auto p : std::minmax_element(b, e)) { /* st=
uff */ }` to silently compile and cause UB at run time half the time isn&#3=
9;t a great idea, IMO.</div><div><br></div><div>Of course, you don&#39;t ne=
ed to convince me, but given the previous rejection of this idea, the Range=
s TS on the horizon, and the trivially implemented workaround, I&#39;m doub=
tful that it would find much support in the committee.<br><div><div><br>On =
Thursday, July 23, 2015 at 3:35:12 PM UTC-4, Vlad from Moscow wrote:<blockq=
uote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-lef=
t: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">How is it related to=
 std:;pair?! You can with the same success use iterators in any algorithm t=
hat do not make a range and what? Do you suggest not to use algorithms?<br>=
<br>On Thursday, July 23, 2015 at 10:29:23 PM UTC+3, T. C. wrote:<blockquot=
e class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;=
border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:=
solid"><div dir=3D"ltr">They existed in an earlier C++0x draft, and were re=
moved by that LWG issue before C++11 was published.<div><br></div><div>Not =
all pairs of iterators are ranges. Not even all pairs of iterators returned=
 by functions in the standard library are ranges,</div><div>as your own cod=
e with minmax_element demonstrates.</div><div><br></div><div>Besides, a ran=
ge class that wraps a pair of iterators is trivial to implement.</div><div>=
<br>On Thursday, July 23, 2015 at 3:15:05 PM UTC-4, Vlad from Moscow wrote:=
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding=
-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-l=
eft-style:solid"><div dir=3D"ltr">There is nothing said about introducing f=
unctions std::begin and std:;end for std::pair.<br><br>On Thursday, July 23=
, 2015 at 9:52:23 PM UTC+3, T. C. wrote:<blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204=
,204,204);border-left-width:1px;border-left-style:solid"><div dir=3D"ltr"><=
div><a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html=
#1381" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D&#39;h=
ttp://www.google.com/url?q\75http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2F=
wg21%2Fdocs%2Flwg-defects.html%231381\46sa\75D\46sntz\0751\46usg\75AFQjCNGC=
nw-GAV0E1QTFZv90wIFhv-vtdQ&#39;;return true;" onclick=3D"this.href=3D&#39;h=
ttp://www.google.com/url?q\75http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2F=
wg21%2Fdocs%2Flwg-defects.html%231381\46sa\75D\46sntz\0751\46usg\75AFQjCNGC=
nw-GAV0E1QTFZv90wIFhv-vtdQ&#39;;return true;">http://www.open-std.org/jtc1/=
sc22/wg21/docs/lwg-defects.html#1381</a></div><div><br></div><div><div><br>=
</div><div>On Thursday, July 23, 2015 at 2:30:02 PM UTC-4, Vlad from Moscow=
 wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;=
padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;b=
order-left-style:solid"><div dir=3D"ltr"><div>And one more example :)</div>=
<div><br></div><div>#include &lt;iostream&gt;<br>#include &lt;utility&gt;<b=
r>#include &lt;vector&gt;<br>#include &lt;algorithm&gt;<br>#include &lt;ite=
rator&gt;</div><div><br></div><div>namespace std<br>{=C2=A0=C2=A0=C2=A0 <br=
>template &lt;class Iterator&gt;<br>Iterator begin( const std::pair&lt;Iter=
ator, 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.sec=
ond;<br>}<br>}</div><div>int main()<br>{<br>=C2=A0=C2=A0=C2=A0 std::vector&=
lt;int&gt; v =3D { 3, 4, 0, 5, 1, 6, 9, 7, 8 };<br>=C2=A0=C2=A0=C2=A0 <br>=
=C2=A0=C2=A0=C2=A0 for ( auto x : v ) 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 auto p =3D std::minmax_element( v.begin(), v.end() );<br>=C2=
=A0=C2=A0=C2=A0 <br>=C2=A0=C2=A0=C2=A0 if ( std::distance( v.begin(), p.sec=
ond ) &lt; std::distance( v.begin(), p.first ) )<br>=C2=A0=C2=A0=C2=A0 {<br=
>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 std::swap( p.first, p.second );=
<br>=C2=A0=C2=A0=C2=A0 }=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 </div><d=
iv>=C2=A0=C2=A0=C2=A0 for ( auto x : p ) 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>=
}=C2=A0=C2=A0=C2=A0 <br><br></div><div>The program output is</div><div><br>=
</div><div>3 4 0 5 1 6 9 7 8 <br>0 5 1 6</div><div><br>On Thursday, July 23=
, 2015 at 8:57:38 PM UTC+3, Vlad from Moscow wrote:</div><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;border-=
left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">=
<div dir=3D"ltr"><div>Another example</div><div><br></div><div>#include &lt=
;iostream&gt;<br>#include &lt;utility&gt;<br>#include &lt;vector&gt;</div><=
div><br></div><div>namespace std<br>{=C2=A0=C2=A0=C2=A0 <br></div><div><br>=
</div><div>template &lt;class Iterator&gt;<br>Iterator begin( const std::pa=
ir&lt;Iterator, Iterator&gt; &amp;p )<br>{<br>=C2=A0=C2=A0=C2=A0 return p.f=
irst;<br>}</div><div><br></div><div>template &lt;class Iterator&gt;<br>Iter=
ator 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>}</div><div=
><br></div><div>int main()<br>{<br>=C2=A0=C2=A0=C2=A0 std::vector&lt;int&gt=
; v =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( v.begin(), v.end() ) ) std::cou=
t &lt;&lt; x &lt;&lt; &#39; &#39;;<br>=C2=A0=C2=A0=C2=A0 std::cout &lt;&lt;=
 std::endl;<br>=C2=A0=C2=A0=C2=A0 <br>=C2=A0=C2=A0=C2=A0 for ( auto x : std=
::make_pair( v.rbegin(), v.rend() ) ) 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 <br></div><div><br></div><div>The program output is</div><div>=
<br></div><div>0 1 2 3 4 5 6 7 8 9 <br>9 8 7 6 5 4 3 2 1 0</div><div><br></=
div><div>Enjoy!:)<br><br>On Thursday, July 23, 2015 at 8:36:46 PM UTC+3, Vl=
ad from Moscow wrote:</div><blockquote class=3D"gmail_quote" style=3D"margi=
n:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);bor=
der-left-width:1px;border-left-style:solid"><div dir=3D"ltr"><div>I&#39;d l=
ike to =C2=A0suggest very simple and=C2=A0at the same time very useful=C2=
=A0 overloaded functions std::begin and std::end for standard class std::pa=
ir.</div><div><br></div><div>Here is a demonstrative program of the idea</d=
iv><div><br></div><div>#include &lt;iostream&gt;</div><div>#include &lt;uti=
lity&gt;</div><div><br></div><div>namespace std<br>{=C2=A0=C2=A0=C2=A0 <br>=
template &lt;class Iterator&gt;<br>Iterator begin( const std::pair&lt;Itera=
tor, 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.seco=
nd;<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::co=
ut &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::make_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></div><div>The program output is</d=
iv><div><br></div><div>3 4 5 6 <br>2 3 4 5=C2=A0=C2=A0=C2=A0 <br></div></di=
v></blockquote></div></blockquote></div></blockquote></div></div></div></bl=
ockquote></div></blockquote></div></div></blockquote></div></blockquote></d=
iv></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_879_1570981853.1437682257087--
------=_Part_878_567141446.1437682257087--

.
