220 33168 <CAMmfjbPSGa_AiSOieY9jo9FPY5EaZn852RGTMO85kV+h7CRMig@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Brian Bi <bbi5291@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Add a few missing things from the iterator library
Date: Mon, 10 Jul 2017 11:49:20 -0700
Lines: 128
Approved: news@gmane.org
Message-ID: <CAMmfjbPSGa_AiSOieY9jo9FPY5EaZn852RGTMO85kV+h7CRMig@mail.gmail.com>
References: <e45d0f40-ac12-4df3-9532-8c9481e7791a@isocpp.org> <CAGNvRgBnrZXiiQQy_8eVukE-F365uuXgwFMffvdNbyJ+_S=O2g@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="001a1141c70c76c2260553fb0a53"
X-Trace: blaine.gmane.org 1499712563 26044 195.159.176.226 (10 Jul 2017 18:49:23 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 10 Jul 2017 18:49:23 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDS5ZX5VU4NBBMMYR7FQKGQESKPUP4A@isocpp.org Mon Jul 10 20:49:18 2017
Return-path: <std-proposals+bncBDS5ZX5VU4NBBMMYR7FQKGQESKPUP4A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pg0-f72.google.com ([74.125.83.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDS5ZX5VU4NBBMMYR7FQKGQESKPUP4A@isocpp.org>)
	id 1dUdkD-0006Sr-MB
	for gclcip-std-proposals@m.gmane.org; Mon, 10 Jul 2017 20:49:17 +0200
Original-Received: by mail-pg0-f72.google.com with SMTP id u5sf124205328pgq.14
        for <gclcip-std-proposals@m.gmane.org>; Mon, 10 Jul 2017 11:49:23 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1499712563; cv=pass;
        d=google.com; s=arc-20160816;
        b=OuFiRA3zoVtVT+ySGFgtUu07yrMIdwC9mJDsPHE4euBxAGeanHm+sHcAMX0hodz/gI
         og2h7BVBpRkB06E0HXLtMnVKGDSh7kJlNjNcMBvhpFxjv5nMUZMxqgAz3p51mWY6d3BD
         EN398CDcku5YXmXEHhYxlO9rJhUpUqZIXlBq6IZjbu1DwBEOfyliZXTsvcdoPdpfeFNI
         iL2vdboChrMpsB6CopC1XI5J50VmSAgg+dhDAgxwecAytDPUiLGSEjrKkb0CPoF8MCyl
         taQnb/LrEYrBev7Wf6Jy0O4TAxIvwZ99d4k6B48ea9mdtJgvDfuvrOkSHZhTNxLSOnks
         Q0cw==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:references:in-reply-to:mime-version:arc-authentication-results
         :arc-message-signature:dkim-signature:arc-authentication-results;
        bh=f8a2qCxt8zeGRcwDJyXwT8WJWj6EMdDCIpO5wneyf2w=;
        b=sMe7VyVMZV+hZPzOSMRotV4KknVSax3Qju469Bij/MNXkrzpbviuZuPmQWJBUyZ0ru
         pZuGBS8yO5K5MLaHcd+4mP6prymlBFhF4JtrmiplQFC9qttU2+LOLjnHgn4ti5EUWtHk
         fSWuUVUMlOfxu1+OnWV8ofwH9zPDEM+8kvYRJvGuXYGSoPxx7+88OZVl9sBh2eGb4qYd
         I/NOub9aDmq5jSEVrIbN/c4OjWnX13++hYAfHsKgwhMQ4uEUz1C9jhze9TFqrf0xo2nq
         ibGSEVVpX+HdK3tdPYz5+8oM3B3f0BdlZ17Bvw7xn4rJeUWHM49EVfjt5bRofJ+be2k3
         swmg==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.b=NrMxtuXS;
       spf=pass (google.com: domain of bbi5291@gmail.com designates 2607:f8b0:4003:c06::22c as permitted sender) smtp.mailfrom=bbi5291@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:from:date:message-id:subject: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;
        bh=f8a2qCxt8zeGRcwDJyXwT8WJWj6EMdDCIpO5wneyf2w=;
        b=HKxWTHslTbWZR9QJXwQ0FSCapVCwWaTx1BoyHvx9Ysj3D+4b10yO8NxSBpe4Hr1Gfp
         aQQHDpleaptB0pVBbul4YcJiCGwUqlE/aWlJ4zQOPqL84mVDIzQcO/+h6TfmRgdmc6qM
         UCI4wY5rHMnUtDa2OnYN4A1Kaw2L8rrCQehjPZplqUlPO/82PbECiSGN8hHF1dmrP9vJ
         l9ashkU6Xi2FZmT3aW5FpJyp21rh/VgflHt0lXNBoYzt39njnvKazIdHX0BME0nG9D7c
         7CQScXuvQw1c3h4ljDE4IBfCWPIXabTDnjB6ZUQZlZaNfjTMA4PGfPcJf7aDaSDbGAym
         Ou9Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=f8a2qCxt8zeGRcwDJyXwT8WJWj6EMdDCIpO5wneyf2w=;
        b=KFztsQZaiTgsJZ8NDJhFwF75uSo3ij/7XK3IdHkbxeU/JBvgxpKBWt3h8P7YN+bjy6
         +ejlq99pj3BuqPWBgpe5VlJFkf7pEnmDlvkb8optfppGKVvVduS/pCDwIG5bfuFTs4S0
         yXN9P0evMHbodFWwcSyPQ5qfP9hUKJb54vLYADRm4F8n0AQkbaKc+zr9yOy1hizzHAac
         kNloAYm+O1u6t/NI5Y84c4pUj7XKjVdh5+GrnRQI6rCqRICToeZXpHP6fcAafztSq/oF
         8XQnW8yCgc0ujcV2pPLAUKqSMVaCrTsG9ob1L5NIP8zZv+58WG+BHwbyqDGcuP0T072K
         nbMg==
X-Gm-Message-State: AIVw110gWc8ApmWR60HewnOwDNb4nRHpmJBW/sLk/c2X43H0HG5c71bq
	egyT2TZ+D6j+ocdX
X-Received: by 10.99.175.24 with SMTP id w24mr12952966pge.2.1499712562948;
        Mon, 10 Jul 2017 11:49:22 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.36.73.147 with SMTP id e19ls148711itd.1.gmail; Mon, 10 Jul
 2017 11:49:21 -0700 (PDT)
X-Received: by 10.202.179.85 with SMTP id c82mr8639208oif.198.1499712561329;
        Mon, 10 Jul 2017 11:49:21 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1499712561; cv=none;
        d=google.com; s=arc-20160816;
        b=BNaSkBykRC+yWQrCvjSlCfhOTHSU5JbcK3tQHxpIVKSCeIoiwHXrKuR2FRMs6RIh0W
         LccbBGMOcMpW/WaDvho0Jtxt7+99NoSgw9Cj1i6OI72dZWnrXuDMbNzP7tmP2wXwoX2N
         M6hKWGsr/iWRO/XCUZN/iY6Cvo/Xgrlna4N2Vk4kwOFPlTl5Lb3PRmeV3CwuJoYggYKJ
         uKh1qh9GJRhP99+aU+J+W8+Oq8PlhmdOV3CjMWIcYmavYIgW2Sm9QY3mScIwaJ5Gxjxb
         ONQLb9WSGzf3cmUZdD7FKGEcKNotMKgMfiYceMZmXB64gl73oMTEaRDuNhI41rVpHCM/
         oyFA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:references:in-reply-to:mime-version
         :dkim-signature:arc-authentication-results;
        bh=8tLxCnmNNcR3ociWAdmTAxwhRNdUHe4bWrRw6xBjBSE=;
        b=uKk2YhBtPXbUY4BdXpij00l8XcQ2NFhN4PNscN820cEO8OOOvmnMMROuaOn5591YmW
         Ly2TpaCEAVajOyc10kdyZxAR1eUYJMD9xHMQaVYKZbh/6doyvHwgvMPdnSxuHllvg2xw
         XEfW3flSXgTiFutRsX6kZq9jfY5UnTCgLPdP5HcnV1/WoRkgn+vd4dXDYvAERZvFYhXB
         VAcKf9+wfkEwMeDxbzXbOCKYzXshn9w6+XAPTeQ5wHzbQpjqmyZBDhcBUoRFJ4JmJOqW
         v60PdOOY5NGyS0Wosd5kPgMJZ5a9EhlK4/4a06g8hwyY4YNNq3pdDCYAuQehSGvqsUU2
         VKqA==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.b=NrMxtuXS;
       spf=pass (google.com: domain of bbi5291@gmail.com designates 2607:f8b0:4003:c06::22c as permitted sender) smtp.mailfrom=bbi5291@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Original-Received: from mail-oi0-x22c.google.com (mail-oi0-x22c.google.com. [2607:f8b0:4003:c06::22c])
        by mx.google.com with ESMTPS id q185si8791980oig.68.2017.07.10.11.49.21
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 10 Jul 2017 11:49:21 -0700 (PDT)
Received-SPF: pass (google.com: domain of bbi5291@gmail.com designates 2607:f8b0:4003:c06::22c as permitted sender) client-ip=2607:f8b0:4003:c06::22c;
Original-Received: by mail-oi0-x22c.google.com with SMTP id 191so82834475oii.2
        for <std-proposals@isocpp.org>; Mon, 10 Jul 2017 11:49:21 -0700 (PDT)
X-Received: by 10.202.227.130 with SMTP id a124mr10507937oih.52.1499712561003;
 Mon, 10 Jul 2017 11:49:21 -0700 (PDT)
Original-Received: by 10.74.56.14 with HTTP; Mon, 10 Jul 2017 11:49:20 -0700 (PDT)
In-Reply-To: <CAGNvRgBnrZXiiQQy_8eVukE-F365uuXgwFMffvdNbyJ+_S=O2g@mail.gmail.com>
X-Original-Sender: bbi5291@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.b=NrMxtuXS;       spf=pass (google.com: domain of
 bbi5291@gmail.com designates 2607:f8b0:4003:c06::22c as permitted sender)
 smtp.mailfrom=bbi5291@gmail.com;       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.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: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://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>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:33168
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/33168>

--001a1141c70c76c2260553fb0a53
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Mon, Jul 10, 2017 at 11:21 AM, Daniel Kr=C3=BCgler <daniel.kruegler@gmai=
l.com>
wrote:

> 2017-07-10 19:47 GMT+02:00  <gafunchal@gmail.com>:
> > Hi,
> >
> > I propose to add to <iterator>:
>
> [..]
>
> > 2) std::make_const_iterator(iterator)
> > Semantics: return iterator static_cast-ed to const_iterator
> > Why: We have std::make_move_iterator so again I believe this is missing=
..
> > Container requirements (23.2) specify that iterators must be convertibl=
e
> to
> > const_iterator so I believe this is just a static_cast.
> >
> > 3) std::container_of_t<decltype(iterator)>
> > Semantics: determine the container type of the iterator
> > Why: Helpful to implement 2 above, also helpful in a variety of
> situations
> > where there's a need to check requirements on the container of an
> iterator.
>
> These two proposals make assumptions that are neither met by current
> implementations nor implied by the standard: There is no 1:1 relation
> between container type and iterator type, which makes both (2) and (3)
> impossible. It would also break non-Standard-Library implementations
> of containers such as from Boost or other third-party libraries.
>

I think 2 is possible though it may not necessarily have desirable
properties. It can have a generic implementation that returns a
std::const_iterator<Iterator> (where std::const_iterator is an adaptor
template similar to std::move_iterator). It can be partially specialized on
T* to return const T* and then container libraries can add custom overloads
for their own iterator types that will be found via ADL, but only if the
iterator type isn't T* or something like that.

--=20
*Brian Bi*

--=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CAMmfjbPSGa_AiSOieY9jo9FPY5EaZn852RGTMO85kV%2Bh7=
CRMig%40mail.gmail.com.

--001a1141c70c76c2260553fb0a53
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Mon, Jul 10, 2017 at 11:21 AM, Daniel Kr=C3=BCgler <span dir=3D"ltr"=
>&lt;<a href=3D"mailto:daniel.kruegler@gmail.com" target=3D"_blank">daniel.=
kruegler@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quot=
e" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">=
<span class=3D"">2017-07-10 19:47 GMT+02:00=C2=A0 &lt;<a href=3D"mailto:gaf=
unchal@gmail.com">gafunchal@gmail.com</a>&gt;:<br>
&gt; Hi,<br>
&gt;<br>
&gt; I propose to add to &lt;iterator&gt;:<br>
<br>
</span>[..]<br>
<span class=3D""><br>
&gt; 2) std::make_const_iterator(<wbr>iterator)<br>
&gt; Semantics: return iterator static_cast-ed to const_iterator<br>
&gt; Why: We have std::make_move_iterator so again I believe this is missin=
g.<br>
&gt; Container requirements (23.2) specify that iterators must be convertib=
le to<br>
&gt; const_iterator so I believe this is just a static_cast.<br>
&gt;<br>
&gt; 3) std::container_of_t&lt;decltype(<wbr>iterator)&gt;<br>
&gt; Semantics: determine the container type of the iterator<br>
&gt; Why: Helpful to implement 2 above, also helpful in a variety of situat=
ions<br>
&gt; where there&#39;s a need to check requirements on the container of an =
iterator.<br>
<br>
</span>These two proposals make assumptions that are neither met by current=
<br>
implementations nor implied by the standard: There is no 1:1 relation<br>
between container type and iterator type, which makes both (2) and (3)<br>
impossible. It would also break non-Standard-Library implementations<br>
of containers such as from Boost or other third-party libraries.<br></block=
quote><div><br></div><div>I think 2 is possible though it may not necessari=
ly have desirable properties. It can have a generic implementation that ret=
urns a std::const_iterator&lt;Iterator&gt; (where std::const_iterator is an=
 adaptor template similar to std::move_iterator). It can be partially speci=
alized on T* to return const T* and then container libraries can add custom=
 overloads for their own iterator types that will be found via ADL, but onl=
y if the iterator type isn&#39;t T* or something like that.<br></div><div>=
=C2=A0</div></div>-- <br><div class=3D"gmail_signature" data-smartmail=3D"g=
mail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><font color=3D"#c0c0=
c0"><i>Brian Bi</i></font><br><div></div><div></div><div></div></div></div>=
</div></div>
</div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAMmfjbPSGa_AiSOieY9jo9FPY5EaZn852RGT=
MO85kV%2Bh7CRMig%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAMmfjbPSGa_AiS=
OieY9jo9FPY5EaZn852RGTMO85kV%2Bh7CRMig%40mail.gmail.com</a>.<br />

--001a1141c70c76c2260553fb0a53--

.
