220 31768 <0d3f5162-b2f9-4389-a0ec-4e3928492fa3@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Complexities caused by using unique_ptr and
 move semantics
Date: Sun, 26 Mar 2017 18:12:05 -0700 (PDT)
Lines: 103
Approved: news@gmane.org
Message-ID: <0d3f5162-b2f9-4389-a0ec-4e3928492fa3@isocpp.org>
References: <46a85060-631b-49e5-94f3-ab07429d8085@isocpp.org>
 <86aeb556-e0d7-4d68-b553-1b4163461473@isocpp.org> <136fc743-bc63-48c8-b1d5-dc4084dd13cf@isocpp.org>
 <CALQmNFgAe4B2tiqjA7Mq1TWXWdt-OMAUD41AKzuxh_6_X=uRcQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2792_1819910155.1490577125313"
X-Trace: blaine.gmane.org 1490577129 25820 195.159.176.226 (27 Mar 2017 01:12:09 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 27 Mar 2017 01:12:09 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBZON4HDAKGQEOQP2DWY@isocpp.org Mon Mar 27 03:12:04 2017
Return-path: <std-proposals+bncBCEKFTV6ZUMBBZON4HDAKGQEOQP2DWY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vk0-f70.google.com ([209.85.213.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBZON4HDAKGQEOQP2DWY@isocpp.org>)
	id 1csJCT-0005qG-6O
	for gclcip-std-proposals@m.gmane.org; Mon, 27 Mar 2017 03:12:01 +0200
Original-Received: by mail-vk0-f70.google.com with SMTP id x65sf33930922vkx.0
        for <gclcip-std-proposals@m.gmane.org>; Sun, 26 Mar 2017 18:12:07 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :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=xYDC11HxYvzpqJz2j5FV6K/F/U6HmOH1Eve/uu6ZsTg=;
        b=sCEw2TFSwsXzHZc1rZijdW+eGKfPL1q26s+27vjSKRUh1YXTVlJVIP3QHnLY4ocfq4
         QQ4zas+ZB7Ebedt9zVu5w+xKBZCq0S7H698rV92L0PMy7fTUBNcI6C1sufVTiR+AMogM
         8lMDwXGm9f7s1TbTyP5aEJc0CINlAP4khEw5xiBdLkxGqHZYUOJRR2OnLW6f9ZGl76GY
         pbUGCFLrGyjGueZt43YyPMd2n2HEjbN90cziAOBbvWQW10hfRBLzfwy6s+YJpVzFnODj
         BARMUnUnXxtW59oiKktNhw/v90yIvPHwx+yb/P7RsQsbyYDFRP8UWbd9v5pFgsDKq+dK
         GLkQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :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=xYDC11HxYvzpqJz2j5FV6K/F/U6HmOH1Eve/uu6ZsTg=;
        b=PBTuSCR5u1QRC+SZpl9NGdDx5Xo+rA97artJqEnkz4Slm3MRu57JqoBD++2rBqP0B/
         3iDcwyCYnWevEexBqX+DZWzG2Gtk6Z43U+Zepvg0EOi6T4GFk0HJ5Ybm8sQOU54xXNRA
         nbJkFXwK8gxlf4BQrputeJh1qpMnx5kY8IKsJ4EBqISA82Mrd0oXPxbUYTI0OQ7L2seB
         RakpQd3wjOf4n6Rn7/JSMd6TvPRqX4Nwdp0g3f3N1FhZmuTTeMie1B3m6Gp+LqK0JAgb
         53c4IhhzISK8brvMQwdpBVRum3778cGlCdJiF3Hr/B7xdbXCHAdayVeM56reCUe/hCYW
         t5IQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version: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=xYDC11HxYvzpqJz2j5FV6K/F/U6HmOH1Eve/uu6ZsTg=;
        b=K77Q5f3xKJXdrTRaxf7gp+nvtEodgvHVuDJ5BljijWELtzn46j2K1iW7DfYu4D7Tp6
         1kfq6To/cfiaMuHgmc3cTHA6E/CWwgmdu+FXF4SZ70uHs7oNwVrLufkMMuDNcrMT+cfX
         N/U93sE7eZsZX9BpA1yo0Dx4tBbHvHZPoOb/kXpUnPIvphQ3d03E0pOQSbcD3/FYRplv
         fwpIukTaJVS4UklQGtdhOLIRJiocZsCK9tn3PsOugU4W5tIrx/bidjYXi9GkU3FUw83N
         I51JRc9PdTv1JvVMRER80cXBgrT+04T2ZWeYgNnSQzZEf4FYjbF+ydlC3/tiKm5wYsv+
         VZ6Q==
X-Gm-Message-State: AFeK/H2L4N3pUyHOU3+ZzEAI8sGV3QZ7Y9TzhPinM7NvqVgbuF3rzgF7zSCBXZFP0yCSYQ==
X-Received: by 10.31.134.1 with SMTP id i1mr4974174vkd.35.1490577126596;
        Sun, 26 Mar 2017 18:12:06 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.30.168 with SMTP id n37ls11994478otn.25.gmail; Sun, 26 Mar
 2017 18:12:05 -0700 (PDT)
X-Received: by 10.157.82.72 with SMTP id q8mr1544524otg.4.1490577125812;
        Sun, 26 Mar 2017 18:12:05 -0700 (PDT)
In-Reply-To: <CALQmNFgAe4B2tiqjA7Mq1TWXWdt-OMAUD41AKzuxh_6_X=uRcQ@mail.gmail.com>
X-Original-Sender: jmckesson@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:31768
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/31768>

------=_Part_2792_1819910155.1490577125313
Content-Type: multipart/alternative; 
	boundary="----=_Part_2793_825116473.1490577125313"

------=_Part_2793_825116473.1490577125313
Content-Type: text/plain; charset=UTF-8



On Sunday, March 26, 2017 at 6:11:08 PM UTC-4, Sean Middleditch wrote:
>
> On Fri, Mar 24, 2017 at 3:25 PM, Nicol Bolas <jmck...@gmail.com 
> <javascript:>> wrote:
>
>>
>>> Basically, you want to write something like:
>>>
>>>   iterable<T&> foo::get_things() { return make_iterable(_things, 
>>> [](auto& p){ return *p; }); }
>>>
>>>
>> That's a really bad tradeoff: type-erasing performance plus the cost of 
>> filtering, all just to gain some increased genericity. 
>>
>
> Not at all, because that'd be a template that gets fully inlined and 
> result in identical machine code (assuming a suitably capable optimizer).
>

How? `iterable` doesn't specify the type of iterator used to iterate over 
`_things`, nor does it specify the type of range that `_things` is. But it 
still has to store either the range or an iterator pair over that range. 
Therefore, the storage for those things must be type-erased in some 
fashion. And that requires some form of indirect call to move to the next 
item in the iterator, as well as to call the functor. Not to mention having 
to type-erase the functor itself.

And type-erasure is the enemy of inlining.

If that were an `iterable<span<T>, function_type>`, then I could buy the 
inlining. But not so long as type erasure has to be used.

-- 
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/0d3f5162-b2f9-4389-a0ec-4e3928492fa3%40isocpp.org.

------=_Part_2793_825116473.1490577125313
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Sunday, March 26, 2017 at 6:11:08 PM UTC-4, Sea=
n Middleditch wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr"><div><div class=3D"gmail_quote">On Fri, Mar 24, 2017 at 3:25 PM, N=
icol Bolas <span dir=3D"ltr">&lt;<a href=3D"javascript:" target=3D"_blank" =
gdf-obfuscated-mailto=3D"4ZU9vxs4BwAJ" rel=3D"nofollow" onmousedown=3D"this=
..href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39;jav=
ascript:&#39;;return true;">jmck...@gmail.com</a>&gt;</span> wrote:<br><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #c=
cc solid;padding-left:1ex"><div dir=3D"ltr"><span><blockquote class=3D"gmai=
l_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;pad=
ding-left:1ex"><div dir=3D"ltr"><div><br></div><div>Basically, you want to =
write something like:</div><div><br></div><div>=C2=A0 iterable&lt;T&amp;&gt=
; foo::get_things() { return make_iterable(_things, [](auto&amp; p){ return=
 *p; }); }<br></div><div><br></div><div></div></div></blockquote></span><di=
v><br>That&#39;s a really bad tradeoff: type-erasing performance plus the c=
ost of filtering, all just to gain some increased genericity. <br></div></d=
iv></blockquote><div><br></div><div>Not at all, because that&#39;d be a tem=
plate that gets fully inlined and result in identical machine code (assumin=
g a suitably capable optimizer).</div></div></div></div></blockquote><div><=
br>How? `iterable` doesn&#39;t specify the type of iterator used to iterate=
 over `_things`, nor does it specify the type of range that `_things` is. B=
ut it still has to store either the range or an iterator pair over that ran=
ge. Therefore, the storage for those things must be type-erased in some fas=
hion. And that requires some form of indirect call to move to the next item=
 in the iterator, as well as to call the functor. Not to mention having to =
type-erase the functor itself.<br><br>And type-erasure is the enemy of inli=
ning.<br><br>If that were an `iterable&lt;span&lt;T&gt;, function_type&gt;`=
, then I could buy the inlining. But not so long as type erasure has to be =
used.</div><br></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/0d3f5162-b2f9-4389-a0ec-4e3928492fa3%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0d3f5162-b2f9-4389-a0ec-4e3928492fa3=
%40isocpp.org</a>.<br />

------=_Part_2793_825116473.1490577125313--

------=_Part_2792_1819910155.1490577125313--

.
