220 29857 <902b08de-322b-4a97-8ba2-dfd8d3eb88e6@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: szollosi.lorand@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Default constructor for lambdas
Date: Fri, 16 Dec 2016 15:21:12 -0800 (PST)
Lines: 130
Approved: news@gmane.org
Message-ID: <902b08de-322b-4a97-8ba2-dfd8d3eb88e6@isocpp.org>
References: <13497310-30de-4542-9ba4-fb1fbd730cb6@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_712_106992050.1481930472538"
X-Trace: blaine.gmane.org 1481930476 7217 195.159.176.226 (16 Dec 2016 23:21:16 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 16 Dec 2016 23:21:16 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDR7PROGSALRB2PN2HBAKGQE3EBP6NA@isocpp.org Sat Dec 17 00:21:10 2016
Return-path: <std-proposals+bncBDR7PROGSALRB2PN2HBAKGQE3EBP6NA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yw0-f199.google.com ([209.85.161.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDR7PROGSALRB2PN2HBAKGQE3EBP6NA@isocpp.org>)
	id 1cI1oL-0000e6-G3
	for gclcip-std-proposals@m.gmane.org; Sat, 17 Dec 2016 00:21:10 +0100
Original-Received: by mail-yw0-f199.google.com with SMTP id b66sf73568070ywh.2
        for <gclcip-std-proposals@m.gmane.org>; Fri, 16 Dec 2016 15:21:14 -0800 (PST)
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=auVXPDKyixz/y1ecYatVDx5IapwRhXBkfPh18O/VLKY=;
        b=Ok/g+7eThu2kTTqhQn/xmIaLnRhr4vNjjCFgzmlwpE8wBE9lHQr6EuytnjbJ8EiLa5
         yqdKbJlKTtdak9n/tr5r8RjyqV32NOfiZaPUYxMmHR7IRJVajzedvBVHjWhdGrV6oDeT
         8BonbtEzaQc1mu66RIBXzn6BEiyfDJbwKv+6urzrYDaJN5XGNb9Aq33chVFBgw55WVcx
         fsH3AG3u8+261F5hIdZ+KZoKoEtbViAE3nHnaYDVl3qciy4cTpmwaJw78EQFggilRuAj
         VOwtDSJrT8RxxGS8s1HDgFMfHTEvUW3K2yhwar770e8TxHPt1Q2PGcu30vpJh2BNbVDy
         g6VA==
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=auVXPDKyixz/y1ecYatVDx5IapwRhXBkfPh18O/VLKY=;
        b=A5tneNZ2NgUsgn2JtF4PoNJSGaqm0EfKcuFS8PDXRqdRgk9fA8V8XUWRzq+GRA0GhR
         PONsvH8mbIagfe6ZkrGUJfNaJC+pkCEavDbjAYnlLbtdDlDGWtmZhsTKgtSjhdS5yJiW
         BTn0lV6U4f8Qlosm+DVHWki3QwfiYwwBbLVyPdxcgBl6CTGCNlCsUT3Hty1T3SV1RFSR
         s9ftGwkNUiUEODzfC7OTIGRupEY6oI+LwZ0MPiL9sKwd5k059rfKWxsg/G7qUDCugsK1
         Zh1xEgXTVLWHPv0n/r9w1ZpAXs2Bo56/eHbicnGnnkCayrv+dGhT13mSSIxXwc9Cj5kq
         sCWw==
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=auVXPDKyixz/y1ecYatVDx5IapwRhXBkfPh18O/VLKY=;
        b=oKjh8xH9rr4dgUIYFCZPDuglY+SKB1nMVAPJYtTHcefpUsIBe/k3EgbFPJP8xMZP7+
         uYnf6+LunAKKcl9EYxMqNs7rkChl72kp+LkyenSQ990wpEDx6K+NyZDPbo7gV/aFQh6f
         Er6QKlVJLrC89RFXNyQxqICh4O/Tl/9fX3MhbDjX8fVydwH8WgBBmPfM155y3pIwniOj
         Qs9LzJywnpW3h9XF3mN1ZdEm8oLTOPvydXQcSZG7V0Vxv/FcC5igiyGoWnUdtfxyu6Mn
         qOGYq1Vu/opgyjP2Kk9uuF/JRNyvV7TmlLGeTLjUs2704uxiSm1iR1ELPWm1JN4avS2f
         DYcQ==
X-Gm-Message-State: AIkVDXKpFFMf6ZKQ04UoCsgFMA9qB9q1nHNZG85ztqFMWLRV7MBy7yGthVsg77dbi/uiXw==
X-Received: by 10.129.198.2 with SMTP id l2mr1475284ywi.75.1481930473720;
        Fri, 16 Dec 2016 15:21:13 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.39.136 with SMTP id c8ls9314408otb.9.gmail; Fri, 16 Dec
 2016 15:21:12 -0800 (PST)
X-Received: by 10.157.37.247 with SMTP id q110mr355670ota.5.1481930472953;
        Fri, 16 Dec 2016 15:21:12 -0800 (PST)
In-Reply-To: <13497310-30de-4542-9ba4-fb1fbd730cb6@isocpp.org>
X-Original-Sender: szollosi.lorand@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:29857
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/29857>

------=_Part_712_106992050.1481930472538
Content-Type: multipart/alternative; 
	boundary="----=_Part_713_1238446629.1481930472538"

------=_Part_713_1238446629.1481930472538
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi,

Minor thing - it will only work if all the captures of the lambda are=20
copyable. Even then it's non-trivial sometimes to choose schematics.

Thanks,
-lorro

2016. december 16., p=C3=A9ntek 23:47:45 UTC+1 id=C5=91pontban Vincent Reve=
rdy a=20
k=C3=B6vetkez=C5=91t =C3=ADrta:
>
> Hello.
>
> What is the reason why lambdas have no default constructor? Is there any=
=20
> technical reason behind that, or is it a pure design decision?
>
> I have a use case where not having a default constructor for lambda is=20
> annoying.
>
> Given C++17 class template deduction, I would like to be able to do:
>
> template <class F>
> class object
> {
>     constexpr object(F) {}            // Constructor
>     constexpr void execute() {F()();} // Default-construct the lambda,=20
> and run it
> };
>
> object myobject([](){std::cout<<"Hello world!"<<std::endl;});
> myobject.execute();
>
> What do you think? Remarks? Comments?
>
> Thank you very much.
> Best,
> Vincent Reverdy
>

--=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/902b08de-322b-4a97-8ba2-dfd8d3eb88e6%40isocpp.or=
g.

------=_Part_713_1238446629.1481930472538
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi,<br><br>Minor thing - it will only work if all the capt=
ures of the lambda are copyable. Even then it&#39;s non-trivial sometimes t=
o choose schematics.<br><br>Thanks,<br>-lorro<br><br>2016. december 16., p=
=C3=A9ntek 23:47:45 UTC+1 id=C5=91pontban Vincent Reverdy a k=C3=B6vetkez=
=C5=91t =C3=ADrta:<blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"=
ltr">Hello.<br><br>What is the reason why lambdas have no default construct=
or? Is there any
 technical reason behind that, or is it a pure design decision?<br><br>I ha=
ve a use case where not having a default constructor for lambda is annoying=
..<br><br>Given C++17 class template deduction, I would like to be able to d=
o:<br><br><div style=3D"background-color:rgb(250,250,250);border-color:rgb(=
187,187,187);border-style:solid;border-width:1px"><code><div><span style=3D=
"color:#008">template</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">&lt;</span><span style=3D"color:#008">class</span><span sty=
le=3D"color:#000"> F</span><span style=3D"color:#660">&gt;</span><span styl=
e=3D"color:#000"><br></span><span style=3D"color:#008">class</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#008">object</span><span st=
yle=3D"color:#000"><br></span><span style=3D"color:#660">{</span><span styl=
e=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">conste=
xpr</span><span style=3D"color:#000"> </span><span style=3D"color:#008">obj=
ect</span><span style=3D"color:#660">(</span><span style=3D"color:#000">F</=
span><span style=3D"color:#660">)</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#660">{}</span><span style=3D"color:#000"> =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0</span><span style=3D"color:#800">// Constru=
ctor</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color:#008">constexpr</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#008">void</span><span style=3D"color:#000"> execute</span><sp=
an style=3D"color:#660">()</span><span style=3D"color:#000"> </span><span s=
tyle=3D"color:#660">{</span><span style=3D"color:#000">F</span><span style=
=3D"color:#660">()();}</span><span style=3D"color:#000"> </span><span style=
=3D"color:#800">// Default-construct the lambda, and run it</span><span sty=
le=3D"color:#000"><br></span><span style=3D"color:#660">};</span><span styl=
e=3D"color:#000"><br><br></span><span style=3D"color:#008">object</span><sp=
an style=3D"color:#000"> myobject</span><span style=3D"color:#660">([](){</=
span><span style=3D"color:#000">std</span><span style=3D"color:#660">::</sp=
an><span style=3D"color:#000">cout</span><span style=3D"color:#660">&lt;&lt=
;</span><span style=3D"color:#080">&quot;<wbr>Hello world!&quot;</span><spa=
n style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000">std</span>=
<span style=3D"color:#660">::</span><span style=3D"color:#000">endl</span><=
span style=3D"color:#660">;});</span><span style=3D"color:#000"><br>myobjec=
t</span><span style=3D"color:#660">.</span><span style=3D"color:#000">execu=
te</span><span style=3D"color:#660">();</span><span style=3D"color:#000"><b=
r></span></div></code></div><br>What do you think? Remarks? Comments?<br><b=
r>Thank you very much.<br>Best,<br>Vincent Reverdy<br></div></blockquote></=
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/902b08de-322b-4a97-8ba2-dfd8d3eb88e6%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/902b08de-322b-4a97-8ba2-dfd8d3eb88e6=
%40isocpp.org</a>.<br />

------=_Part_713_1238446629.1481930472538--

------=_Part_712_106992050.1481930472538--

.
