220 5881 <CA+cyFgt8E-+Do=CEbnEbk7gytP-g_aLoXDtpeAsbzV9c9j08_A@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Geoffrey Romer <gromer@google.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Remove vector<bool>?
Date: Tue, 27 Aug 2013 09:12:16 -0700
Lines: 178
Approved: news@gmane.org
Message-ID: <CA+cyFgt8E-+Do=CEbnEbk7gytP-g_aLoXDtpeAsbzV9c9j08_A@mail.gmail.com>
References: <CAGsORuDQdeWAO5yjA6=h0hW9Y0Sj4F1gcHB61udw5JFmtx+g4Q@mail.gmail.com>
	<b06daeb3-a585-4c55-aebf-cae643146838@isocpp.org>
	<CAGg_6+O_d85CBjT+cTV6vQqepUTXVvUMV_QUioS6ELpQCav6GQ@mail.gmail.com>
	<521B07D2.8070000@beamways.com>
	<7d0bc129-f8aa-4803-bbd9-bd5ca504d728@isocpp.org>
	<CAGsORuB8omCBfjco6i_zENDn23tx-5wg1jeHuhsGsiVMbGk+Ww@mail.gmail.com>
	<77e0868c-6aed-4578-acc7-7cf1227465f6@isocpp.org>
	<CAGsORuAAZChA8cyx4JTTqRmMNSGQXZyGdzrm9P0WVRMZSSg6Qw@mail.gmail.com>
	<4E5B6BD9-363D-4B42-ACA3-029301F3F54E@gmail.com>
	<CA+cyFgvGeOJQSfXAQg3z2TKXvFY-OYvhp6_EGMx_mxoskys7LQ@mail.gmail.com>
	<CAGsORuCKcuREjDJVyrfL+eHUF8diSENG2sVC2rjGnfOqcyOdBw@mail.gmail.com>
	<5EEBFD4F-87A9-4543-8449-B5CAAC2E29E6@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=047d7b60457ced179c04e4f02263
X-Trace: ger.gmane.org 1377619935 23779 80.91.229.3 (27 Aug 2013 16:12:15 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 27 Aug 2013 16:12:15 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBD74DCN5SYHBBYE76OIAKGQEDUVRC2Q@isocpp.org Tue Aug 27 18:12:18 2013
Return-path: <std-proposals+bncBD74DCN5SYHBBYE76OIAKGQEDUVRC2Q@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qe0-f71.google.com ([209.85.128.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBD74DCN5SYHBBYE76OIAKGQEDUVRC2Q@isocpp.org>)
	id 1VELsP-0001Lg-Mh
	for gclcip-std-proposals@m.gmane.org; Tue, 27 Aug 2013 18:12:17 +0200
Original-Received: by mail-qe0-f71.google.com with SMTP id 1sf5529834qee.2
        for <gclcip-std-proposals@m.gmane.org>; Tue, 27 Aug 2013 09:12:16 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=sN/k2q+rIDTzUFPha8aCDx4fSQeACpCxmXUc8/VcFsE=;
        b=RksjgUowsN/QeGxqAIfE6C41AmJUQ5SL1/qZsODdyuiV2+49fSDW08SuHUGT3aHGkP
         cS7TWvWAhhOZ4+p2ThoOKxJuPK82Ddf0/CVDGKvDu7N5gnr4H1ZJzRhFisxL9Ascftia
         /93t3h2exIWguf1X/TIx7YTgF0SZHmZvBfJtnw1xwzahtlzcoNGMzG6IeX5xgPwJXDsU
         3L/WxeCahbyrGU6eg64ox3IY38j3kyUecmCFCRqqfb1nfxpQJLwqUNP6ccitIOtf8x8J
         WBY6nv77Sm3uMIJBK4rht/tqDEemOxJNHqefz56Z2I+yErhPw0bbVvhVafXWvjt6DRDI
         z+wQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=x-gm-message-state:mime-version:in-reply-to:references:date
         :message-id:subject:from:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe:content-type;
        bh=sN/k2q+rIDTzUFPha8aCDx4fSQeACpCxmXUc8/VcFsE=;
        b=Ywo2JeMsEeYnAB5Yx7tsiBDN9+Hh9tjWB3mirBNFBP6ole1pH9NDwMfPbaFWTZi10P
         8EIG0Se0SUfsPRLiXqBVFkIrmk4rJLvct5vFkfZQb+DemQDFHwWKxJKJ5vcWy7KJQmhA
         X/aLvgmDgXqIetQiQv3rh5zQvFOiPe2kPHwBh0iEhAYjwiQlUyhnTS0aUX9UqLY/LQid
         3bYsYyxGDkDBaDnOb/yfxwZAujiHL6OSLtUxBqOhoqg+7c+q/qDD3LZw7nU0Es3M8Q6j
         Qyxo7J7skdlbTDu+z0N3/2YPbic2SGS2kMKzmOPHYwLW5NgNGbpa7Dn20mk7kMfxayI+
         +cfQ==
X-Received: by 10.236.147.70 with SMTP id s46mr8094633yhj.0.1377619936799;
        Tue, 27 Aug 2013 09:12:16 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.25.2 with SMTP id y2ls3048457qef.91.gmail; Tue, 27 Aug 2013
 09:12:16 -0700 (PDT)
X-Received: by 10.224.63.72 with SMTP id a8mr16591572qai.72.1377619936313;
        Tue, 27 Aug 2013 09:12:16 -0700 (PDT)
Original-Received: from mail-qe0-x236.google.com (mail-qe0-x236.google.com [2607:f8b0:400d:c02::236])
        by mx.google.com with ESMTPS id g8si8388678qam.25.1969.12.31.16.00.00
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Tue, 27 Aug 2013 09:12:16 -0700 (PDT)
Received-SPF: pass (google.com: domain of gromer@google.com designates 2607:f8b0:400d:c02::236 as permitted sender) client-ip=2607:f8b0:400d:c02::236;
Original-Received: by mail-qe0-f54.google.com with SMTP id i11so2690865qej.41
        for <std-proposals@isocpp.org>; Tue, 27 Aug 2013 09:12:16 -0700 (PDT)
X-Gm-Message-State: ALoCoQmZuTrj4Z3e8FHMlT9Fjd2ZEr2yObO5liNxxCmk+owE4DTAX2H0nkv1Bi4K/JHLRkOZZD96srSw3XI5IICgMExruvJNqj2gxLOjHueihgZNnD0F+JqA3z311nfHbRB5pPbR2m2I57pWn5MYvBro9zL4ymKYPvK/WML+MuqW/YTK4dMkt37Z+75aRiAJu3QgFSaESORQolAyk1XeSgigTrNwRTpXkA==
X-Received: by 10.224.166.129 with SMTP id m1mr23414907qay.46.1377619936082;
 Tue, 27 Aug 2013 09:12:16 -0700 (PDT)
Original-Received: by 10.49.12.228 with HTTP; Tue, 27 Aug 2013 09:12:16 -0700 (PDT)
In-Reply-To: <5EEBFD4F-87A9-4543-8449-B5CAAC2E29E6@gmail.com>
X-Original-Sender: gromer@google.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of gromer@google.com designates 2607:f8b0:400d:c02::236 as permitted
 sender) smtp.mail=gromer@google.com;       dkim=pass header.i=@google.com;
       dmarc=pass (p=REJECT dis=NONE) d=google.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <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: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:5881
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/5881>

--047d7b60457ced179c04e4f02263
Content-Type: text/plain; charset=ISO-8859-1

On Mon, Aug 26, 2013 at 5:36 PM, Howard Hinnant <howard.hinnant@gmail.com>wrote:

> On Aug 26, 2013, at 8:28 PM, Zhihao Yuan <zy@miator.net> wrote:
>
> > On Mon, Aug 26, 2013 at 8:16 PM, Geoffrey Romer <gromer@google.com>
> wrote:
> >> template <typename iter_t>
> >> value_type& GetValue(iter_t iter) {
> >>  return *iter;
> >> }
> >
> > I think this can be "corrected" by just replacing the return type
> > with `auto` :(
>
> I was going to suggest:
>
> typename std::iterator_traits<iter_t>::reference
>
> but I like Zhihao's suggestion a lot better.  Unless you need the
> iterator_traits dance for SFINAE purposes.
>
> Bottom line:  All we have to do is stop assuming that *iter returns a
> value_type&.  We already can not assume that for input iterators, do this
> does not seem like a big stretch.  And we already can not assume it for
> output iterators, even though we can use output iterators to modify values.
>

Yes, it's _possible_ to rewrite that code so that it works with a proxy.
I'm just saying that it's _harder_ to write correct code against a proxying
iterator than against a non-proxying one. It's true that "all we have to do
is stop assuming that *iter returns a value_type&", but the "we" here
refers to all C++ programmers, so this is not a small thing, and undefined
behavior is a pretty harsh punishment for those who fail to update
themselves appropriately.

Now, sometimes you need a proxying iterator, because returning value_type&
just isn't possible. That being the case, it's certainly preferable for
such iterators to be a supported part of the iterator framework, and it's
certainly desirable for them to be able to describe themselves accurately
(e.g. vector<bool>::iterator supports random access, but can't return a
value_type&), so I am wholly in favor of decomposing the iterator
categories to describe value-access separately from traversal (along the
lines of n1640), and relaxing the iterator requirements of the standard
algorithms as much as possible.

What I don't want is for the STL container requirements to allow proxying
iterators or, still worse, for the standard iterator concepts to permit
proxying unconditionally. This would render some existing code incorrect,
and worse, it would be incorrect in a subtle way that would probably work
most of the time, because in practice the STL containers are unlikely to
use proxying, so there may be a long lag between when the bug is written
and when it is discovered.


>
> Howard
>
> --
>
> ---
> 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/.
>

-- 

--- 
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/.

--047d7b60457ced179c04e4f02263
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><div class=3D"gmail_quote">=
On Mon, Aug 26, 2013 at 5:36 PM, Howard Hinnant <span dir=3D"ltr">&lt;<a hr=
ef=3D"mailto:howard.hinnant@gmail.com" target=3D"_blank">howard.hinnant@gma=
il.com</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex"><div class=3D"im">On Aug 26, 2013, at 8:28 PM, Zhihao Yuan=
 &lt;<a href=3D"mailto:zy@miator.net">zy@miator.net</a>&gt; wrote:<br>

<br>
&gt; On Mon, Aug 26, 2013 at 8:16 PM, Geoffrey Romer &lt;<a href=3D"mailto:=
gromer@google.com">gromer@google.com</a>&gt; wrote:<br>
&gt;&gt; template &lt;typename iter_t&gt;<br>
&gt;&gt; value_type&amp; GetValue(iter_t iter) {<br>
&gt;&gt; =A0return *iter;<br>
&gt;&gt; }<br>
&gt;<br>
&gt; I think this can be &quot;corrected&quot; by just replacing the return=
 type<br>
&gt; with `auto` :(<br>
<br>
</div>I was going to suggest:<br>
<br>
typename std::iterator_traits&lt;iter_t&gt;::reference<br>
<br>
but I like Zhihao&#39;s suggestion a lot better. =A0Unless you need the ite=
rator_traits dance for SFINAE purposes.<br>
<br>
Bottom line: =A0All we have to do is stop assuming that *iter returns a val=
ue_type&amp;. =A0We already can not assume that for input iterators, do thi=
s does not seem like a big stretch. =A0And we already can not assume it for=
 output iterators, even though we can use output iterators to modify values=
..<br>
</blockquote><div><br></div><div>Yes, it&#39;s _possible_ to rewrite that c=
ode so that it works with a proxy. I&#39;m just saying that it&#39;s _harde=
r_ to write correct code against a proxying iterator than against a non-pro=
xying one. It&#39;s true that &quot;all we have to do is stop assuming that=
 *iter returns a value_type&amp;&quot;, but the &quot;we&quot; here refers =
to all C++ programmers, so this is not a small thing, and undefined behavio=
r is a pretty harsh punishment for those who fail to update themselves appr=
opriately.</div>
<div><br></div><div>Now, sometimes you need a proxying iterator, because re=
turning value_type&amp; just isn&#39;t possible. That being the case, it&#3=
9;s certainly preferable for such iterators to be a supported part of the i=
terator framework, and it&#39;s certainly desirable for them to be able to =
describe themselves accurately (e.g. vector&lt;bool&gt;::iterator supports =
random access, but can&#39;t return a value_type&amp;), so I am wholly in f=
avor of decomposing the iterator categories to describe value-access separa=
tely from traversal (along the lines of n1640), and relaxing the iterator r=
equirements of the standard algorithms as much as possible.</div>
<div><br></div><div>What I don&#39;t want is for the STL container requirem=
ents to allow proxying iterators or, still worse, for the standard iterator=
 concepts to permit proxying unconditionally. This would render some existi=
ng code incorrect, and worse, it would be incorrect in a subtle way that wo=
uld probably work most of the time, because in practice the STL containers =
are unlikely to use proxying, so there may be a long lag between when the b=
ug is written and when it is discovered.</div>
<div>=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px=
 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left=
-style:solid;padding-left:1ex">
<span class=3D""><font color=3D"#888888"><br>
Howard<br>
</font></span><div class=3D""><div class=3D"h5"><br>
--<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%2Bunsubscribe@isocpp.org">std-propo=
sals+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/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />

--047d7b60457ced179c04e4f02263--

.
