220 17431 <CAFk2RUYre=zG1oX+rZKGm-mJ37gGvQkwWsa56eEkCmyQRq+Lew@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Ville Voutilainen <ville.voutilainen@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Proposal: lambda move capture
Date: Sun, 19 Apr 2015 17:26:41 +0300
Lines: 37
Approved: news@gmane.org
Message-ID: <CAFk2RUYre=zG1oX+rZKGm-mJ37gGvQkwWsa56eEkCmyQRq+Lew@mail.gmail.com>
References: <0c39ed29-d389-4894-bc65-71a9bb79cbe5@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: ger.gmane.org 1429453606 20745 80.91.229.3 (19 Apr 2015 14:26:46 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sun, 19 Apr 2015 14:26:46 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC5JHI7A7ALRBIXWZ2UQKGQEXTL442Y@isocpp.org Sun Apr 19 16:26:45 2015
Return-path: <std-proposals+bncBC5JHI7A7ALRBIXWZ2UQKGQEXTL442Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pd0-f200.google.com ([209.85.192.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC5JHI7A7ALRBIXWZ2UQKGQEXTL442Y@isocpp.org>)
	id 1YjqBI-0002n5-Mb
	for gclcip-std-proposals@m.gmane.org; Sun, 19 Apr 2015 16:26:44 +0200
Original-Received: by pdbqb6 with SMTP id qb6sf248631914pdb.3
        for <gclcip-std-proposals@m.gmane.org>; Sun, 19 Apr 2015 07:26:43 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:date
         :message-id:subject:from:to:content-type: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=vLPqBzsDclxi48WMj7auL6F20No/p61IZmXoKrnUaAg=;
        b=Nxw/WSFDaIeRBQxI5hTNeUDCJPzh9iZoQlKk93stztbSiXLBI/bvtavUM/Jb4bwTX9
         GJHmbi+ppN+v0zGVSYKDoo1nogzNCzqz0RC2M3bZ6HQyqjS7vkElQHabKAOVnkv+l8uh
         T730wsULfKIXmHKGv0dtAUYwziNa3KRxkuv5H6xfmZTVW2QQOSCEKezUvk8Pz5t1dudq
         PBCc4d3Gp1fL2XXl4uPQtPhOmWim3Qd8VsmXumXmeYffTLYL0VQ50vk9H8XfzYWLrTom
         5xvx0c1uGnIRQgvzuFQOF9R9Vf39zgKTc8mbpP65hIFVAJwh91AnVCGw1M1nH8CaiI7B
         SaMg==
X-Gm-Message-State: ALoCoQlIkd5pzvDx7P99rg4/gbwykw+m+amNZEvloFxVKAxErXwozuHzojprjRx4uM8dDbiVb+Cs
X-Received: by 10.66.182.166 with SMTP id ef6mr16865556pac.42.1429453603126;
        Sun, 19 Apr 2015 07:26:43 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.148.208 with SMTP id w199ls1829217iod.92.gmail; Sun, 19
 Apr 2015 07:26:42 -0700 (PDT)
X-Received: by 10.107.161.81 with SMTP id k78mr16633481ioe.41.1429453602392;
        Sun, 19 Apr 2015 07:26:42 -0700 (PDT)
Original-Received: from mail-ie0-x233.google.com (mail-ie0-x233.google.com. [2607:f8b0:4001:c03::233])
        by mx.google.com with ESMTPS id sb1si6026206igb.52.2015.04.19.07.26.42
        for <std-proposals@isocpp.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Sun, 19 Apr 2015 07:26:42 -0700 (PDT)
Received-SPF: pass (google.com: domain of ville.voutilainen@gmail.com designates 2607:f8b0:4001:c03::233 as permitted sender) client-ip=2607:f8b0:4001:c03::233;
Original-Received: by iebrs15 with SMTP id rs15so100662047ieb.3
        for <std-proposals@isocpp.org>; Sun, 19 Apr 2015 07:26:42 -0700 (PDT)
X-Received: by 10.50.30.130 with SMTP id s2mr15413610igh.11.1429453601788;
 Sun, 19 Apr 2015 07:26:41 -0700 (PDT)
Original-Received: by 10.36.213.70 with HTTP; Sun, 19 Apr 2015 07:26:41 -0700 (PDT)
In-Reply-To: <0c39ed29-d389-4894-bc65-71a9bb79cbe5@isocpp.org>
X-Original-Sender: ville.voutilainen@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of ville.voutilainen@gmail.com designates 2607:f8b0:4001:c03::233 as
 permitted sender) smtp.mail=ville.voutilainen@gmail.com;       dkim=pass
 header.i=@gmail.com;       dmarc=pass (p=NONE 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-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://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>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:17431
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/17431>

On 19 April 2015 at 17:06, Avi Kivity <avi@cloudius-systems.com> wrote:
> Lambdas currently support three styles of capture:
>
> 1. Init capture (fully generic) [x = expression]
> 2. Copy capture: [x], equivalent to [x = x]
> 3. Reference capture: [&x], roughly equivalent to [x = std::ref(x)]
>
> As I find myself typing [x = std::move(x)] more and more, I propose to
> support a fourth style:
>
> 4. Move capture: [&&x], equivalent to [x = std::move(x)]
>
> This would be very useful for move-only types such as unique_ptr<>.


I don't see that as a good idea. It looks like a
capture-by-rvalue-reference, but
you don't want to capture an rvalue reference, you want to capture a
value initialized
from an rvalue. Consistently, when you want to move into a function or
into a constructor,
you need to use std::move. For a lambda, you're initializing a
capture, which is rather
similar to calling a constructor, so using std::move there makes sense.

This syntax has been proposed in the committee too - we found it undesirable
due to the points above, and went for init-captures since they can do much more
than initialize from an rvalue.

-- 

--- 
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.
