220 19249 <dcbc314d-a2a4-4afe-a80d-4125d1835a2f@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: Re: Re: Overloading std::begin and std::end for std::pair
Date: Fri, 24 Jul 2015 13:06:21 -0700 (PDT)
Lines: 647
Approved: news@gmane.org
Message-ID: <dcbc314d-a2a4-4afe-a80d-4125d1835a2f@isocpp.org>
References: <012fd35d-96fd-4775-835e-2105176c4f97@isocpp.org>
 <e61080cb-ca1f-4426-a6be-4618ffe88cfe@isocpp.org>
 <792fab39-5af7-4d95-b9ba-a5cc4aed8544@isocpp.org>
 <8100167.A1Y3soRlXn@tjmaciei-mobl4>
 <15e678b3-9b6b-4966-a7a5-1d37495fda5e@isocpp.org>
 <CAMSC8GNY-CQ+=nD59acZ6-qWbmNK5Fh2JjOHOq6ekxeeG3Lmdg@mail.gmail.com>
 <d8e0f792-23ba-4555-9910-00bd87d6e1ca@isocpp.org>
 <9c360e55-9315-4585-9402-a813a4765e8d@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1082_1582433338.1437768381872"
X-Trace: ger.gmane.org 1437768404 17207 80.91.229.3 (24 Jul 2015 20:06:44 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 24 Jul 2015 20:06:44 +0000 (UTC)
Cc: sasha2048@gmail.com, inkwizytoryankes@gmail.com
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCXLLRHD7IDRBPVVZKWQKGQE3FO3S4Q@isocpp.org Fri Jul 24 22:06:29 2015
Return-path: <std-proposals+bncBCXLLRHD7IDRBPVVZKWQKGQE3FO3S4Q@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ie0-f199.google.com ([209.85.223.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCXLLRHD7IDRBPVVZKWQKGQE3FO3S4Q@isocpp.org>)
	id 1ZIjEf-0002ek-Ni
	for gclcip-std-proposals@m.gmane.org; Fri, 24 Jul 2015 22:06:26 +0200
Original-Received: by iebyd10 with SMTP id yd10sf55468367ieb.2
        for <gclcip-std-proposals@m.gmane.org>; Fri, 24 Jul 2015 13:06:25 -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: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=DhDF8QtmoOvYK1Hn7S5MLynreIr66CvAeAQURc6YRb8=;
        b=FzOLccdDd+TflbBlrHoja6DVK0CvmeyW7ZDETXkQIYyKdJalT1N/S2HusXd8Kdy01N
         AvCaMqMMG2N2+C64hjNjizHV/Lhs09/WQwDueKwfpnZEfBRT9Lg5NoHbdEKDr0Lkug0A
         H31LQrost1cxsnIdT3FZyZk+Lbb97nNzx5OqIA1hdtRhythN0e3sQPpxl935EzYk1aCV
         pIR+O4iIXke1TQRdSwQdqXhUp8mskpAH5C0I4UtGsUnYvX8F7ryHVi8FXYGcPMr+z2c5
         X325lKb00BqMc9jw9sWxPLLY/mxh6onog9HGSO9XzQgdtBqkRVmT18oHpI1WRLftzOh8
         MBcA==
X-Gm-Message-State: ALoCoQmSbwX9xt4XoPfwuM+XUf2Ml+4hmri1Z+5Nm4v7YI9g+XnH6TUJ2s2bf31++VGX7xejIGUh
X-Received: by 10.107.7.220 with SMTP id g89mr14718847ioi.2.1437768384976;
        Fri, 24 Jul 2015 13:06:24 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.17.170 with SMTP id 39ls1743055qgd.6.gmail; Fri, 24 Jul
 2015 13:06:22 -0700 (PDT)
X-Received: by 10.140.91.182 with SMTP id z51mr321692qgd.5.1437768382554;
        Fri, 24 Jul 2015 13:06:22 -0700 (PDT)
In-Reply-To: <9c360e55-9315-4585-9402-a813a4765e8d@isocpp.org>
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:19249
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/19249>

------=_Part_1082_1582433338.1437768381872
Content-Type: multipart/alternative; 
	boundary="----=_Part_1083_1495154463.1437768381873"

------=_Part_1083_1495154463.1437768381873
Content-Type: text/plain; charset=UTF-8



On Friday, July 24, 2015 at 9:59:16 PM UTC+3, inkwizyt...@gmail.com wrote:
>
> If some object have `begin` and `end` then its range. Most pair aren't 
> ranges then they should not have this functions.
>

Most pointers are not ranges. Does it mean that pointers can not make up a 
range? 

Consider for example a dynamically allocated array. Does it has a range?

How will you specify its range? I think you will specify it as a pair of 
pointers will not you? So for example if you allocated an integer array of 
size n and the address of the allocated area was stored in pointer a then 
pair a and a + n set a valid range. How do you specify pairs in C++? I 
suspect that you use std::pair.

std::pair<int *, int *> range( a, a + n );

or

auto range = std::make_pair( a, a + n );


So if you have a pair that specifiers a valid range then you expect this 
range can be used in for example the for range statement

So it is natural and locgically consistent for example to write

for ( int x : range ) std::cout << x << ' ';

It is a valid record. Why? Because object range defines a valid range. It 
already exists. There is no need to invent some superconstructions that to 
convert this valid range in the same valid range, You already have it.

Another example that I showed early is using either algorithm or class 
methods equal_range. They all return a valid range do not they?

Thus std::pair is an integral part of algorithms and ranges. It is already 
used to specify a valid range. There is nothing to invent. All you need is 
to have an access to elements of the ranges they make up. To have an access 
means that you need to get accfess to the beginning of the range and to the 
end of the range.

You have such an access simply writing

for ( auto begin = p.first, end = p.second; begin != end; ++begin ) { 
/*...*/ }

There is no any need to deform algorithms. All you need you already have in 
your disposal. 

Only instead of 

for ( auto begin = p.first, end = p.second; begin != end; ++begin ) { 
/*...*/ }

it is better to write

for ( x : p ) { /(...*/ }

However according to your logic you prefer to use only this record of the 
loop

for ( auto begin = p.first, end = p.second; begin != end; ++begin ) { 
/*...*/ }

Why? Because your argument is that std::pair does not set a range.:) It is 
funny.:) 

I am sorry I do not see any logic in your words. 

Of course you can create a class that will be named something like ranges.  
You can even to build a hierarchy of such classes and numerous 
specializations of the classes. :)

But to use the range that is held in an object of type std::pair your 
classes are useless.

All examples of code that I showed in this thread I wrote literally in 5-10 
minutes without inventing any classes. Because it is natural way of using 
std::pair having a range.

On the other hand your hierarchy of classes of ranges has been created if I 
am not mistaken already several years. And in the examples I showed their 
usage is no more than the usage of soap bubbles. 

 

> If some objects don't give you guarantees about something but you know in 
> some cases it true then proper way of use is EXPLICITLY show that it hold 
> true.
> In our case `std::make_range` fulfill this requirements.
>
> Probably solution for this problem are tagged pairs and tuples (IIRC they 
> are form range proposition).
> It look something like that:
>
> extern int tab[10];
>
> std::pair<std::begin_tag<int*>, std::end_tag<int*>> a;
> std::pair<std::ptr_tag<int*>, std::success_tag<bool>> b;
>
> a.begin() = tab; //equal a.first = tab;
> a.end() = tab + 10; //equal a.second = tab + 10;
> for (auto& x : a)
> {
>     if (x == 5)
>     {
>         b.ptr() = &x;
>         b.success() = true;
>     }
> }
> return b;
>
>
>
>
> On Friday, July 24, 2015 at 3:10:03 PM UTC+2, Vlad from Moscow wrote:
>>
>>
>>
>> On Friday, July 24, 2015 at 3:50:58 PM UTC+3, Sasha Unknown wrote:
>>>
>>> To T. C. and Sean Middleditch: Thank you for you patience. While I 
>>> don't like the this proposal of Vlad from Moscow for many reasons, I 
>>> appreciate patience and level of detail in your responses. At some 
>>> point in future these patience and detail-level may save some good but 
>>> ugly-looking proposal. 
>>>
>>> To Vlad from Moscow: 
>>> 1. Just to satisfy my interest: Aren't you coming to C++ from some 
>>> dynamically-typed language? 
>>> 2. If n2995 and/or D4128 would be accepted, they will satisfy all your 
>>> requests: 
>>>     for ( auto x : std::make_range( a + 3, a + 7 ) ) ...; 
>>>     for ( auto p : m.equal_range( 'A' ) ) ...; 
>>>
>>>
>> It seems you do not understand. There is no any need to build a 
>> superconstruction or to deform algorithms that to do this in clear and 
>> natural way.
>>
>> The C++ Standard already has all needed to do the task.  And if you have 
>> a pair of iterators that make up a range then why do you need to build a 
>> range from already existent valid range?! Simply write
>>
>>     for ( auto x : p ) ...; 
>>
>> There is such principle KISS in programming that means Keep It Simple 
>> Stupid.
>>
>> The programmer should not pay for what he totally need not.
>>
>> What you are suggesting looks the following way. I have a notebook. You 
>> come to my home take away my notebook and say: "Pay me and i will give you 
>> a notebook". And after I paid you return me my notebook.
>>
>> Excelent idea!
>>
>>
>>
>>
>> On Fri, Jul 24, 2015 at 10:36 AM, Vlad from Moscow <vlad....@mail.ru> 
>>> wrote: 
>>> > 
>>> > 
>>> > On Friday, July 24, 2015 at 1:58:22 AM UTC+3, Thiago Macieira wrote: 
>>> >> 
>>> >> On Thursday 23 July 2015 12:31:59 Vlad from Moscow wrote: 
>>> >> > Could you explain why do I need some ranges when this program looks 
>>> >> > clear 
>>> >> > and nice without any ranges? 
>>> >> 
>>> >> Because you made it so that std::pair<T, T> is always a range, but 
>>> that 
>>> >> isn't 
>>> >> the case. In fact, I'd argue that most people who think of 
>>> "iterating" 
>>> >> over a 
>>> >> pair expect it to behave as an array of two elements: the first and 
>>> the 
>>> >> second. 
>>> >> 
>>> > 
>>> > There is a serious logical mistake. If for example two pointers can 
>>> make up 
>>> > a range this does not mean that any two pointers is a range or that 
>>> any 
>>> > range is two pointers. Even two iterators of the same container or two 
>>> > pointers of the same array might not make a range. 
>>> > 
>>> > std::pair is simply a media that can store iterators. It is used in 
>>> > algorithm std::mismatch where iterators does not make up a range or in 
>>> the 
>>> > algorithm or class methods  equal_range where pointers make up a 
>>> range. 
>>> > 
>>> > It is a responsibility of the programmer to use appropriate iterators 
>>> that 
>>> > are stored in the media. 
>>> > 
>>> > So you and Sean Middleditch attempts to substitute the meaning of 
>>>  std::pair 
>>> > for the role like just ranges are false and confuse programmers. 
>>> > It is responsibility of the programmer to correctly use std::pair in 
>>> > different situations. 
>>> > 
>>> > With the same success you can use any valid C++ construction 
>>> incorrectly. 
>>> > For example you can return a reference to a local variable of a 
>>> function. 
>>> > Does it mean that something wrong with references and the programmers 
>>> shall 
>>> > not declare function return types as references? 
>>> > 
>>> > According to your false logic it follows that the programmers indeed 
>>> shall 
>>> > not declare function return types as references 
>>> > 
>>> > The ptoblem is why should the programmer pay for the means that he 
>>> totally 
>>> > need not? 
>>> > 
>>> > I showed already an example with std::multimap where the code looks 
>>> clear 
>>> > and nice. But you are saying: "Stop! Programs must not be so clear and 
>>> nice. 
>>> > You have to declare a class hierarchy and use these additional classes 
>>> to do 
>>> > a simple and entirely correct thing." 
>>> > 
>>> > Why do the programmer have to use a suoerstructure when he already has 
>>> a 
>>> > range that he stored on such a media like std::pair? 
>>> > 
>>> > And moreover now Sean Middleditch is even going to deform standard 
>>> > algorithms with the only purpose that all programmers used his useless 
>>> > superstructures where all can be done simply and clear without them. 
>>> > 
>>> > 
>>> >> I'd expect: 
>>> >> 
>>> >> template<typename T> const T* begin(const pair<T, T> &p) 
>>> >> { return &p.first; } 
>>> >> 
>>> >> template<typename T> const T *end(const pair<T, T> &p) 
>>> >> { return &p.second + 1; } 
>>> >> 
>>> >> Which allows me to run: 
>>> >> 
>>> >> int main() 
>>> >> { 
>>> >>         for (auto i : std::make_pair(1, 2)) 
>>> >>                 cout << i << ' '; 
>>> >>         cout << endl; 
>>> >> } 
>>> >> 
>>> >> output: 1 2 
>>> >> -- 
>>> >> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org 
>>> >>    Software Architect - Intel Open Source Technology Center 
>>> >>       PGP/GPG: 0x6EF45358; fingerprint: 
>>> >>       E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358 
>>> >> 
>>> > -- 
>>> > 
>>> > --- 
>>> > 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-proposal...@isocpp.org. 
>>> > To post to this group, send email to std-pr...@isocpp.org. 
>>> > Visit this group at 
>>> > http://groups.google.com/a/isocpp.org/group/std-proposals/. 
>>>
>>

-- 

--- 
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_1083_1495154463.1437768381873
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Friday, July 24, 2015 at 9:59:16 PM UTC+3, inkw=
izyt...@gmail.com 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-left-style: solid;"><div dir=3D"ltr">If so=
me object have `begin` and `end` then its range. Most pair aren&#39;t range=
s then they should not have this functions.<br></div></blockquote><div><br>=
</div><div>Most pointers are not ranges. Does it mean that pointers can not=
 make up a range? </div><div><br></div><div>Consider for example a dynamica=
lly allocated array. Does it has a range?</div><div><br></div><div>How will=
 you specify its range? I think you will specify it as a pair of pointers w=
ill not you? So for example if you allocated an integer array of size n and=
 the address of the allocated area was stored in pointer=C2=A0a then pair=
=C2=A0a and=C2=A0a + n set a valid range. How do you specify pairs in C++? =
I suspect that you use std::pair.</div><div><br></div><div>std::pair&lt;int=
 *, int *&gt; range( a, a + n );</div><div><br></div><div>or</div><div><br>=
</div><div>auto range =3D std::make_pair( a, a + n );</div><div><br></div><=
div><br></div><div>So if you have a pair that specifiers a valid range then=
 you expect this range can be used in for example the for range statement</=
div><div><br></div><div>So it is natural and locgically consistent for exam=
ple to write</div><div><br></div><div>for ( int x :=C2=A0range ) std::cout =
&lt;&lt; x &lt;&lt; &#39; &#39;;</div><div><br></div><div>It is a valid rec=
ord. Why? Because=C2=A0object range defines a valid range. It already exist=
s. There is no need to invent some superconstructions that to convert this =
valid range in the same valid range, You already have it.</div><div><br></d=
iv><div>Another example that I showed early is using either algorithm or cl=
ass methods equal_range. They all return a valid range do not they?</div><d=
iv><br></div><div>Thus std::pair is an integral part of algorithms and rang=
es. It is already used to specify a valid range. There is nothing to invent=
.. All you need is to have an access to elements of the ranges they make up.=
 To have an access means that you need to get accfess to the beginning of t=
he range and to the end of the range.</div><div><br></div><div>You have suc=
h an access simply writing</div><div><br></div><div>for ( auto begin =3D p.=
first, end =3D p.second; begin !=3D end; ++begin ) { /*...*/ }</div><div><b=
r></div><div>There is no any need to deform algorithms.=C2=A0All you need y=
ou already have in your disposal.=C2=A0</div><div><br></div><div>Only inste=
ad of </div><div><br></div><div><div>for ( auto begin =3D p.first, end =3D =
p.second; begin !=3D end; ++begin ) { /*...*/ }</div><div><br></div><div>it=
 is better to write</div><div><br></div><div>for ( x : p ) { /(...*/ }</div=
><div><br></div><div>However according to your logic you prefer to use only=
=C2=A0this=C2=A0record of the loop</div><div><br></div><div><div>for ( auto=
 begin =3D p.first, end =3D p.second; begin !=3D end; ++begin ) { /*...*/ }=
</div><div><br></div><div>Why? Because your argument is that std::pair does=
 not set a range.:) It is funny.:)=C2=A0</div><div><br></div><div>I am sorr=
y I do not see any logic in your words. </div><div><br></div><div>Of course=
 you can create a class that will be named something=C2=A0like ranges.=C2=
=A0 You can even to build a hierarchy of such classes and numerous speciali=
zations of the classes. :)</div><div><br></div><div>But to use the range th=
at is held in an object of type std::pair your classes are useless.</div><d=
iv><br></div><div>All examples of code that I showed in this thread I wrote=
 literally in 5-10 minutes without inventing any classes. Because it is nat=
ural way of using std::pair having a range.</div><div><br></div><div>On the=
 other hand your hierarchy of classes of ranges has been created if I am no=
t mistaken already several years. And in the examples I showed their usage =
is no more than the usage of soap bubbles. </div><div><br></div><div>=C2=A0=
</div></div></div><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0p=
x 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); bord=
er-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr">If some obj=
ects don&#39;t give you guarantees about something but you know in some cas=
es it true then proper way of use is EXPLICITLY show that it hold true.<br>=
In our case `std::make_range` fulfill this requirements.<br><br>Probably so=
lution for this problem are tagged pairs and tuples (IIRC they are form ran=
ge proposition).<br>It look something like that:<br><div style=3D"border: 1=
px solid rgb(187, 187, 187); border-image: none; -ms-word-wrap: break-word;=
 background-color: rgb(250, 250, 250);"><code><div><span style=3D"color: rg=
b(0, 0, 0);"><br></span><span style=3D"color: rgb(0, 0, 136);">extern</span=
><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, =
0, 136);">int</span><span style=3D"color: rgb(0, 0, 0);"> tab</span><span s=
tyle=3D"color: rgb(102, 102, 0);">[</span><span style=3D"color: rgb(0, 102,=
 102);">10</span><span style=3D"color: rgb(102, 102, 0);">];</span><span st=
yle=3D"color: rgb(0, 0, 0);"><br><br>std</span><span style=3D"color: rgb(10=
2, 102, 0);">::</span><span style=3D"color: rgb(0, 0, 0);">pair</span><span=
 style=3D"color: rgb(102, 102, 0);">&lt;</span><span style=3D"color: rgb(0,=
 0, 0);">std</span><span style=3D"color: rgb(102, 102, 0);">::</span><span =
style=3D"color: rgb(0, 0, 0);">begin_tag</span><span style=3D"color: rgb(10=
2, 102, 0);">&lt;</span><span style=3D"color: rgb(0, 0, 136);">int</span><s=
pan style=3D"color: rgb(102, 102, 0);">*&gt;,</span><span style=3D"color: r=
gb(0, 0, 0);"> std</span><span style=3D"color: rgb(102, 102, 0);">::</span>=
<span style=3D"color: rgb(0, 0, 0);">end_tag</span><span style=3D"color: rg=
b(102, 102, 0);">&lt;</span><span style=3D"color: rgb(0, 0, 136);">int</spa=
n><span style=3D"color: rgb(102, 102, 0);">*&gt;&gt;</span><span style=3D"c=
olor: rgb(0, 0, 0);"> a</span><span style=3D"color: rgb(102, 102, 0);">;</s=
pan><span style=3D"color: rgb(0, 0, 0);"><br>std</span><span style=3D"color=
: rgb(102, 102, 0);">::</span><span style=3D"color: rgb(0, 0, 0);">pair</sp=
an><span style=3D"color: rgb(102, 102, 0);">&lt;</span><span style=3D"color=
: rgb(0, 0, 0);">std</span><span style=3D"color: rgb(102, 102, 0);">::</spa=
n><span style=3D"color: rgb(0, 0, 0);">ptr_tag</span><span style=3D"color: =
rgb(102, 102, 0);">&lt;</span><span style=3D"color: rgb(0, 0, 136);">int</s=
pan><span style=3D"color: rgb(102, 102, 0);">*&gt;,</span><span style=3D"co=
lor: rgb(0, 0, 0);"> std</span><span style=3D"color: rgb(102, 102, 0);">::<=
/span><span style=3D"color: rgb(0, 0, 0);">success_tag</span><span style=3D=
"color: rgb(0, 136, 0);">&lt;bool&gt;</span><span style=3D"color: rgb(102, =
102, 0);">&gt;</span><span style=3D"color: rgb(0, 0, 0);"> b</span><span st=
yle=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0)=
;"><br><br>a</span><span style=3D"color: rgb(102, 102, 0);">.</span><span s=
tyle=3D"color: rgb(0, 0, 136);">begin</span><span style=3D"color: rgb(102, =
102, 0);">()</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color: rgb(0, 0, 0);=
"> tab</span><span style=3D"color: rgb(102, 102, 0);">;</span><span style=
=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(136, 0, 0);">//=
equal a.first =3D tab;</span><span style=3D"color: rgb(0, 0, 0);"><br>a</sp=
an><span style=3D"color: rgb(102, 102, 0);">.</span><span style=3D"color: r=
gb(0, 0, 136);">end</span><span style=3D"color: rgb(102, 102, 0);">()</span=
><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102=
, 102, 0);">=3D</span><span style=3D"color: rgb(0, 0, 0);"> tab </span><spa=
n style=3D"color: rgb(102, 102, 0);">+</span><span style=3D"color: rgb(0, 0=
, 0);"> </span><span style=3D"color: rgb(0, 102, 102);">10</span><span styl=
e=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"=
> </span><span style=3D"color: rgb(136, 0, 0);">//equal a.second =3D tab + =
10;</span><span style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"co=
lor: rgb(0, 0, 136);">for</span><span style=3D"color: rgb(0, 0, 0);"> </spa=
n><span style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rg=
b(0, 0, 136);">auto</span><span style=3D"color: rgb(102, 102, 0);">&amp;</s=
pan><span style=3D"color: rgb(0, 0, 0);"> x </span><span style=3D"color: rg=
b(102, 102, 0);">:</span><span style=3D"color: rgb(0, 0, 0);"> a</span><spa=
n style=3D"color: rgb(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0=
, 0);"><br></span><span style=3D"color: rgb(102, 102, 0);">{</span><span st=
yle=3D"color: rgb(0, 0, 0);"><br>=C2=A0 =C2=A0 </span><span style=3D"color:=
 rgb(0, 0, 136);">if</span><span style=3D"color: rgb(0, 0, 0);"> </span><sp=
an style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, =
0, 0);">x </span><span style=3D"color: rgb(102, 102, 0);">=3D=3D</span><spa=
n style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 102, =
102);">5</span><span style=3D"color: rgb(102, 102, 0);">)</span><span style=
=3D"color: rgb(0, 0, 0);"><br>=C2=A0 =C2=A0 </span><span style=3D"color: rg=
b(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 b</span><span style=3D"color: rgb(102, 102, 0);">.</sp=
an><span style=3D"color: rgb(0, 0, 0);">ptr</span><span style=3D"color: rgb=
(102, 102, 0);">()</span><span style=3D"color: rgb(0, 0, 0);"> </span><span=
 style=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color: rgb(0, =
0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">&amp;</span><span =
style=3D"color: rgb(0, 0, 0);">x</span><span style=3D"color: rgb(102, 102, =
0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 b</span><span style=3D"color: rgb(102, 102, 0);">.</span><span style=
=3D"color: rgb(0, 0, 0);">success</span><span style=3D"color: rgb(102, 102,=
 0);">()</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"=
color: rgb(102, 102, 0);">=3D</span><span style=3D"color: rgb(0, 0, 0);"> <=
/span><span style=3D"color: rgb(0, 0, 136);">true</span><span style=3D"colo=
r: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br>=C2=
=A0 =C2=A0 </span><span style=3D"color: rgb(102, 102, 0);">}</span><span st=
yle=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(102, 102,=
 0);">}</span><span style=3D"color: rgb(0, 0, 0);"><br></span><span style=
=3D"color: rgb(0, 0, 136);">return</span><span style=3D"color: rgb(0, 0, 0)=
;"> b</span><span style=3D"color: rgb(102, 102, 0);">;</span></div></code><=
/div><br><br><br><br>On Friday, July 24, 2015 at 3:10:03 PM UTC+2, Vlad fro=
m Moscow wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0=
px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-=
left-width: 1px; border-left-style: solid;"><div dir=3D"ltr"><br><br>On Fri=
day, July 24, 2015 at 3:50:58 PM UTC+3, Sasha Unknown wrote:<blockquote cla=
ss=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; b=
order-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-s=
tyle: solid;">To T. C. and Sean Middleditch: Thank you for you patience. Wh=
ile I
<br>don&#39;t like the this proposal of Vlad from Moscow for many reasons, =
I
<br>appreciate patience and level of detail in your responses. At some
<br>point in future these patience and detail-level may save some good but
<br>ugly-looking proposal.
<br>
<br>To Vlad from Moscow:
<br>1. Just to satisfy my interest: Aren&#39;t you coming to C++ from some
<br>dynamically-typed language?
<br>2. If n2995 and/or D4128 would be accepted, they will satisfy all your =
requests:
<br>=C2=A0 =C2=A0 for ( auto x : std::make_range( a + 3, a + 7 ) ) ...;
<br>=C2=A0 =C2=A0 for ( auto p : m.equal_range( &#39;A&#39; ) ) ...;
<br>
<br></blockquote><div><br></div><div>It seems you do not understand. There =
is no any need to=C2=A0build a superconstruction or to deform algorithms th=
at to do this in clear and natural way.</div><div><br></div><div>The C++ St=
andard already has all=C2=A0needed to do the task.=C2=A0 And if you have a =
pair of iterators that make up a range then why do you need to build a rang=
e from already existent valid range?! Simply write</div><div><br></div><div=
>=C2=A0=C2=A0=C2=A0 for ( auto=C2=A0x :=C2=A0p ) ...; </div><div><br></div>=
<div>There is such principle KISS in programming that means Keep It Simple =
Stupid.</div><div><br></div><div>The=C2=A0programmer should not pay for wha=
t he totally need not.</div><div><br></div><div>What you are suggesting loo=
ks the following way. I have a notebook. You come to my home take away my n=
otebook and say: &quot;Pay me and i will give you a notebook&quot;. And aft=
er I paid you=C2=A0return me my notebook.</div><div><br></div><div>Excelent=
 idea!</div><div><br></div><div><br></div><div><br></div><div><br></div><bl=
ockquote 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;">On Fri, Jul 24, 2015 at 10:36 AM, Vlad from Mosco=
w &lt;<a rel=3D"nofollow">vlad....@mail.ru</a>&gt; wrote:
<br>&gt;
<br>&gt;
<br>&gt; On Friday, July 24, 2015 at 1:58:22 AM UTC+3, Thiago Macieira wrot=
e:
<br>&gt;&gt;
<br>&gt;&gt; On Thursday 23 July 2015 12:31:59 Vlad from Moscow wrote:
<br>&gt;&gt; &gt; Could you explain why do I need some ranges when this pro=
gram looks
<br>&gt;&gt; &gt; clear
<br>&gt;&gt; &gt; and nice without any ranges?
<br>&gt;&gt;
<br>&gt;&gt; Because you made it so that std::pair&lt;T, T&gt; is always a =
range, but that
<br>&gt;&gt; isn&#39;t
<br>&gt;&gt; the case. In fact, I&#39;d argue that most people who think of=
 &quot;iterating&quot;
<br>&gt;&gt; over a
<br>&gt;&gt; pair expect it to behave as an array of two elements: the firs=
t and the
<br>&gt;&gt; second.
<br>&gt;&gt;
<br>&gt;
<br>&gt; There is a serious logical mistake. If for example two pointers ca=
n make up
<br>&gt; a range this does not mean that any two pointers is a range or tha=
t any
<br>&gt; range is two pointers. Even two iterators of the same container or=
 two
<br>&gt; pointers of the same array might not make a range.
<br>&gt;
<br>&gt; std::pair is simply a media that can store iterators. It is used i=
n
<br>&gt; algorithm std::mismatch where iterators does not make up a range o=
r in the
<br>&gt; algorithm or class methods =C2=A0equal_range where pointers make u=
p a range.
<br>&gt;
<br>&gt; It is a responsibility of the programmer to use appropriate iterat=
ors that
<br>&gt; are stored in the media.
<br>&gt;
<br>&gt; So you and Sean Middleditch attempts to substitute the meaning of =
=C2=A0std::pair
<br>&gt; for the role like just ranges are false and confuse programmers.
<br>&gt; It is responsibility of the programmer to correctly use std::pair =
in
<br>&gt; different situations.
<br>&gt;
<br>&gt; With the same success you can use any valid C++ construction incor=
rectly.
<br>&gt; For example you can return a reference to a local variable of a fu=
nction.
<br>&gt; Does it mean that something wrong with references and the programm=
ers shall
<br>&gt; not declare function return types as references?
<br>&gt;
<br>&gt; According to your false logic it follows that the programmers inde=
ed shall
<br>&gt; not declare function return types as references
<br>&gt;
<br>&gt; The ptoblem is why should the programmer pay for the means that he=
 totally
<br>&gt; need not?
<br>&gt;
<br>&gt; I showed already an example with std::multimap where the code look=
s clear
<br>&gt; and nice. But you are saying: &quot;Stop! Programs must not be so =
clear and nice.
<br>&gt; You have to declare a class hierarchy and use these additional cla=
sses to do
<br>&gt; a simple and entirely correct thing.&quot;
<br>&gt;
<br>&gt; Why do the programmer have to use a suoerstructure when he already=
 has a
<br>&gt; range that he stored on such a media like std::pair?
<br>&gt;
<br>&gt; And moreover now Sean Middleditch is even going to deform standard
<br>&gt; algorithms with the only purpose that all programmers used his use=
less
<br>&gt; superstructures where all can be done simply and clear without the=
m.
<br>&gt;
<br>&gt;
<br>&gt;&gt; I&#39;d expect:
<br>&gt;&gt;
<br>&gt;&gt; template&lt;typename T&gt; const T* begin(const pair&lt;T, T&g=
t; &amp;p)
<br>&gt;&gt; { return &amp;p.first; }
<br>&gt;&gt;
<br>&gt;&gt; template&lt;typename T&gt; const T *end(const pair&lt;T, T&gt;=
 &amp;p)
<br>&gt;&gt; { return &amp;p.second + 1; }
<br>&gt;&gt;
<br>&gt;&gt; Which allows me to run:
<br>&gt;&gt;
<br>&gt;&gt; int main()
<br>&gt;&gt; {
<br>&gt;&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 for (auto i : std::make_pair(1, 2)=
)
<br>&gt;&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cout &=
lt;&lt; i &lt;&lt; &#39; &#39;;
<br>&gt;&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 cout &lt;&lt; endl;
<br>&gt;&gt; }
<br>&gt;&gt;
<br>&gt;&gt; output: 1 2
<br>&gt;&gt; --
<br>&gt;&gt; Thiago Macieira - thiago (AT) <a onmousedown=3D"this.href=3D&#=
39;http://www.google.com/url?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46sntz=
\0751\46usg\75AFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;return true;" onclick=
=3D"this.href=3D&#39;http://www.google.com/url?q\75http%3A%2F%2Fmacieira.in=
fo\46sa\75D\46sntz\0751\46usg\75AFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;ret=
urn true;" href=3D"http://macieira.info" target=3D"_blank" rel=3D"nofollow"=
>macieira.info</a> - thiago (AT) <a onmousedown=3D"this.href=3D&#39;http://=
www.google.com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75AF=
QjCNHGRJdo5_JYG1DowztwAHAKs80XSA&#39;;return true;" onclick=3D"this.href=3D=
&#39;http://www.google.com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\075=
1\46usg\75AFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA&#39;;return true;" href=3D"htt=
p://kde.org" target=3D"_blank" rel=3D"nofollow">kde.org</a>
<br>&gt;&gt; =C2=A0 =C2=A0Software Architect - Intel Open Source Technology=
 Center
<br>&gt;&gt; =C2=A0 =C2=A0 =C2=A0 PGP/GPG: 0x6EF45358; fingerprint:
<br>&gt;&gt; =C2=A0 =C2=A0 =C2=A0 E067 918B B660 DBD1 105C =C2=A0966C 33F5 =
F005 6EF4 5358
<br>&gt;&gt;
<br>&gt; --
<br>&gt;
<br>&gt; ---
<br>&gt; You received this message because you are subscribed to the Google=
 Groups
<br>&gt; &quot;ISO C++ Standard - Future Proposals&quot; group.
<br>&gt; To unsubscribe from this group and stop receiving emails from it, =
send an
<br>&gt; email to <a rel=3D"nofollow">std-proposal...@isocpp.org</a>.
<br>&gt; To post to this group, send email to <a rel=3D"nofollow">std-pr...=
@isocpp.org</a>.
<br>&gt; Visit this group at
<br>&gt; <a onmousedown=3D"this.href=3D&#39;http://groups.google.com/a/isoc=
pp.org/group/std-proposals/&#39;;return true;" onclick=3D"this.href=3D&#39;=
http://groups.google.com/a/isocpp.org/group/std-proposals/&#39;;return true=
;" href=3D"http://groups.google.com/a/isocpp.org/group/std-proposals/" targ=
et=3D"_blank" rel=3D"nofollow">http://groups.google.com/a/isocpp.org/group/=
std-proposals/</a>.
<br></blockquote></div></blockquote></div></blockquote></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_1083_1495154463.1437768381873--
------=_Part_1082_1582433338.1437768381872--

.
