220 29855 <13497310-30de-4542-9ba4-fb1fbd730cb6@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Vincent Reverdy <vince.rev@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Default constructor for lambdas
Date: Fri, 16 Dec 2016 14:47:45 -0800 (PST)
Lines: 129
Approved: news@gmane.org
Message-ID: <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_2411_169816189.1481928465523"
X-Trace: blaine.gmane.org 1481928467 29518 195.159.176.226 (16 Dec 2016 22:47:47 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 16 Dec 2016 22:47:47 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCYPFAORZMKRBEW62HBAKGQEQEQC5LY@isocpp.org Fri Dec 16 23:47:43 2016
Return-path: <std-proposals+bncBCYPFAORZMKRBEW62HBAKGQEQEQC5LY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qk0-f199.google.com ([209.85.220.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCYPFAORZMKRBEW62HBAKGQEQEQC5LY@isocpp.org>)
	id 1cI1Hy-0006nf-I5
	for gclcip-std-proposals@m.gmane.org; Fri, 16 Dec 2016 23:47:42 +0100
Original-Received: by mail-qk0-f199.google.com with SMTP id m67sf74981751qkf.0
        for <gclcip-std-proposals@m.gmane.org>; Fri, 16 Dec 2016 14:47:47 -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: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=RSWLECWMINlvZWnKUtfYYV8BGGfxi/st17ZYaknAnhE=;
        b=0M8g2fXVXeofiP0InH5O721kXMIgwabxA3/0/dbrWFh/iVQ/ZWnGoDhvbawcgZvG8y
         HGaJNs5tofA7qV/tpGxKfe4a5GYfdxb5gScHWFSLkYZjf385HbOn7SU5Qp3mIrIkmwic
         MY4LXWj1+aeVxwL9dCxBEkMi7w8CycjYsYpWO07UiC1x60DMKX83tyq7aEu0lqsPYDCa
         ca7K7Zj79qqzl0JeEtbtPJXvN4Wywc/8iGm0XY/myscH8DkHzkC0uVD4b7JcGEOWtp7/
         Q593Ocepe6vAy8ekhQl8XOEaHqPcQC7UINxqHuvAoGkGM1Oqv+HuTWz0a1p98kmN2dWD
         8AiQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id: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=RSWLECWMINlvZWnKUtfYYV8BGGfxi/st17ZYaknAnhE=;
        b=cJYDDseJt79jqaZBMJwIqQjx6lzgTEnc/Cg8jS8jGldXxApSbwMVjRsbm5Ko/CCVAs
         pfq9LmwOw5v/2NkmieO+iSvokffwHa4z4ItE8nwZ/jkfUFmlUjUtZ+cFJJ/3PcX/cJN+
         RmT4BN7i9FJkAvrty2dnMGMMlTXmb42y93OZOISkiFnkVuNiFRk3MTHCu5oxN0x1/JSC
         z/GxxPs5QfA24eiyc6cysJK/llI6xdoppDYajP0bFHy7b/aL36Cyr7m4/kO2ziJLf41q
         yEpjvZPaooega7YDnApQo5OZWat9Li78Tmgzf+GfiwqVlcKe0jDrUDDZezse95aYCBMW
         AemQ==
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: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=RSWLECWMINlvZWnKUtfYYV8BGGfxi/st17ZYaknAnhE=;
        b=MMQoTpGuMTDF5uaRNow0fI+Bb20twvGPD7hxDmJVIaKQAyv/kklevSVlpHdXemCCXI
         Z7hGeqE5k4pNXnsAutaCooeX0zfGJXvTpXpwvoXZAM400xHUX5vtlSKlvrjNTjJ7TyF0
         Bz21wwPj++KsRZmyRSPlzGlEFEjXJe68m2YsroH36KoYpduMVdbyFrCErarz/zVDdTit
         LrnPeJMnF0Dih4Lwh3Pxg+TYqitUeSudGo0AnAjBDH2EXw+P8oujBY81PTpCv/CkEfdf
         VnXb667NhpFYbvPHAxJyswKRAxvEuc6j+ABcJonDhgSvTybZBaqv6eSz8EqQNndelTRz
         IFGw==
X-Gm-Message-State: AIkVDXKlh4c6I2a0l6ZqLQ7RaCERvNiQKzw+nmq58TKvoY+gnwT64uAX+2sa29lNLFR/Aw==
X-Received: by 10.237.36.163 with SMTP id t32mr1130514qtc.22.1481928466803;
        Fri, 16 Dec 2016 14:47:46 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.23.193 with SMTP id j59ls9701350otj.24.gmail; Fri, 16 Dec
 2016 14:47:46 -0800 (PST)
X-Received: by 10.157.18.211 with SMTP id g77mr353706otg.14.1481928466056;
        Fri, 16 Dec 2016 14:47:46 -0800 (PST)
X-Original-Sender: Vince.Rev@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:29855
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/29855>

------=_Part_2411_169816189.1481928465523
Content-Type: multipart/alternative; 
	boundary="----=_Part_2412_2115786499.1481928465524"

------=_Part_2412_2115786499.1481928465524
Content-Type: text/plain; charset=UTF-8

Hello.

What is the reason why lambdas have no default constructor? Is there any 
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 
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, 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

-- 
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/13497310-30de-4542-9ba4-fb1fbd730cb6%40isocpp.org.

------=_Part_2412_2115786499.1481928465524
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hello.<br><br>What is the reason why lambdas have no defau=
lt constructor? 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; overflow-wrap:=
 break-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div class=
=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">template</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> F</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">class</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">object</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">constexpr</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">object</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">F</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">{}</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0</s=
pan><span style=3D"color: #800;" class=3D"styled-by-prettify">// Constructo=
r</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>constexpr</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">void</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> execute</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">F</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">()();}</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by=
-prettify">// Default-construct the lambda, and run it</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">object</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> myobject</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">([](){</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">std</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">cout</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
lt;&lt;</span><span style=3D"color: #080;" class=3D"styled-by-prettify">&qu=
ot;Hello world!&quot;</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">std</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">endl</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;});</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>myobject</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">execute</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br></span></div></code></div><br>W=
hat do you think? Remarks? Comments?<br><br>Thank you very much.<br>Best,<b=
r>Vincent Reverdy<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/13497310-30de-4542-9ba4-fb1fbd730cb6%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/13497310-30de-4542-9ba4-fb1fbd730cb6=
%40isocpp.org</a>.<br />

------=_Part_2412_2115786499.1481928465524--

------=_Part_2411_169816189.1481928465523--

.
