220 19244 <9c360e55-9315-4585-9402-a813a4765e8d@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: inkwizytoryankes@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Overloading std::begin and std::end for std::pair
Date: Fri, 24 Jul 2015 11:59:16 -0700 (PDT)
Lines: 529
Approved: news@gmane.org
Message-ID: <9c360e55-9315-4585-9402-a813a4765e8d@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>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_439_767270575.1437764356352"
X-Trace: ger.gmane.org 1437764374 14644 80.91.229.3 (24 Jul 2015 18:59:34 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 24 Jul 2015 18:59:34 +0000 (UTC)
Cc: sasha2048@gmail.com, vlad.moscow@mail.ru
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDDLTAGNTIBBBBMWZKWQKGQEISR7FDY@isocpp.org Fri Jul 24 20:59:21 2015
Return-path: <std-proposals+bncBDDLTAGNTIBBBBMWZKWQKGQEISR7FDY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ig0-f199.google.com ([209.85.213.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDDLTAGNTIBBBBMWZKWQKGQEISR7FDY@isocpp.org>)
	id 1ZIiBj-0006o5-BB
	for gclcip-std-proposals@m.gmane.org; Fri, 24 Jul 2015 20:59:19 +0200
Original-Received: by igbqa2 with SMTP id qa2sf44830796igb.0
        for <gclcip-std-proposals@m.gmane.org>; Fri, 24 Jul 2015 11:59:18 -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=qAQvrviRvYll/f1zytYC/zounj3Q3QFcjSCiVG50wr0=;
        b=bCH7cL7DrCuEL2Cc2rbjNnCnbDuXSbu1DCq/sIC5yi+9mQntWlincLYtwTRiNBZ8b1
         dMqXR3LMTev7lJZDGlCiOXzA7zvoUGrSNdSkpIv5EihtPQFS5m7vPoEFhorcUb1SPVPn
         w7LOr/PE7c6TAN1z5svdHj4hExQ0VzVEIVCCgM7UPxS5UZQYeUx/EddqHcRPEGPCXaUB
         0f2eB6omdnGGHgudbc+qp/jGl/7uEjCYY9rHaOfFanbARTKBu+DH80IXgN1UPqdT43g/
         sX3kIQf0oF4m61qco7s18WJuRZ73QD2sJlC6MJ+LxwfQrB/XfOlE1NyFZ0SdMNkF4VsR
         J1zw==
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=qAQvrviRvYll/f1zytYC/zounj3Q3QFcjSCiVG50wr0=;
        b=TT4gp7AY5Y+/bfFUW+oHTLLKVuEWaGFle8E4J1Us20gwFZ8lXtfM3fqAGV1xQERLLJ
         vb6E694CQ4A5iu56NVC/W9e/EzFv9ayzOVBxwQFdJ1faOB9zHjxvzQQJvWeFcsSBsUQB
         UrRcfTk1x+AusD4d9x8RXR9GonGcMaTV6O19+dlvlWkt6VlJ7lAn2USvPBy6u8YnTSpD
         d1Q4LHjbaVNfLoa+itmUPBJ56h0QPqWlNzqmE9Lo2EKKfatzVEjFXj0i9c4vBmNL6goi
         ZgflQPfZGRbvKItGKMWOuyyIjoZF8k8HPAadWLuokpfTWOsub5MqSmU/yasA9aOvjpI6
         G8lQ==
X-Gm-Message-State: ALoCoQkZ0NmDtSnwXuZQtDl4zKNk346LKPebxpoZnAD96ncVD0vCccpw54/CfRo8JBbZ7YoSsGsG
X-Received: by 10.107.157.76 with SMTP id g73mr14209622ioe.32.1437764358292;
        Fri, 24 Jul 2015 11:59:18 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.99.36 with SMTP id p33ls1622628qge.51.gmail; Fri, 24 Jul
 2015 11:59:17 -0700 (PDT)
X-Received: by 10.140.33.199 with SMTP id j65mr325934qgj.31.1437764357175;
        Fri, 24 Jul 2015 11:59:17 -0700 (PDT)
In-Reply-To: <d8e0f792-23ba-4555-9910-00bd87d6e1ca@isocpp.org>
X-Original-Sender: inkwizytoryankes@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:19244
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/19244>

------=_Part_439_767270575.1437764356352
Content-Type: multipart/alternative; 
	boundary="----=_Part_440_2084545534.1437764356354"

------=_Part_440_2084545534.1437764356354
Content-Type: text/plain; charset=UTF-8

If some object have `begin` and `end` then its range. Most pair aren't 
ranges then they should not have this functions.
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_440_2084545534.1437764356354
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">If some object have `begin` and `end` then its range. Most=
 pair aren&#39;t ranges then they should not have this functions.<br>If som=
e objects don&#39;t give you guarantees about something but you know in som=
e cases 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>Probab=
ly solution for this problem are tagged pairs and tuples (IIRC they are for=
m range proposition).<br>It look something like that:<br><div class=3D"pret=
typrint" style=3D"background-color: rgb(250, 250, 250); border-color: rgb(1=
87, 187, 187); border-style: solid; border-width: 1px; word-wrap: break-wor=
d;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">extern</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> tab</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">[</span><span style=3D"color: #066;" class=3D"styled-by-pret=
tify">10</span><span style=3D"color: #660;" class=3D"styled-by-prettify">];=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>st=
d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">pair</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">std</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">begin_tag</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">int</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">*&gt;,</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
end_tag</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt=
;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">*&gt;&gt;</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> a</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>std</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">pair</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">std</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">ptr_tag</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">*&gt;,</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">success_tag</span><span style=
=3D"color: #080;" class=3D"styled-by-prettify">&lt;bool&gt;</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> b</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br><br>a</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">.</span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">begin</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> tab</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">//equal a.first =3D tab;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br>a</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">end</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> tab </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">+</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #066;" class=3D"styled-by-prettify">10</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #8=
00;" class=3D"styled-by-prettify">//equal a.second =3D tab + 10;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">for</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">auto</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> x </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">if</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">x </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">=3D=3D</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettif=
y">5</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 b</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
ptr</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">x</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 b</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">success</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">true</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">return</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">;</span></div></code></div><br><br><br><br>On Friday, July=
 24, 2015 at 3:10:03 PM UTC+2, Vlad from Moscow wrote:<blockquote class=3D"=
gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc so=
lid;padding-left: 1ex;"><div dir=3D"ltr"><br><br>On Friday, July 24, 2015 a=
t 3:50:58 PM UTC+3, Sasha Unknown 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">To T. C. and Sean =
Middleditch: Thank you for you patience. While 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-le=
ft:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left=
-style:solid">On Fri, Jul 24, 2015 at 10:36 AM, Vlad from Moscow &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 href=3D"http://macieira.info"=
 rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D&#39;http://=
www.google.com/url?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46us=
g\75AFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;return true;" onclick=3D"this.h=
ref=3D&#39;http://www.google.com/url?q\75http%3A%2F%2Fmacieira.info\46sa\75=
D\46sntz\0751\46usg\75AFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;return true;"=
>macieira.info</a> - thiago (AT) <a href=3D"http://kde.org" rel=3D"nofollow=
" target=3D"_blank" onmousedown=3D"this.href=3D&#39;http://www.google.com/u=
rl?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75AFQjCNHGRJdo5_JYG1=
DowztwAHAKs80XSA&#39;;return true;" onclick=3D"this.href=3D&#39;http://www.=
google.com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75AFQjCN=
HGRJdo5_JYG1DowztwAHAKs80XSA&#39;;return true;">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 href=3D"http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D&#39;htt=
p://groups.google.com/a/isocpp.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;">http://groups.google.com/a/isocpp.org/group/=
std-proposals/</a>.
<br></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_440_2084545534.1437764356354--
------=_Part_439_767270575.1437764356352--

.
