220 5230 <CAMeU-s1SWuGH0J-o=ojWEV5w3JTO6J=OgDe92mf9w8dV7+emtw@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Teachability problems with std::move
Date: Wed, 26 Jun 2013 12:10:58 +0100
Lines: 93
Approved: news@gmane.org
Message-ID: <CAMeU-s1SWuGH0J-o=ojWEV5w3JTO6J=OgDe92mf9w8dV7+emtw@mail.gmail.com>
References: <CA+cyFgsYFbjG1M98PJS-XVzuJYbQmt7=4GOqS5_V5-WVJ0caLg@mail.gmail.com>
	<aa993593-2e71-4c1e-a510-d678672e5c17@isocpp.org>
	<73cad38f-c1b6-4ce3-bfc1-e4a660dbb638@isocpp.org>
	<CAFk2RUbJ1AqZ==1zsCQjtVm-YRuLhRjtXzyV=kPvX1FH8q9z6g@mail.gmail.com>
	<09ec0612-ac10-48fb-a186-bd3c200bd5fe@isocpp.org>
	<20f56505-2fba-4041-9d81-26088e67dc5d@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=089e0149c80041a66304e00cb370
X-Trace: ger.gmane.org 1372245064 17776 80.91.229.3 (26 Jun 2013 11:11:04 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 26 Jun 2013 11:11:04 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDC55PNFRYGRBQ4YVOHAKGQE2ZKOV2Q@isocpp.org Wed Jun 26 13:11:02 2013
Return-path: <std-proposals+bncBDC55PNFRYGRBQ4YVOHAKGQE2ZKOV2Q@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oa0-f70.google.com ([209.85.219.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDC55PNFRYGRBQ4YVOHAKGQE2ZKOV2Q@isocpp.org>)
	id 1Urncr-0000Ur-IK
	for gclcip-std-proposals@m.gmane.org; Wed, 26 Jun 2013 13:11:01 +0200
Original-Received: by mail-oa0-f70.google.com with SMTP id i4sf63694129oah.1
        for <gclcip-std-proposals@m.gmane.org>; Wed, 26 Jun 2013 04:11:00 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=x-beenthere:mime-version:in-reply-to:references:date:message-id
         :subject:from:to:x-original-sender:x-original-authentication-results
         :reply-to:precedence:mailing-list:list-id:x-google-group-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=Pz59H9UA74Jd1nxxdSAjQ1zNICtG3ekifYMT0LCbTUo=;
        b=ZxIXHGIjrv9OcLLxhl2ndhQcu+etPCEP3hoLiXUdK9MZHsoYNgfxbzyoDRHqrhwtfz
         qAulpJ+m3AyAes/G5mbV92l9jMb6vhRyLznpRFPTIQeILmK9EG3uklwf7HegWj9x4Q2t
         HEjjx4h+qv1ADaQW3eIU0e8wj2VLf6KSr0dJGcmg1ZYoMnmdOmdPbZpsZN/PYpsDTaMO
         /c/woYkPEL4cxQl83o0Or9qC0I8onjVJCLyUbmTqn2nobQfZwIhUPeExwLuwnmaS27i0
         T5a3Zt+oi0cmSTEwBK7k3EcD2eIAVaInA2ZUeAMu4Zdn8nKtRk6ebrxz+oVohhorc5CX
         4BoQ==
X-Received: by 10.182.226.170 with SMTP id rt10mr652549obc.13.1372245060555;
        Wed, 26 Jun 2013 04:11:00 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.66.103 with SMTP id e7ls68456obt.58.gmail; Wed, 26 Jun
 2013 04:10:58 -0700 (PDT)
X-Received: by 10.60.84.147 with SMTP id z19mr215702oey.21.1372245058773;
        Wed, 26 Jun 2013 04:10:58 -0700 (PDT)
Original-Received: from mail-oa0-x22b.google.com (mail-oa0-x22b.google.com [2607:f8b0:4003:c02::22b])
        by mx.google.com with ESMTPS id ko2si223376oeb.7.2013.06.26.04.10.58
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Wed, 26 Jun 2013 04:10:58 -0700 (PDT)
Received-SPF: pass (google.com: domain of mikhailsemenov1957@gmail.com designates 2607:f8b0:4003:c02::22b as permitted sender) client-ip=2607:f8b0:4003:c02::22b;
Original-Received: by mail-oa0-f43.google.com with SMTP id i7so14755183oag.30
        for <std-proposals@isocpp.org>; Wed, 26 Jun 2013 04:10:58 -0700 (PDT)
X-Received: by 10.60.41.66 with SMTP id d2mr212713oel.28.1372245058494; Wed,
 26 Jun 2013 04:10:58 -0700 (PDT)
Original-Received: by 10.60.14.2 with HTTP; Wed, 26 Jun 2013 04:10:58 -0700 (PDT)
In-Reply-To: <20f56505-2fba-4041-9d81-26088e67dc5d@isocpp.org>
X-Original-Sender: mikhailsemenov1957@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of mikhailsemenov1957@gmail.com designates 2607:f8b0:4003:c02::22b as
 permitted sender) smtp.mail=mikhailsemenov1957@gmail.com;       dkim=pass header.i=@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:5230
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/5230>

--089e0149c80041a66304e00cb370
Content-Type: text/plain; charset=ISO-8859-1

> Coming back to the original topic, are you really suggesting the code
above is the ideal form for teaching when to use std::move and when > not
to?  I think "return result;" is much simpler.

If you have to convert from std::unique_ptr<Foo> to std::unique_ptr<const
Foo>
the following code *WON'T COMPILE*;
*return result;*

*Try it in your compiler!*

My point is that if you have to convert  (from std::unique_ptr<Foo> to
std::unique_ptr<const Foo>) write it explicitly:

 *return std::unique_ptr<const Foo>(std::move(result));*

If you don't have to convert (you use the same unque_ptr types) than yes write
as you said:
**
*return result*.

-- 

--- 
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/.



--089e0149c80041a66304e00cb370
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div><font style=3D"BACKGROUND-COLOR:#ffffff" color=3D"#3333ff">&gt; Coming=
 back to the original topic, are you really suggesting the code above is th=
e ideal form for teaching when to use std::move and when &gt; not to?=A0 I =
think &quot;return result;&quot; is much simpler.<br>
</font></div>
<div><font style=3D"BACKGROUND-COLOR:#ffffff" color=3D"#3333ff"><font color=
=3D"#000000"></font></font>=A0</div>
<div><font style=3D"BACKGROUND-COLOR:#ffffff" color=3D"#3333ff"><font color=
=3D"#000000">If you have to convert from std::unique_ptr&lt;Foo&gt; to std:=
:unique_ptr&lt;const Foo&gt;</font></font></div>
<div>the following code <font color=3D"#ff0000"><strong>WON&#39;T COMPILE</=
strong></font>;</div>
<div><strong>return result;</strong></div>
<div>=A0</div>
<div><font color=3D"#ff6666"><strong>Try it in your compiler!</strong></fon=
t></div>
<div><font style=3D"BACKGROUND-COLOR:#ffffff" color=3D"#3333ff"><font color=
=3D"#000000"></font></font>=A0</div>
<div><font style=3D"BACKGROUND-COLOR:#ffffff" color=3D"#3333ff"><font color=
=3D"#000000">My point is that if you have to convert=A0 (from std::unique_p=
tr&lt;Foo&gt; to std::unique_ptr&lt;const Foo&gt;) write it explicitly:</fo=
nt></font></div>

<div><font style=3D"BACKGROUND-COLOR:#ffffff" color=3D"#3333ff"><font color=
=3D"#000000"></font>=A0</font></div>
<div>
<div><font style=3D"BACKGROUND-COLOR:#ffffff" color=3D"#3333ff"><font color=
=3D"#000000"><strong>return std::unique_ptr&lt;const Foo&gt;(std::move(resu=
lt));</strong></font></font></div></div>
<div>=A0</div>
<div><font color=3D"#000000">If you don&#39;t have to convert (you use the =
same unque_ptr types) than yes </font><font color=3D"#000000">write as you =
said:</font></div>
<div><font color=3D"#000000"><strong></strong></font>=A0</div>
<div><font color=3D"#000000"><strong>return result</strong>.</font></div>
<div><font color=3D"#000000"></font><br>=A0</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 />

--089e0149c80041a66304e00cb370--

.
