220 39304 <CAOHCbisY24xBK9zEYvpaS9SLFhWwfzxLo=PsuFd9AncLW1VQew@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Tony V E <tvaneerd@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Standardising a type-erased iterator
Date: Mon, 23 Jul 2018 11:01:58 -0400
Lines: 406
Approved: news@gmane.org
Message-ID: <CAOHCbisY24xBK9zEYvpaS9SLFhWwfzxLo=PsuFd9AncLW1VQew@mail.gmail.com>
References: <09db196a-e818-4d7a-9af1-48f07b2f4c3d@isocpp.org>
 <CALvx3hZkVPxg3E0MBPBeXnNwK9szQ5o6O7Gs2ab_omXt8R8=qw@mail.gmail.com>
 <24d8f121-aba9-4ead-b107-bc4b72014870@isocpp.org> <CALvx3hbfFAyh7twxd73DdPYXkrs8chxjsRL9kYzd5kk2VmgD1Q@mail.gmail.com>
 <c9664ef6-f769-4942-8e44-56761d091efc@isocpp.org> <CALvx3haDm01D7jCvJJA3JJycraXVZ_WHz9A4md5h1WXhCR29cg@mail.gmail.com>
 <CAOHCbivaZbbS-zsx4nSzs3uggAxvWSze0zgVnrGm5dAfy=+Hnw@mail.gmail.com> <CALvx3hZWBkQB0SGDqaD5iY_-kez7ibnj6wj3jT=btXtUoUr=zg@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="00000000000052f7820571abed0b"
X-Trace: blaine.gmane.org 1532357994 23377 195.159.176.226 (23 Jul 2018 14:59:54 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 23 Jul 2018 14:59:54 +0000 (UTC)
To: Standard Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCUZ5QWKNQIORW6X3ICRUBACCIBV2@isocpp.org Mon Jul 23 16:59:50 2018
Return-path: <std-proposals+bncBCUZ5QWKNQIORW6X3ICRUBACCIBV2@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f70.google.com ([209.85.218.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCUZ5QWKNQIORW6X3ICRUBACCIBV2@isocpp.org>)
	id 1fhcJS-0005yA-9F
	for gclcip-std-proposals@m.gmane.org; Mon, 23 Jul 2018 16:59:50 +0200
Original-Received: by mail-oi0-f70.google.com with SMTP id j5-v6sf759824oiw.13
        for <gclcip-std-proposals@m.gmane.org>; Mon, 23 Jul 2018 08:02:01 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1532358121; cv=pass;
        d=google.com; s=arc-20160816;
        b=JdOYl3Dir7p4xJcJyT7XHDVYKQKNnaf8/ImZBTxu5hgKhpwjQTX5o7AgHCzWYgosSq
         2LRvtE7tJoG05evGw4pv6PClxSCdumfBzQqh5XerVJzO05q/EcXqH4Ty4dMQ4hYqUGQl
         nb14Rx+g6PgQYEKJDKF4TjhwuZHQgnzz6N/KaH3SVBFBU0jSOyYeTRFYNxU4nZLy710g
         R0MEj+vWeC2dNsvR7ZqVVLjubHauDTvktLU93U8BYYyKl1R4u+knwSBHjDCZOuekfSbL
         YQV4o8+fXOhvbG0FeV639qfpbj//33kQ+nCEna9fD0ZF1eD8I+PI8Uj4v+9Y7VAw306V
         wI4Q==
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=W9IpodNHbriCrU8OC+PMken8v41p9RKtR2I3O6ILM38=;
        b=LqcUUVO239BVJVAW0bOG4zKOZm1c7NSqXwMwVPFRh3XBMy5c2UycPZjhLM1+XadDkb
         GZMl2uabawRFU1yCcxfhhV6FczyEZriwgHY8YsUXl0vK0LKAqTJZkm36/iAgQDNNn182
         C1uX4ZDfDpPcz5IdtCJEs/55YDfUNQjGabouHoE/Ppdb+LSRu2PIlLc51SjcTMU9E1lH
         97exDEUfzkuU5BOdFmaOdRUP97bBOcVkp7PKX/f619G9trLgstZoR0p2vs0GZG4m039A
         CEzdVeBzvoSLrMxLDpnJf2O8OpTS6rJXEkwbGLlwoi8sv4EHL7oUB1d7PrD5zFwgW0wR
         iLeQ==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=obfDzy4b;
       spf=pass (google.com: domain of tvaneerd@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=tvaneerd@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE 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=W9IpodNHbriCrU8OC+PMken8v41p9RKtR2I3O6ILM38=;
        b=oMrnyIPBjowMuJIdzQuzfWnUElkmK15JREzG2bpY1R8AaGOh2Aet3jgd69fl3aLoQ9
         dyZ24YEhB5ZRiiUHt0qPMAH10G1ImPCPTM0TujscKGaCapWcWrc8Cjldy7RgtrfCwmY6
         ax7dcf01MHwMeFLtbVWQrf5z2LfEMqENttuuZ/6J5Z1HDvPtMO0fqkYIBy635yJemtle
         vZaTygmBnHMAvoACiRtzOZK5vK9QclXUK/Ar2zqDlhEUHMRJfQ1bgA7r7T0RpZgzX1TL
         tBdMnUd2xEss4zbOi8HywM9oVXEMYPitScHWMTGXdvKEuJdVKu3mC+GlJPnMqpYoZJqx
         NtKQ==
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=W9IpodNHbriCrU8OC+PMken8v41p9RKtR2I3O6ILM38=;
        b=kjz6SbIKOUSrzVOxtBod80JlGRa22I2nTMOxW16R6mR1hRhw6kwYu2ZMYBYAveoG9k
         UDjbeyil5/ye7JKEh5cl6DthHSX3pZ1+vGtTZ5iGYIWgbj5zwwIABxEMz4eEvtajZ6rG
         V6Ss9Z0xsc09u7M3d9jSEhip1nlA0fqsfRJJZqMuLuV4K/9vAadnNxUP6NSKET/DJlCO
         MwZN81lGcxU4EA2tb+CL04bSdWbibiCRnlGq1U2LzDnueIy0wTmmSDehq9FnKoVT408u
         Dp/SiGByJ3WL06e4F3Fw3tAw/ZQ18GYuyS5SXXBXGXLLqvIH1QWB0dFqEKIhOpMwvaVN
         2UMg==
X-Gm-Message-State: AOUpUlGzv4FvFPGniJxsk7zcIKwHaM5e3Gxa2ymwKtbh+XWRuGMccWE7
	X/JWjXR32vNBG1LNOFjUmGnUpA==
X-Google-Smtp-Source: AAOMgpcwems6NYVmpOX5h2hzfNMcqM4HYLnHeAY75F5R+iKdm02Y4AiMcjHxm5f14jwxBS45Nw4lOA==
X-Received: by 2002:aca:a17:: with SMTP id 23-v6mr9816964oik.80.1532358120936;
        Mon, 23 Jul 2018 08:02:00 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:aca:c0d4:: with SMTP id q203-v6ls3124306oif.14.gmail; Mon,
 23 Jul 2018 08:02:00 -0700 (PDT)
X-Received: by 2002:aca:b702:: with SMTP id h2-v6mr8599365oif.66.1532358120021;
        Mon, 23 Jul 2018 08:02:00 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1532358119; cv=none;
        d=google.com; s=arc-20160816;
        b=sxYdOrPwO2KE3nT9Yz/vsIRZ2JSJrP9Oef4PgUmz2Rub7z6A5PNmzsrJAHazHFkrsL
         DVBtMhSZTaK9Gci3aKl2rTye/+Sld+eXdaG3DsL6pPKw3Wu8TtHG9qDYr2BVHSprz/Vc
         3+1BILeWYdaSHBkrwsXxzfW13bjaCja1AywmuMp8XDUgwofCUMZU1fkSeGHIWkri5QDX
         iHY78tLy0D7rR9JncduDGYt77SNB/JgQdh1uChpdpXo3pgLTzLRj7cyBUbEW25InxNx5
         +flpQ/fpm1jW7VqoYTkCfmuVmKnUa77SRXEg4SS+u150BYkousuRmiZ6CfFi3FVVHXD6
         IgkA==
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=nXl47JAYBo0nsN6fvePyGi7sOlV4LgkoME0cifVFgJ4=;
        b=H0Xf4GpP1KhsNSh+OBPAxu3QIjfh3GBf9fNkfetB4zxzyo8kXxn8YqnxXDReeuEgiV
         04ByXsooEHtL0oBWLfP3N3dXro7W3EA7+9UzVKUjbL1MM5xAtWIvNVa634JKEdATnqcM
         c35on79Y4W7oLZfOVHT/z+zI5i+8DzRFt5OhtmDkq11mreE6nLBDmD0p7YVpkN0lQrup
         2SLN0PRbrFgas/7olWs9R+AAfvuxZRYDQwM6+QNkzsR0HM6LgbMut8856x0WqaftFl8c
         JWyqvd6EOkAO0Odz5+V1vf0/wz1mKn+C9yrsXwY8K34OBHHMtHyeJb9MK5LRxDNPVGwy
         jqyw==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=obfDzy4b;
       spf=pass (google.com: domain of tvaneerd@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=tvaneerd@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id x12-v6sor4770516oie.29.2018.07.23.08.01.59
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Mon, 23 Jul 2018 08:01:59 -0700 (PDT)
Received-SPF: pass (google.com: domain of tvaneerd@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 2002:aca:af15:: with SMTP id y21-v6mr9414047oie.324.1532358118535;
 Mon, 23 Jul 2018 08:01:58 -0700 (PDT)
Original-Received: by 2002:a9d:ea6:0:0:0:0:0 with HTTP; Mon, 23 Jul 2018 08:01:58 -0700 (PDT)
In-Reply-To: <CALvx3hZWBkQB0SGDqaD5iY_-kez7ibnj6wj3jT=btXtUoUr=zg@mail.gmail.com>
X-Original-Sender: tvaneerd@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=obfDzy4b;       spf=pass
 (google.com: domain of tvaneerd@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=tvaneerd@gmail.com;       dmarc=pass (p=NONE
 sp=QUARANTINE 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-Spam-Checked-In-Group: 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:39304
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/39304>

--00000000000052f7820571abed0b
Content-Type: text/plain; charset="UTF-8"

On Mon, Jul 23, 2018 at 10:54 AM, Richard Hodges <hodges.r@gmail.com> wrote:

>
>
> On Mon, 23 Jul 2018 at 16:16, Tony V E <tvaneerd@gmail.com> wrote:
>
>> I've wanted type-erased iterators a few times, on various projects,
>> various companies.
>>
>> Currently we deal with 3D points a lot.  Often in vectors.  Sometimes in
>> other containers.  Sometimes the 3D point is just part of a bigger struct.
>> So we get a vector of FooBars and each FooBar has a 3D point (or 2
>> different 3D points, like 'source' and 'dest' and we need to pick which we
>> are processing.)
>>
>> For many algorithms we use, the cost of "get next point" is small
>> compared to other processing. And the amount of code in the algorithm is
>> high for a template.
>>
>> So I see lots of code that copies tens of thousands of points from one
>> container into another, so that it is in the right format, ie so that it
>> can pass in a vector<Point3D>.
>> We might also transform each point tmp = f(*it) before processing it.
>> That could also be in the iterator.
>>
>
> This is beginning to make sense.
>
> Now giving it more thought, I see problems.
>
> A map's value_type is a key/value pair but a vector or set's value_type is
> a value.
>
> Conceptually we could argue that all containers have a key and a value:
>
> vector<V> : key = std::size_t, value = V
> map<K, V> : key = K, value = V
> set<V> : key = V, value = V
>
> Then we could distinguish between polymorphic key iteration and
> polymorphic value iteration.
>
> This might argue for
>
> std::polymorphic_forward_sequence_key_view<K>,
> std::polymorphic_forward_sequence_value_view<V> and
> std::polymorphic_forward_sequence_key_value_view<K, V>
>
> ...etc for all classes of iterator category.
>
> It's starting to look like a lot of work.
>


std::poly_sequence<T>.  If you want key, make T = key; if you want value,
make T = value; if you want key+value, make T = std::pair<key,value>.
From the point of view of the algorithm that will _use_ the iterator, it
only needs one type - whatever T it needs to process.

Put the magic of converting from map to poly_sequence<mapped_type> inside
the iterator.




>
>>
>> On Mon, Jul 23, 2018 at 5:14 AM, Richard Hodges <hodges.r@gmail.com>
>> wrote:
>>
>>>
>>>
>>> On Mon, 23 Jul 2018 at 09:01, Thomas Russell <thomas.russell97@gmail.com>
>>> wrote:
>>>
>>>> The motivation is similar to having any standard type-erased facility;
>>>> it gives a concrete interface that accepts an arbitrary set of classes that
>>>> conform to the required concepts.
>>>>
>>>> The closest existing parallel in the standard library is
>>>> `std::function`, modelling the Callable concept.
>>>>
>>>> Having such a facility as a vocabulary type provides various benefits
>>>> over function templates accepting Callables:
>>>> - Reduced generated code-size (this can even go some way towards
>>>> reducing the performance penalty).
>>>> - Works with the OOP paradigm (virtual functions cannot be function
>>>> templates)
>>>> - Reduced compile-time
>>>> - Can work across dynamically-linked library boundaries, providing the
>>>> correctly corresponding build parameters are met.
>>>>
>>>> I think these are good motivations, but am interested to hear opposing
>>>> opinions.
>>>>
>>>
>>> I think it would be fair to say that they are theoretical or
>>> hypothesised motivations, not actual concrete use cases where there is a
>>> demonstrable benefit in providing a standardised type-erased iterator suite.
>>>
>>> I'm thinking in terms of "here's some current software that sucks
>>> because we don't have type-erased iterators, and presented here is a better
>>> version using my implementation of such iterators".
>>>
>>> I say this not to be argumentative.
>>>
>>> I say it because like you and many others, I have played with similar
>>> ideas because they were fun or interesting ideas. Including for example a
>>> type-erased iterator for iterating across a tuple (operator* returns a
>>> boost::variant of references).
>>>
>>> However, in 30 years on and off writing commercial software, I have
>>> never encountered an actual use case while using c++.
>>>
>>> This is probably because I reach for c++ when seeking concrete
>>> guarantees on type safety, and python, perl or javascript when I'm seeking
>>> type flexibility and expressiveness.
>>>
>>> But it could be that I am thinking myopically. I have experimented in
>>> the past with providing more "script-like" library objects to the odd
>>> project. Again, out of curiosity more than need.
>>>
>>> You see what I'm saying? Is this in reality a fun personal project, or
>>> is there a tangible benefit to me if I find this in the std toolbox?
>>>
>>>
>>>>
>>>> --
>>>> 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.
>>>> To view this discussion on the web visit https://groups.google.com/a/
>>>> isocpp.org/d/msgid/std-proposals/c9664ef6-f769-4942-
>>>> 8e44-56761d091efc%40isocpp.org.
>>>>
>>> --
>>> 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.
>>> To view this discussion on the web visit https://groups.google.com/a/
>>> isocpp.org/d/msgid/std-proposals/CALvx3haDm01D7jCvJJA3JJycraXVZ
>>> _WHz9A4md5h1WXhCR29cg%40mail.gmail.com
>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3haDm01D7jCvJJA3JJycraXVZ_WHz9A4md5h1WXhCR29cg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>>
>>
>> --
>> Be seeing you,
>> Tony
>>
>> --
>> 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.
>> To view this discussion on the web visit https://groups.google.com/a/
>> isocpp.org/d/msgid/std-proposals/CAOHCbivaZbbS-
>> zsx4nSzs3uggAxvWSze0zgVnrGm5dAfy%3D%2BHnw%40mail.gmail.com
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbivaZbbS-zsx4nSzs3uggAxvWSze0zgVnrGm5dAfy%3D%2BHnw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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.
> To view this discussion on the web visit https://groups.google.com/a/
> isocpp.org/d/msgid/std-proposals/CALvx3hZWBkQB0SGDqaD5iY_-
> kez7ibnj6wj3jT%3DbtXtUoUr%3Dzg%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hZWBkQB0SGDqaD5iY_-kez7ibnj6wj3jT%3DbtXtUoUr%3Dzg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>



-- 
Be seeing you,
Tony

-- 
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbisY24xBK9zEYvpaS9SLFhWwfzxLo%3DPsuFd9AncLW1VQew%40mail.gmail.com.

--00000000000052f7820571abed0b
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 23, 2018 at 10:54 AM, Richard Hodges <span dir=3D"ltr">&lt;=
<a href=3D"mailto:hodges.r@gmail.com" target=3D"_blank">hodges.r@gmail.com<=
/a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:=
0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><b=
r><br><div class=3D"gmail_quote"><span class=3D""><div dir=3D"ltr">On Mon, =
23 Jul 2018 at 16:16, Tony V E &lt;<a href=3D"mailto:tvaneerd@gmail.com" ta=
rget=3D"_blank">tvaneerd@gmail.com</a>&gt; wrote:<br></div><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pad=
ding-left:1ex"><div dir=3D"ltr"><div>I&#39;ve wanted type-erased iterators =
a few times, on various projects, various companies.</div><div><br></div><d=
iv>Currently we deal with 3D points a lot.=C2=A0 Often in vectors.=C2=A0 So=
metimes in other containers.=C2=A0 Sometimes the 3D point is just part of a=
 bigger struct.=C2=A0 So we get a vector of FooBars and each FooBar has a 3=
D point (or 2 different 3D points, like &#39;source&#39; and &#39;dest&#39;=
 and we need to pick which we are processing.)<br></div><div><br></div><div=
>For many algorithms we use, the cost of &quot;get next point&quot; is smal=
l compared to other processing. And the amount of code in the algorithm is =
high for a template.<br></div><div><br></div><div>So I see lots of code tha=
t copies tens of thousands of points from one container into another, so th=
at it is in the right format, ie so that it can pass in a vector&lt;Point3D=
&gt;.</div><div>We might also transform each point tmp =3D f(*it) before pr=
ocessing it.=C2=A0 That could also be in the iterator.<br></div></div></blo=
ckquote><div><br></div></span><div>This is beginning to make sense.=C2=A0</=
div><div><br></div><div>Now giving it more thought, I see problems.</div><d=
iv><br></div><div>A map&#39;s value_type is a key/value pair but a vector o=
r set&#39;s value_type is a value.</div><div><br></div><div>Conceptually we=
 could argue that all containers have a key and a value:</div><div><br></di=
v><div><div style=3D"font-size:small;background-color:rgb(255,255,255);text=
-decoration-style:initial;text-decoration-color:initial">vector&lt;V&gt; : =
key =3D std::size_t, value =3D V</div><div style=3D"font-size:small;backgro=
und-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-co=
lor:initial">map&lt;K, V&gt; : key =3D K, value =3D V</div><div style=3D"fo=
nt-size:small;background-color:rgb(255,255,255);text-decoration-style:initi=
al;text-decoration-color:initial">set&lt;V&gt; : key =3D V, value =3D V</di=
v><div><br></div>Then we could distinguish between polymorphic key iteratio=
n and polymorphic value iteration.</div><div><br></div><div>This might argu=
e for=C2=A0</div><div><font face=3D"monospace, monospace"><br></font></div>=
<div><font face=3D"monospace, monospace">std::polymorphic_forward_<wbr>sequ=
ence_key_view&lt;K&gt;</font>,=C2=A0</div><div><span style=3D"font-size:sma=
ll;background-color:rgb(255,255,255);text-decoration-style:initial;text-dec=
oration-color:initial;float:none;display:inline"><font face=3D"monospace, m=
onospace">std::polymorphic_forward_<wbr>sequence_value_view&lt;V&gt;</font>=
 and=C2=A0</span>=C2=A0</div><div><font face=3D"monospace, monospace">std::=
polymorphic_forward_<wbr>sequence_key_value_view&lt;K, V&gt;</font></div><d=
iv><br class=3D"m_-2938253410442622621gmail-Apple-interchange-newline">...e=
tc for all classes of iterator category.</div><div>=C2=A0=C2=A0<br></div><d=
iv>It&#39;s starting to look like a lot of work.</div></div></div></blockqu=
ote><div><br></div><div><br></div><div>std::poly_sequence&lt;T&gt;.=C2=A0 I=
f you want key, make T =3D key; if you want value, make T =3D value; if you=
 want key+value, make T =3D std::pair&lt;key,value&gt;.</div><div>
<div>From the point of view of the algorithm that will _use_ the iterator, =
it only needs one type - whatever T it needs to process.<br></div><div><br>=
 </div>

</div><div>Put the magic of converting from map to poly_sequence&lt;mapped_=
type&gt; inside the iterator.</div><div><br></div><br><div><br></div><block=
quote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc=
 solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_quote"><div><=
br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;borde=
r-left:1px #ccc solid;padding-left:1ex"><div><div class=3D"h5"><div dir=3D"=
ltr"><div><br></div><div><div class=3D"gmail_extra"><br><div class=3D"gmail=
_quote">On Mon, Jul 23, 2018 at 5:14 AM, Richard Hodges <span dir=3D"ltr">&=
lt;<a href=3D"mailto:hodges.r@gmail.com" target=3D"_blank">hodges.r@gmail.c=
om</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"marg=
in:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"=
><br><br><div class=3D"gmail_quote"><span><div dir=3D"ltr">On Mon, 23 Jul 2=
018 at 09:01, Thomas Russell &lt;<a href=3D"mailto:thomas.russell97@gmail.c=
om" target=3D"_blank">thomas.russell97@gmail.com</a>&gt; wrote:<br></div><b=
lockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px =
#ccc solid;padding-left:1ex">The motivation is similar to having any standa=
rd type-erased facility; it gives a concrete interface that accepts an arbi=
trary set of classes that conform to the required concepts.<br>
<br>
The closest existing parallel in the standard library is `std::function`, m=
odelling the Callable concept.<br>
<br>
Having such a facility as a vocabulary type provides various benefits over =
function templates accepting Callables:<br>
- Reduced generated code-size (this can even go some way towards reducing t=
he performance penalty).<br>
- Works with the OOP paradigm (virtual functions cannot be function templat=
es) <br>
- Reduced compile-time<br>
- Can work across dynamically-linked library boundaries, providing the corr=
ectly corresponding build parameters are met. <br>
<br>
I think these are good motivations, but am interested to hear opposing opin=
ions. <br></blockquote><div><br></div></span><div>I think it would be fair =
to say that they are theoretical or hypothesised motivations, not actual co=
ncrete use cases where there is a demonstrable benefit in providing a stand=
ardised type-erased iterator suite.</div><div><br></div><div>I&#39;m thinki=
ng in terms of &quot;here&#39;s some current software that sucks because we=
 don&#39;t have type-erased iterators, and presented here is a better versi=
on using my implementation of such iterators&quot;.</div><div><br></div><di=
v>I say this not to be argumentative.</div><div><br></div><div>I say it bec=
ause like you and many others, I have played with similar ideas because the=
y were fun or interesting ideas. Including for example a type-erased iterat=
or for iterating across a tuple (operator* returns a boost::variant of refe=
rences).</div><div><br></div><div>However, in 30 years on and off writing c=
ommercial software, I have never encountered an actual use case while using=
 c++.</div><div><br></div><div>This is probably because I reach for c++ whe=
n seeking concrete guarantees on type safety, and python, perl or javascrip=
t when I&#39;m seeking type flexibility and expressiveness.</div><div><br><=
/div><div>But it could be that I am thinking myopically. I have experimente=
d in the past with providing more &quot;script-like&quot; library objects t=
o the odd project. Again, out of curiosity more than need.=C2=A0</div><div>=
<br></div><div>You see what I&#39;m saying? Is this in reality a fun person=
al project, or is there a tangible benefit to me if I find this in the std =
toolbox?<br>=C2=A0<br></div><span><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<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" target=3D=
"_blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">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/c9664ef6-f769-4942-8e44-56761d091efc%=
40isocpp.org" rel=3D"noreferrer" target=3D"_blank">https://groups.google.co=
m/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/c9664ef6-f769-4942-<wbr>8e44=
-56761d091efc%40isocpp.org</a><wbr>.<br>
</blockquote></span></div></div><span>

<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" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CALvx3haDm01D7jCvJJA3JJycraXVZ_WHz9A4=
md5h1WXhCR29cg%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfooter"=
 target=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-=
<wbr>proposals/<wbr>CALvx3haDm01D7jCvJJA3JJycraXVZ<wbr>_WHz9A4md5h1WXhCR29c=
g%40mail.<wbr>gmail.com</a>.<br>
</blockquote></div><br><br clear=3D"all"><br>-- <br><div class=3D"m_-293825=
3410442622621m_-5021038089919027371gmail_signature" data-smartmail=3D"gmail=
_signature"><div dir=3D"ltr"><div>Be seeing you,<br></div>Tony<br></div></d=
iv>
</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" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></div></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAOHCbivaZbbS-zsx4nSzs3uggAxvWSze0zgV=
nrGm5dAfy%3D%2BHnw%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoo=
ter" target=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msgid/=
std-<wbr>proposals/CAOHCbivaZbbS-<wbr>zsx4nSzs3uggAxvWSze0zgVnrGm5dA<wbr>fy=
%3D%2BHnw%40mail.gmail.com</a>.<br>
</blockquote></div></div><span class=3D"">

<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" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CALvx3hZWBkQB0SGDqaD5iY_-kez7ibnj6wj3=
jT%3DbtXtUoUr%3Dzg%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoo=
ter" target=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msgid/=
std-<wbr>proposals/<wbr>CALvx3hZWBkQB0SGDqaD5iY_-<wbr>kez7ibnj6wj3jT%3DbtXt=
UoUr%<wbr>3Dzg%40mail.gmail.com</a>.<br>
</blockquote></div><br><br clear=3D"all"><br>-- <br><div class=3D"gmail_sig=
nature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr"><div>Be seeing =
you,<br></div>Tony<br></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/CAOHCbisY24xBK9zEYvpaS9SLFhWwfzxLo%3D=
PsuFd9AncLW1VQew%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbisY24xBK9=
zEYvpaS9SLFhWwfzxLo%3DPsuFd9AncLW1VQew%40mail.gmail.com</a>.<br />

--00000000000052f7820571abed0b--

.
