220 5216 <aa993593-2e71-4c1e-a510-d678672e5c17@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Teachability problems with std::move
Date: Tue, 25 Jun 2013 10:55:47 -0700 (PDT)
Lines: 63
Approved: news@gmane.org
Message-ID: <aa993593-2e71-4c1e-a510-d678672e5c17@isocpp.org>
References: <CA+cyFgsYFbjG1M98PJS-XVzuJYbQmt7=4GOqS5_V5-WVJ0caLg@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_517_30114209.1372182947769"
X-Trace: ger.gmane.org 1372182951 13638 80.91.229.3 (25 Jun 2013 17:55:51 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 25 Jun 2013 17:55:51 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDC55PNFRYGRBJFTU6HAKGQEN33CM5Q@isocpp.org Tue Jun 25 19:55:52 2013
Return-path: <std-proposals+bncBDC55PNFRYGRBJFTU6HAKGQEN33CM5Q@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-gh0-f199.google.com ([209.85.160.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDC55PNFRYGRBJFTU6HAKGQEN33CM5Q@isocpp.org>)
	id 1UrXT3-0000nM-OQ
	for gclcip-std-proposals@m.gmane.org; Tue, 25 Jun 2013 19:55:49 +0200
Original-Received: by mail-gh0-f199.google.com with SMTP id g14sf13299211ghb.2
        for <gclcip-std-proposals@m.gmane.org>; Tue, 25 Jun 2013 10:55:48 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=x-beenthere:date:from:to:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-google-group-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=i52N/67Kl9vxXBfCnccJNZm1tPm615sMiij1yA4UtQw=;
        b=kA0qnKQY4QkXXIVSB/Zl34XmjaEksqMiym4aSPHkEHapkR6QxKqt+OYUuWWhXnYMRB
         AaF//5jXxLOBreWeoXL6qGGOKYEv4+iYMHZJb+paf++4V9dA+uU1AE0663khCxVYB6fc
         3D+9hfb1p2/JRfocp5LN3DNZfr+NP7YdS0JvP1h99BP0XRRFghfeVi3/iVl5eZdcsJAE
         QQMSGE1oQf0pt3FzOp3b+0CKcgRBINB299fbpGNq/JOlny3B0aZiCnADJaP15MLJelDR
         r2pHHY9/YawKpTiBSmyf9kMUg9JW6FxrECezvIpELgafgF7aH9F0gwoy78pbNYnDYXdm
         Eehw==
X-Received: by 10.236.124.165 with SMTP id x25mr134947yhh.4.1372182948870;
        Tue, 25 Jun 2013 10:55:48 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.37.229 with SMTP id b5ls116227qek.18.gmail; Tue, 25 Jun
 2013 10:55:48 -0700 (PDT)
X-Received: by 10.49.17.166 with SMTP id p6mr7017qed.18.1372182948147;
        Tue, 25 Jun 2013 10:55:48 -0700 (PDT)
In-Reply-To: <CA+cyFgsYFbjG1M98PJS-XVzuJYbQmt7=4GOqS5_V5-WVJ0caLg@mail.gmail.com>
X-Original-Sender: mikhailsemenov1957@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: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:5216
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/5216>

------=_Part_517_30114209.1372182947769
Content-Type: text/plain; charset=ISO-8859-1

I would suggest writing something like that:
 
*std::unique_ptr<const Foo> FooFactory() {*
*  std::unique_ptr<const Foo> result(static_cast<const Foo*>(new Foo));*
*  // ...*
*  return result;*
*}*
 
Then you don't need to deal with implicit conversions and writing *return 
std::move(result);*.
 
On the other hand, if you need to change the newly created Foo value: just 
deal with it first and then create the unique_ptr and return it.

 

-- 

--- 
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/.



------=_Part_517_30114209.1372182947769
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div>I would suggest writing something like that:</div><div><div>&nbsp;</di=
v><div><strong>std::unique_ptr&lt;const Foo&gt; FooFactory() {</strong></di=
v><div><strong>&nbsp; std::unique_ptr&lt;const Foo&gt; result(static_cast&l=
t;const Foo*&gt;(new Foo));</strong></div><div><strong>&nbsp; // ...</stron=
g></div><div><strong>&nbsp; return result;</strong></div><div><strong>}</st=
rong></div></div><div>&nbsp;</div><div>Then you don't need to deal with imp=
licit conversions and writing <strong>return std::move(result);</strong>.</=
div><div>&nbsp;</div><div>On the other hand, if you need to change the newl=
y created Foo value: just deal with it first and then create the unique_ptr=
 and return it.</div><div><br>
</div>

<p></p>

-- <br />
&nbsp;<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_517_30114209.1372182947769--

.
