220 27040 <cd6e299d-7cec-4d8e-8a55-f25fd88d1b91@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Carl Cook <carl.cook@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Proposal - non allocating std::function
Date: Fri, 15 Jul 2016 02:12:58 -0700 (PDT)
Lines: 79
Approved: news@gmane.org
Message-ID: <cd6e299d-7cec-4d8e-8a55-f25fd88d1b91@isocpp.org>
References: <e00db911-40f5-4c11-a4b8-32bba77aa0a5@isocpp.org>
 <CANh-dXnpUNf2O5NTj213K1Jfmhge1=eit6+SistzYWZj+5CkNg@mail.gmail.com> <ff1087cf-5777-47e9-8caa-d28136aae130@isocpp.org>
 <CAOfiQqn31H_Mfkxx3yty1=wqu50JnpcSv25uLP3DNDTb5E8WYQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_190_1624127528.1468573978381"
X-Trace: ger.gmane.org 1468573985 13912 80.91.229.3 (15 Jul 2016 09:13:05 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 15 Jul 2016 09:13:05 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBD27VEPGSEGBBG6SUK6AKGQEZYBPVIA@isocpp.org Fri Jul 15 11:13:04 2016
Return-path: <std-proposals+bncBD27VEPGSEGBBG6SUK6AKGQEZYBPVIA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pf0-f199.google.com ([209.85.192.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBD27VEPGSEGBBG6SUK6AKGQEZYBPVIA@isocpp.org>)
	id 1bNzB7-0007mG-SH
	for gclcip-std-proposals@m.gmane.org; Fri, 15 Jul 2016 11:13:03 +0200
Original-Received: by mail-pf0-f199.google.com with SMTP id p64sf205166937pfb.0
        for <gclcip-std-proposals@m.gmane.org>; Fri, 15 Jul 2016 02:13:01 -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=XMXJJy4zejOB7rln4zLPsmjb2+iza9xpScFik7VWzQ0=;
        b=VxN2tQm1a8hXULSkVeNnzkUjYDITDAnM9q9Dq/rO1CTLJapoqlJ+mzUoWCO+mGmxzx
         bp3XqzShsdTxfGvk+7OTpReON0pedw92182Yvm/DY0W5hQqhFT+B0jxUPbtR+qQB+5Yq
         XYkvI3R/F/dwEE7Ji1743PqD5j1WBHpX594qEtVaq1kK2vpm/WqSdGUpWc5cOxq4m/sU
         EkzB8zBjC8NR5Vhm4WlsB9xpFLVZZtRd6FaAlIoorP6ouogLBlyWz7u9hXj4367PedYw
         TGFn+vkB9yyq3vGzdd+k9XWymkk6w43oyRe3+zht3bBIWgT+85Ld/Jy2Zujy6FtlGYex
         J3EQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        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=XMXJJy4zejOB7rln4zLPsmjb2+iza9xpScFik7VWzQ0=;
        b=mZhMeddhfsqBR1tjwoPhRjkqffcU+nOtItXOWvSUMr0wv4YpuvyEeaQz95Hq3XwhHA
         SBH2uqzS3HlBi5tU02Pxc+GH3CJBqMyo+/uFA0aSbSNkGFw/S1ftcoMWq1CESiWFBDNt
         YOjL6oYlJLP230VMleh6ndaAaBgKSVtq71mC6rPW7ByppZBDXY1SFvetuPB6cIoeAPcS
         IH//hGrMxMvEbzfRxTxinafVQmcu+LHzvBsYzfXnx2VeHYb7SfhLPAcFki+VLdJOxqKE
         n0N7FRhgMS4zsKjp6N42cvRpz2YwRGMYBrywUTeXlbYZWm4VRxNqCC91eGDww5l3sQXS
         DhTw==
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: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=XMXJJy4zejOB7rln4zLPsmjb2+iza9xpScFik7VWzQ0=;
        b=SXwd49reHk7DbBgZNuHn6/sgycMjzzDMQ1rMWOmNJDsDuoXSoB9JbsrdmNFalSeDZY
         H9014JtpfgZkQ1PYjbSEAS7nB5dZB58iTLjz6JzZB4VvuCiRbQP4KHORLWCAEAJ8elq6
         drIrbivDEgU9iSQ5wtAiiyBlxSsEM0K3KB+4HSQk3mj5UYK4osiLaB2+KbpNHPoqbZM6
         8DPqhDOsyD5d4k0FKMl2PG8AyU36q7VzUzH7592B7IWHK0w7vlvZ1qdmAdw3NYSq4oZ2
         1QM1fX/A5Rv1wfDklonvqORMPyoPaWlOMbsuq3VIZREZqwhM5YKQZaxC++9b1L0Vc2II
         4+gg==
X-Gm-Message-State: ALyK8tKCZD9c4Da+iXw45zWP6fsIg/QixeTxlVwLRiu9HlJ6IJfWLf1ziah03FJk9g0HCg==
X-Received: by 10.67.24.33 with SMTP id if1mr7937406pad.29.1468573980775;
        Fri, 15 Jul 2016 02:13:00 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.15.25 with SMTP id x25ls1297494ioi.5.gmail; Fri, 15 Jul
 2016 02:12:59 -0700 (PDT)
X-Received: by 10.36.210.213 with SMTP id z204mr1207109itf.0.1468573979461;
        Fri, 15 Jul 2016 02:12:59 -0700 (PDT)
In-Reply-To: <CAOfiQqn31H_Mfkxx3yty1=wqu50JnpcSv25uLP3DNDTb5E8WYQ@mail.gmail.com>
X-Original-Sender: carl.cook@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:27040
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/27040>

------=_Part_190_1624127528.1468573978381
Content-Type: multipart/alternative; 
	boundary="----=_Part_191_69710619.1468573978382"

------=_Part_191_69710619.1468573978382
Content-Type: text/plain; charset=UTF-8

On Friday, 15 July 2016 02:35:42 UTC+2, Richard Smith wrote:
>
> llvm::function_ref doesn't capture anything, and is not supposed to -- 
> it's a *non-owning* handle to a callable that outlives the handle. 
> (llvm::function_ref is to std::function as std::string_view is to 
> std::string.) This is a feature and a design goal of llvm::function_ref, 
> but I think it means it's addressing a fundamentally different problem than 
> the one you're tackling here (which seems to be essentially, "let me 
> control the size and alignment in std::function's small function 
> optimization"
>

Understood. What caught me out is that compilers can aggressively limit the 
scope of lambdas. Hence I believe the following is not legal usage:

int non_const_var = 0xf;
function_ref<int()> f_ref = [&]() { return non_const_var;};
return f_ref();



-- 
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/cd6e299d-7cec-4d8e-8a55-f25fd88d1b91%40isocpp.org.

------=_Part_191_69710619.1468573978382
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Friday, 15 July 2016 02:35:42 UTC+2, Richard Smith  wro=
te:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;=
border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div class=
=3D"gmail_quote"><div>llvm::function_ref doesn&#39;t capture anything, and =
is not supposed to -- it&#39;s a *non-owning* handle to a callable that out=
lives the handle. (llvm::function_ref is to std::function as std::string_vi=
ew is to std::string.) This is a feature and a design goal of llvm::functio=
n_ref, but I think it means it&#39;s addressing a fundamentally different p=
roblem than the one you&#39;re tackling here (which seems to be essentially=
, &quot;let me control the size and alignment in std::function&#39;s small =
function optimization&quot;</div></div></div></blockquote><div><br></div><d=
iv>Understood. What caught me out is that compilers can aggressively limit =
the scope of lambdas. Hence I believe the following is not legal usage:</di=
v><div><br></div><div><div class=3D"prettyprint" style=3D"border: 1px solid=
 rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250,=
 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><div clas=
s=3D"subprettyprint">int non_const_var =3D 0xf;</div><div class=3D"subprett=
yprint">function_ref&lt;int()&gt; f_ref =3D [&amp;]() { return non_const_va=
r;};</div><div class=3D"subprettyprint">return f_ref();</div></div></code><=
/div><br><br><br></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/cd6e299d-7cec-4d8e-8a55-f25fd88d1b91%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/cd6e299d-7cec-4d8e-8a55-f25fd88d1b91=
%40isocpp.org</a>.<br />

------=_Part_191_69710619.1468573978382--

------=_Part_190_1624127528.1468573978381--

.
