220 25489 <82db5d5a-bad9-42ce-b1ad-66bcc0dd20b0@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: isocppgroup@denisbider.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Relocation as a solution for the valueless
 variant problem?
Date: Fri, 8 Apr 2016 21:05:30 -0700 (PDT)
Lines: 852
Approved: news@gmane.org
Message-ID: <82db5d5a-bad9-42ce-b1ad-66bcc0dd20b0@isocpp.org>
References: <b4feb52d-4cd0-475f-9f3d-6694564bc1b0@isocpp.org>
 <4187538d-68fa-4582-ba26-f406479abe67@isocpp.org>
 <eafd831f-85d2-430c-9969-7d084e6d28d2@isocpp.org>
 <CALQmNFggBQSADjEqS7pEzcdPSStGJfXkJdX0d2CwW_TmwqA=yQ@mail.gmail.com>
 <105d82bc-e1cf-4795-894c-112cd591c3af@isocpp.org>
 <CALQmNFja3Kt1XRR8S7Qr3rOktChVzuDGO7ZtSaQpsWaohU6wAA@mail.gmail.com>
 <4f31b957-05be-47cf-a1ca-03f33a9900c0@isocpp.org>
 <CALQmNFgoV-Rg4T6+KqMFt6vNa7GCDpU=jVLRcnK4dDd+eBby8A@mail.gmail.com>
 <30181f63-7189-494d-9294-3f8b8759308f@isocpp.org>
 <d7eee27f-bdfc-45b0-9c29-508dd01975b3@isocpp.org>
 <cad96977-d5d4-4eea-8169-ae1ceb8b6477@isocpp.org>
 <456f6164-031c-4ccc-ba25-39fcb5714b98@isocpp.org>
 <96061c41-6f44-468b-b5ec-fb1fd6fad4b7@isocpp.org>
 <f92d4647-9aca-4471-bdc2-c7caba2e2128@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1139_1556648077.1460174730295"
X-Trace: ger.gmane.org 1460174736 28884 80.91.229.3 (9 Apr 2016 04:05:36 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 9 Apr 2016 04:05:36 +0000 (UTC)
Cc: isocppgroup@denisbider.com, barry.revzin@gmail.com
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBD5LNK7YQYJRBDH7UG4AKGQEAZAWV6Q@isocpp.org Sat Apr 09 06:05:35 2016
Return-path: <std-proposals+bncBD5LNK7YQYJRBDH7UG4AKGQEAZAWV6Q@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pa0-f72.google.com ([209.85.220.72])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBD5LNK7YQYJRBDH7UG4AKGQEAZAWV6Q@isocpp.org>)
	id 1aok9O-0003cr-IA
	for gclcip-std-proposals@m.gmane.org; Sat, 09 Apr 2016 06:05:35 +0200
Original-Received: by mail-pa0-f72.google.com with SMTP id zy2sf136037227pac.1
        for <gclcip-std-proposals@m.gmane.org>; Fri, 08 Apr 2016 21:05:34 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:cc: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=Ry2wMT1jyVMkz9WI4zjV77Nt1U6epW3Hd+X+6plLLvE=;
        b=K0qJ3NIAFNs/NlTMh+S2Yh4GZE9YfkVqt4gZA/1U7RHSZOz4KwHxJ32VZpckQGbvFj
         OGMy2sxQvolAx7BjAHt2OsMXptHPnllN4GVo4mYDPzRMqX+26C5Ux/H98+EQhpiQA5Oj
         79mTRKGzzNegO37cdGk4Yywtrz/2agS4UpulhrO9DSuGthB3DNTJSSmHVGecpDCj13VZ
         7NPRVxKZ55sXokRGvFlzJ05VgVRGLsx5c/5KOlGSYSJDBbekXhgimVvPSp8eonLor21j
         uJpQbGwTP++MAcbTtayRO1MzWVMtbt3V7UBA+CiFRXxwgdJzC/jSxHn/UIzvqpdOQIvX
         Fm+w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:cc: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=Ry2wMT1jyVMkz9WI4zjV77Nt1U6epW3Hd+X+6plLLvE=;
        b=F5eXGt3zQRk8Trdq1Lwgw48fk4BqCgWjPJ5MD+w/zM5PI0KBFoD1mJ4xEkCLoPGJT3
         /d29L1E/DDpGhybBNR3OqMzwl/1owz6hXn+tNAA1rzdYpJrALPnlN78u1TGdgo8JJNaE
         RK77ySkXmHoYg60MCz9yk94rSA3633vQWwVu0vjKDxjasxpzESI7AibOIFTeQBVOj+8J
         ea4WZYflm6hatpI+s3IQxlaBmKRBgGhnNuqZa6QxUXgcE4Hv0Ovxmx7Um3R0RqQ7MwEU
         miMm+y7OON9AIVIsRDFIyihAlWlj3I+YHN5Hu4HThgVKyV7tEfh/99ybp9C6s9d5/nVV
         1gdg==
X-Gm-Message-State: AD7BkJJxJNLTEl4SRsSoJ3uqUS9By+6bVp0SEtKNMrbvvxiANvOttD87nCMM23facTbnYQ==
X-Received: by 10.98.33.76 with SMTP id h73mr7853170pfh.0.1460174733346;
        Fri, 08 Apr 2016 21:05:33 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.169.39 with SMTP id s39ls1354102ioe.46.gmail; Fri, 08 Apr
 2016 21:05:31 -0700 (PDT)
X-Received: by 10.50.43.234 with SMTP id z10mr166136igl.4.1460174731722;
        Fri, 08 Apr 2016 21:05:31 -0700 (PDT)
In-Reply-To: <f92d4647-9aca-4471-bdc2-c7caba2e2128@isocpp.org>
X-Original-Sender: isocppgroup@denisbider.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: 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:25489
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/25489>

------=_Part_1139_1556648077.1460174730295
Content-Type: multipart/alternative; 
	boundary="----=_Part_1140_479930691.1460174730296"

------=_Part_1140_479930691.1460174730296
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

I have uploaded a new version of the proposal:

http://denisbider.com/Relocator.pdf

Main changes:

- Indirect use of relocation via copy/move optimization is now explicitly=
=20
defined.

- There is a new annex, proposing a syntax by which a language user can=20
ensure that copy/move optimizations are done as intended.

The proposed new syntax helps not only with relocation, but also in=20
existing situations where a developer wants to ensure that deep copy is not=
=20
being accidentally used.

The proposed syntax simplifies the variant example as follows:

=20

  X temp { std::move(a.x) };

  b.y.~Y();

  *new* (&b.x) X(std::must_relocate(temp));

=20


It also allows for this:

=20

  BigPart MakeBigPart() {

    BigPart part;

    ...

    *return* std::must_move(part);     // may elide, relocate, or move -=20
but not copy

  }

=20

  std::unique_ptr<BigThing> MakeBigThing() {

    *auto* part =3D MakeBigPart();

    *auto* thng =3D std::make_unique<BigThing>(std::must_move(part));  //=
=20
relocate/move

    *return* thng;                     // do not care if copied

  }

=20

Comments welcome.


On Friday, April 8, 2016 at 4:30:52 PM UTC-6, isocp...@denisbider.com wrote=
:

> Or, since we have this problem already when distinguishing between move=
=20
> and copy construction: how about a family of special blessed functions,=
=20
> like this?
>
> template <typename T> T const& require_copy     (T const&);template <type=
name T> T&&      require_move     (T&);template <typename T> T&       requi=
re_relocate (T&);
>
>
> Each of these would require the compiler to flag the returned reference,=
=20
> and perform a compile-time verification that the reference does in fact e=
nd=20
> up being passed to a copy constructor; move constructor; or relocator,=20
> respectively.
>
> This would be useful even without relocate. It would allow code like this=
:
>
> BigObj MakeBigObj() {
>   BigObj x;
>   x.This();
>   x.That();
>   return std::require_move(x);}
>
>
> ... to verify that what's happening is indeed move construction - not cop=
y=20
> construction, by accident.
>
>
> On Friday, April 8, 2016 at 3:44:24 PM UTC-6, isocp...@denisbider.com=20
> wrote:
>
>> You are quite correct. This aspect is being implied, rather than being=
=20
>> addressed.
>> =20
>> I am toying with the following text - currently rather informal:
>>
>> "Move optimization=20
>>
>> When a type is relocatable; then in situations where an implementation=
=20
>> would otherwise move an object value to an object of same type by invoki=
ng=20
>> a move constructor, followed by destruction of the moved-from object; an=
d=20
>> where no use of the moved-from object occurs between move and destructio=
n;=20
>> the implementation may instead invoke the type=E2=80=99s relocator, elid=
ing the=20
>> move constructor and destructor.
>> This move optimization *must* occur when move construction followed by=
=20
>> destruction would otherwise be used when returning a relocatable type by=
=20
>> value from a function, into a new object of same type."
>>
>> =20
>> This would require relocation for return by value, if relocation is=20
>> available and copy elision isn't. This would be similar to how move vs.=
=20
>> copy construction is already chosen right now.=20
>> =20
>> It would also open the door for a compiler to detect when an object is=
=20
>> being moved to a new location, followed by destruction in the previous=
=20
>> location. In this case, the compiler *could* use relocation (move=20
>> destruction), but is not forced to.
>> =20
>> An open concern here is whether this would be, in practice, too subtle.=
=20
>> For example, a developer might want to ensure that relocation is used,=
=20
>> instead of move construction + destruction:
>> =20
>>
>> std::unique_ptr<Thing> MakeThing() {
>>   std::list<int> lst =3D ...;
>>   InitializeList(lst);
>>   return std::make_unique<Thing>(std::move(lst));
>>     // Is this copy construction, move construction, or relocation?}
>>
>> =20
>> On the one hand, currently, we do not have syntax that the developer=20
>> could use to ensure move construction is used, rather than copy=20
>> construction. The developer just has to use syntax that allows for move=
=20
>> construction, and then count on that a move constructor is available.
>> =20
>> Suppose that we have relocation, and the compiler has determined to use=
=20
>> relocation in the above example.
>> =20
>> Then, someone modifies the above function as follows:
>> =20
>>
>> std::unique_ptr<Thing> MakeThing() {
>>   std::list<int> lst =3D ...;
>>   InitializeList(lst);
>>   auto thing =3D std::make_unique<Thing>(std::move(lst));
>>   ReuseListForOtherPurpose(lst);
>>   return thing;}
>>
>> =20
>> Now, this definitely no longer uses relocation, because *lst* is=20
>> being used again.
>>
>> Is this a concern? How do we prevent this?
>>
>> To avoid introducing a keyword, one way could be to add a blessed=20
>> standard library function, say *std::final_reference*:=20
>>
>> std::unique_ptr<Thing> MakeThing() {
>>   std::list<int> lst =3D ...;
>>   InitializeList(lst);
>>   auto thing =3D std::make_unique<Thing>(std::final_reference(lst));
>>   ReuseListForOtherPurpose(lst);  // Error: use of "lst" after final_ref=
erence
>>   return thing;}
>>
>>
>> This would require a compiler to detect the reuse of "lst" after it's=20
>> used in *std::final_reference*, and flag an error when "lst" is reused.
>>
>> An alternative to a blessed function would be a new keyword, e.g.=20
>> "final_reference".
>>
>> Thoughts? Ideas?
>>
>> =20
>> On Friday, April 8, 2016 at 2:46:35 PM UTC-6, barry....@gmail.com wrote:
>>
>>> > If your relocation support can't even perform relocation in this most=
=20
>>>> simple of cases:
>>>> =20
>>>> =20
>>>> How does it *not* handle that case? If std::list has a relocator, the=
=20
>>>> compiler can just call the relocator in this case:
>>>> =20
>>>>
>>>>   std::list<T> SomeFunc() {
>>>>     std::list<T> lt =3D ...
>>>>     ...
>>>>     return lt; // no special syntax needed; compiler calls relocator >=
>list<T>
>>>>   }
>>>>
>>>> =20
>>>> What prevents the compiler from doing this?
>>>>
>>> =20
>>> As far as I can tell, your proposal doesn't say anything about this=20
>>> case, or about automatic objects at all. Your invocation section only=
=20
>>> addresses the use-case of "relocating" one pointer to another.=20
>>> =20
>>> You should take advantage of the feedback opportunity to improve your=
=20
>>> proposal. There's no need to be so defensive.=20
>>>
>>

--=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/82db5d5a-bad9-42ce-b1ad-66bcc0dd20b0%40isocpp.or=
g.

------=_Part_1140_479930691.1460174730296
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>I have uploaded a new version of the proposal:</div><=
div><br></div><div><a href=3D"http://denisbider.com/Relocator.pdf">http://d=
enisbider.com/Relocator.pdf</a></div><div><br></div><div>Main changes:</div=
><div><br></div><div>- Indirect use of relocation via copy/move optimizatio=
n is now explicitly defined.</div><div><br></div><div>-=C2=A0There is a new=
=C2=A0annex, proposing=C2=A0a syntax by which a language user can ensure th=
at copy/move optimizations are done as intended.</div><div><br></div><div>T=
he proposed new syntax helps not only with relocation, but also in existing=
 situations where a developer wants to ensure that deep copy is not being a=
ccidentally used.</div><div><br></div><div>The proposed syntax simplifies t=
he variant example as follows:</div><div><br></div><div><pre style=3D"backg=
round: rgb(246, 248, 255); margin-top: 0in; vertical-align: middle;"><span =
style=3D"color: rgb(0, 0, 32); font-family: Consolas;"><font size=3D"2">=C2=
=A0</font></span></pre><pre style=3D"background: rgb(246, 248, 255); margin=
-top: 0in; vertical-align: middle;"><font size=3D"2"><span style=3D"color: =
rgb(0, 0, 32); font-family: Consolas;"><span style=3D"mso-spacerun: yes;">=
=C2=A0 </span>X temp </span><span style=3D"padding: 0in; border: 1pt window=
text; border-image: none; color: rgb(64, 96, 128); font-family: Consolas; m=
so-border-alt: none windowtext 0in;">{</span><span style=3D"color: rgb(0, 0=
, 32); font-family: Consolas;"> </span><span style=3D"padding: 0in; border:=
 1pt windowtext; border-image: none; color: rgb(0, 102, 238); font-family: =
Consolas; mso-border-alt: none windowtext 0in;">std</span><span style=3D"pa=
dding: 0in; border: 1pt windowtext; border-image: none; color: rgb(64, 96, =
128); font-family: Consolas; mso-border-alt: none windowtext 0in;">::</span=
><span style=3D"padding: 0in; border: 1pt windowtext; border-image: none; c=
olor: rgb(0, 48, 96); font-family: Consolas; mso-border-alt: none windowtex=
t 0in;">move</span><span style=3D"padding: 0in; border: 1pt windowtext; bor=
der-image: none; color: rgb(48, 128, 128); font-family: Consolas; mso-borde=
r-alt: none windowtext 0in;">(</span><span style=3D"color: rgb(0, 0, 32); f=
ont-family: Consolas;">a</span><span style=3D"padding: 0in; border: 1pt win=
dowtext; border-image: none; color: rgb(48, 128, 128); font-family: Consola=
s; mso-border-alt: none windowtext 0in;">.</span><span style=3D"color: rgb(=
0, 0, 32); font-family: Consolas;">x</span><span style=3D"padding: 0in; bor=
der: 1pt windowtext; border-image: none; color: rgb(48, 128, 128); font-fam=
ily: Consolas; mso-border-alt: none windowtext 0in;">)</span><span style=3D=
"color: rgb(0, 0, 32); font-family: Consolas;"> </span><span style=3D"paddi=
ng: 0in; border: 1pt windowtext; border-image: none; color: rgb(64, 96, 128=
); font-family: Consolas; mso-border-alt: none windowtext 0in;">};</span></=
font></pre><pre style=3D"background: rgb(246, 248, 255); margin-top: 0in; v=
ertical-align: middle;"><font size=3D"2"><span style=3D"color: rgb(0, 0, 32=
); font-family: Consolas;"> <span style=3D"mso-spacerun: yes;">=C2=A0</span=
>b</span><span style=3D"padding: 0in; border: 1pt windowtext; border-image:=
 none; color: rgb(48, 128, 128); font-family: Consolas; mso-border-alt: non=
e windowtext 0in;">.</span><span style=3D"color: rgb(0, 0, 32); font-family=
: Consolas;">y</span><span style=3D"padding: 0in; border: 1pt windowtext; b=
order-image: none; color: rgb(48, 128, 128); font-family: Consolas; mso-bor=
der-alt: none windowtext 0in;">.~</span><span style=3D"color: rgb(0, 0, 32)=
; font-family: Consolas;">Y</span><span style=3D"padding: 0in; border: 1pt =
windowtext; border-image: none; color: rgb(48, 128, 128); font-family: Cons=
olas; mso-border-alt: none windowtext 0in;">()</span><span style=3D"padding=
: 0in; border: 1pt windowtext; border-image: none; color: rgb(64, 96, 128);=
 font-family: Consolas; mso-border-alt: none windowtext 0in;">;</span></fon=
t></pre><pre style=3D"background: rgb(246, 248, 255); margin-top: 0in; vert=
ical-align: middle;"><font size=3D"2"><span style=3D"color: rgb(0, 0, 32); =
font-family: Consolas;"><span style=3D"mso-spacerun: yes;">=C2=A0 </span></=
span><b><span style=3D"padding: 0in; border: 1pt windowtext; border-image: =
none; color: rgb(32, 0, 128); font-family: Consolas; mso-border-alt: none w=
indowtext 0in;">new</span></b><span style=3D"color: rgb(0, 0, 32); font-fam=
ily: Consolas;"> </span><span style=3D"padding: 0in; border: 1pt windowtext=
; border-image: none; color: rgb(48, 128, 128); font-family: Consolas; mso-=
border-alt: none windowtext 0in;">(&amp;</span><span style=3D"color: rgb(0,=
 0, 32); font-family: Consolas;">b</span><span style=3D"padding: 0in; borde=
r: 1pt windowtext; border-image: none; color: rgb(48, 128, 128); font-famil=
y: Consolas; mso-border-alt: none windowtext 0in;">.</span><span style=3D"c=
olor: rgb(0, 0, 32); font-family: Consolas;">x</span><span style=3D"padding=
: 0in; border: 1pt windowtext; border-image: none; color: rgb(48, 128, 128)=
; font-family: Consolas; mso-border-alt: none windowtext 0in;">)</span><spa=
n style=3D"color: rgb(0, 0, 32); font-family: Consolas;"> X</span><span sty=
le=3D"padding: 0in; border: 1pt windowtext; border-image: none; color: rgb(=
48, 128, 128); font-family: Consolas; mso-border-alt: none windowtext 0in;"=
>(</span><span style=3D"padding: 0in; border: 1pt windowtext; border-image:=
 none; color: rgb(0, 102, 238); font-family: Consolas; mso-border-alt: none=
 windowtext 0in;">std</span><span style=3D"padding: 0in; border: 1pt window=
text; border-image: none; color: rgb(64, 96, 128); font-family: Consolas; m=
so-border-alt: none windowtext 0in;">::</span><span style=3D"padding: 0in; =
border: 1pt windowtext; border-image: none; color: rgb(0, 48, 96); font-fam=
ily: Consolas; mso-border-alt: none windowtext 0in;">must_relocate</span><s=
pan style=3D"padding: 0in; border: 1pt windowtext; border-image: none; colo=
r: rgb(48, 128, 128); font-family: Consolas; mso-border-alt: none windowtex=
t 0in;">(</span><span style=3D"color: rgb(0, 0, 32); font-family: Consolas;=
">temp</span><span style=3D"padding: 0in; border: 1pt windowtext; border-im=
age: none; color: rgb(48, 128, 128); font-family: Consolas; mso-border-alt:=
 none windowtext 0in;">))</span><span style=3D"padding: 0in; border: 1pt wi=
ndowtext; border-image: none; color: rgb(64, 96, 128); font-family: Consola=
s; mso-border-alt: none windowtext 0in;">;</span></font></pre><pre style=3D=
"background: rgb(246, 248, 255); margin-top: 0in; vertical-align: middle;">=
<span style=3D"color: rgb(0, 0, 32); font-family: Consolas;"><font size=3D"=
2">=C2=A0</font></span></pre></div><div><br></div><div>It also allows for t=
his:</div><div><br></div><div><font color=3D"#000000" face=3D"Times New Rom=
an" size=3D"3">

</font><p style=3D"background: rgb(246, 248, 255); margin: 0in 0in 0pt; lin=
e-height: normal; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt =
320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732=
..8pt;"><span style=3D"color: rgb(0, 0, 32); font-family: Consolas; font-siz=
e: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;">=C2=A0</spa=
n></p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"background: rgb(246, 248, 255); margin: 0in 0in 0pt; lin=
e-height: normal; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt =
320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732=
..8pt;"><span style=3D"color: rgb(0, 0, 32); font-family: Consolas; font-siz=
e: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;"><span style=
=3D"mso-spacerun: yes;">=C2=A0 </span>BigPart MakeBigPart</span><span style=
=3D"color: rgb(48, 128, 128); font-family: Consolas; font-size: 10pt; mso-f=
areast-font-family: &quot;Times New Roman&quot;;">()</span><span style=3D"c=
olor: rgb(0, 0, 32); font-family: Consolas; font-size: 10pt; mso-fareast-fo=
nt-family: &quot;Times New Roman&quot;;"> </span><span style=3D"color: rgb(=
64, 96, 128); font-family: Consolas; font-size: 10pt; mso-fareast-font-fami=
ly: &quot;Times New Roman&quot;;">{</span></p><font color=3D"#000000" face=
=3D"Times New Roman" size=3D"3">

</font><p style=3D"background: rgb(246, 248, 255); margin: 0in 0in 0pt; lin=
e-height: normal; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt =
320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732=
..8pt;"><span style=3D"color: rgb(0, 0, 32); font-family: Consolas; font-siz=
e: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;"><span style=
=3D"mso-spacerun: yes;">=C2=A0</span><span style=3D"mso-spacerun: yes;">=C2=
=A0 </span><span style=3D"mso-spacerun: yes;">=C2=A0</span>BigPart part</sp=
an><span style=3D"color: rgb(64, 96, 128); font-family: Consolas; font-size=
: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;">;</span></p>=
<font color=3D"#000000" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"background: rgb(246, 248, 255); margin: 0in 0in 0pt; lin=
e-height: normal; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt =
320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732=
..8pt;"><span style=3D"color: rgb(0, 0, 32); font-family: Consolas; font-siz=
e: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;"><span style=
=3D"mso-spacerun: yes;">=C2=A0 </span><span style=3D"mso-spacerun: yes;">=
=C2=A0=C2=A0</span>...</span></p><font color=3D"#000000" face=3D"Times New =
Roman" size=3D"3">

</font><p style=3D"background: rgb(246, 248, 255); margin: 0in 0in 0pt; lin=
e-height: normal; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt =
320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732=
..8pt;"><span style=3D"color: rgb(0, 0, 32); font-family: Consolas; font-siz=
e: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;"><span style=
=3D"mso-spacerun: yes;">=C2=A0 </span><span style=3D"mso-spacerun: yes;">=
=C2=A0=C2=A0</span></span><b><span style=3D"color: rgb(32, 0, 128); font-fa=
mily: Consolas; font-size: 10pt; mso-fareast-font-family: &quot;Times New R=
oman&quot;;">return</span></b><span style=3D"color: rgb(0, 0, 32); font-fam=
ily: Consolas; font-size: 10pt; mso-fareast-font-family: &quot;Times New Ro=
man&quot;;"> </span><span style=3D"color: rgb(0, 102, 238); font-family: Co=
nsolas; font-size: 10pt; mso-fareast-font-family: &quot;Times New Roman&quo=
t;;">std</span><span style=3D"color: rgb(64, 96, 128); font-family: Consola=
s; font-size: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;">=
::</span><span style=3D"color: rgb(0, 48, 96); font-family: Consolas; font-=
size: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;">must_mov=
e</span><span style=3D"color: rgb(48, 128, 128); font-family: Consolas; fon=
t-size: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;">(</spa=
n><span style=3D"color: rgb(0, 0, 32); font-family: Consolas; font-size: 10=
pt; mso-fareast-font-family: &quot;Times New Roman&quot;;">part</span><span=
 style=3D"color: rgb(48, 128, 128); font-family: Consolas; font-size: 10pt;=
 mso-fareast-font-family: &quot;Times New Roman&quot;;">)</span><span style=
=3D"color: rgb(64, 96, 128); font-family: Consolas; font-size: 10pt; mso-fa=
reast-font-family: &quot;Times New Roman&quot;;">;</span><span style=3D"col=
or: rgb(0, 0, 32); font-family: Consolas; font-size: 10pt; mso-fareast-font=
-family: &quot;Times New Roman&quot;;"><span style=3D"mso-spacerun: yes;">=
=C2=A0 </span><span style=3D"mso-spacerun: yes;">=C2=A0=C2=A0=C2=A0</span><=
/span><span style=3D"color: rgb(89, 89, 121); font-family: Consolas; font-s=
ize: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;">// may el=
ide, relocate, or move - but not copy</span></p><font color=3D"#000000" fac=
e=3D"Times New Roman" size=3D"3">

</font><p style=3D"background: rgb(246, 248, 255); margin: 0in 0in 0pt; lin=
e-height: normal; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt =
320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732=
..8pt;"><span style=3D"color: rgb(64, 96, 128); font-family: Consolas; font-=
size: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;"><span st=
yle=3D"mso-spacerun: yes;">=C2=A0 </span>}</span></p><font color=3D"#000000=
" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"background: rgb(246, 248, 255); margin: 0in 0in 0pt; lin=
e-height: normal; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt =
320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732=
..8pt;"><span style=3D"color: rgb(0, 0, 32); font-family: Consolas; font-siz=
e: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;">=C2=A0</spa=
n></p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"background: rgb(246, 248, 255); margin: 0in 0in 0pt; lin=
e-height: normal; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt =
320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732=
..8pt;"><span style=3D"color: rgb(0, 102, 238); font-family: Consolas; font-=
size: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;"><span st=
yle=3D"mso-spacerun: yes;">=C2=A0 </span>std</span><span style=3D"color: rg=
b(64, 96, 128); font-family: Consolas; font-size: 10pt; mso-fareast-font-fa=
mily: &quot;Times New Roman&quot;;">::</span><span style=3D"color: rgb(0, 4=
8, 96); font-family: Consolas; font-size: 10pt; mso-fareast-font-family: &q=
uot;Times New Roman&quot;;">unique_ptr</span><span style=3D"color: rgb(64, =
96, 128); font-family: Consolas; font-size: 10pt; mso-fareast-font-family: =
&quot;Times New Roman&quot;;">&lt;</span><span style=3D"color: rgb(0, 0, 32=
); font-family: Consolas; font-size: 10pt; mso-fareast-font-family: &quot;T=
imes New Roman&quot;;">BigThing</span><span style=3D"color: rgb(64, 96, 128=
); font-family: Consolas; font-size: 10pt; mso-fareast-font-family: &quot;T=
imes New Roman&quot;;">&gt;</span><span style=3D"color: rgb(0, 0, 32); font=
-family: Consolas; font-size: 10pt; mso-fareast-font-family: &quot;Times Ne=
w Roman&quot;;"> MakeBigThing</span><span style=3D"color: rgb(48, 128, 128)=
; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: &quot;Ti=
mes New Roman&quot;;">()</span><span style=3D"color: rgb(0, 0, 32); font-fa=
mily: Consolas; font-size: 10pt; mso-fareast-font-family: &quot;Times New R=
oman&quot;;"> </span><span style=3D"color: rgb(64, 96, 128); font-family: C=
onsolas; font-size: 10pt; mso-fareast-font-family: &quot;Times New Roman&qu=
ot;;">{</span></p><font color=3D"#000000" face=3D"Times New Roman" size=3D"=
3">

</font><p style=3D"background: rgb(246, 248, 255); margin: 0in 0in 0pt; lin=
e-height: normal; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt =
320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732=
..8pt;"><span style=3D"color: rgb(0, 0, 32); font-family: Consolas; font-siz=
e: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;"><span style=
=3D"mso-spacerun: yes;">=C2=A0 </span><span style=3D"mso-spacerun: yes;">=
=C2=A0=C2=A0</span></span><b><span style=3D"color: rgb(32, 0, 128); font-fa=
mily: Consolas; font-size: 10pt; mso-fareast-font-family: &quot;Times New R=
oman&quot;;">auto</span></b><span style=3D"color: rgb(0, 0, 32); font-famil=
y: Consolas; font-size: 10pt; mso-fareast-font-family: &quot;Times New Roma=
n&quot;;"> part </span><span style=3D"color: rgb(48, 128, 128); font-family=
: Consolas; font-size: 10pt; mso-fareast-font-family: &quot;Times New Roman=
&quot;;">=3D</span><span style=3D"color: rgb(0, 0, 32); font-family: Consol=
as; font-size: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;"=
> MakeBigPart</span><span style=3D"color: rgb(48, 128, 128); font-family: C=
onsolas; font-size: 10pt; mso-fareast-font-family: &quot;Times New Roman&qu=
ot;;">()</span><span style=3D"color: rgb(64, 96, 128); font-family: Consola=
s; font-size: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;">=
;</span></p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"background: rgb(246, 248, 255); margin: 0in 0in 0pt; lin=
e-height: normal; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt =
320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732=
..8pt;"><span style=3D"color: rgb(0, 0, 32); font-family: Consolas; font-siz=
e: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;"><span style=
=3D"mso-spacerun: yes;">=C2=A0 </span><span style=3D"mso-spacerun: yes;">=
=C2=A0=C2=A0</span></span><b><span style=3D"color: rgb(32, 0, 128); font-fa=
mily: Consolas; font-size: 10pt; mso-fareast-font-family: &quot;Times New R=
oman&quot;;">auto</span></b><span style=3D"color: rgb(0, 0, 32); font-famil=
y: Consolas; font-size: 10pt; mso-fareast-font-family: &quot;Times New Roma=
n&quot;;"> thng </span><span style=3D"color: rgb(48, 128, 128); font-family=
: Consolas; font-size: 10pt; mso-fareast-font-family: &quot;Times New Roman=
&quot;;">=3D</span><span style=3D"color: rgb(0, 0, 32); font-family: Consol=
as; font-size: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;"=
> </span><span style=3D"color: rgb(0, 102, 238); font-family: Consolas; fon=
t-size: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;">std</s=
pan><span style=3D"color: rgb(64, 96, 128); font-family: Consolas; font-siz=
e: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;">::</span><s=
pan style=3D"color: rgb(0, 48, 96); font-family: Consolas; font-size: 10pt;=
 mso-fareast-font-family: &quot;Times New Roman&quot;;">make_unique</span><=
span style=3D"color: rgb(64, 96, 128); font-family: Consolas; font-size: 10=
pt; mso-fareast-font-family: &quot;Times New Roman&quot;;">&lt;</span><span=
 style=3D"color: rgb(0, 0, 32); font-family: Consolas; font-size: 10pt; mso=
-fareast-font-family: &quot;Times New Roman&quot;;">BigThing</span><span st=
yle=3D"color: rgb(64, 96, 128); font-family: Consolas; font-size: 10pt; mso=
-fareast-font-family: &quot;Times New Roman&quot;;">&gt;</span><span style=
=3D"color: rgb(48, 128, 128); font-family: Consolas; font-size: 10pt; mso-f=
areast-font-family: &quot;Times New Roman&quot;;">(</span><span style=3D"co=
lor: rgb(0, 102, 238); font-family: Consolas; font-size: 10pt; mso-fareast-=
font-family: &quot;Times New Roman&quot;;">std</span><span style=3D"color: =
rgb(64, 96, 128); font-family: Consolas; font-size: 10pt; mso-fareast-font-=
family: &quot;Times New Roman&quot;;">::</span><span style=3D"color: rgb(0,=
 48, 96); font-family: Consolas; font-size: 10pt; mso-fareast-font-family: =
&quot;Times New Roman&quot;;">must_move</span><span style=3D"color: rgb(48,=
 128, 128); font-family: Consolas; font-size: 10pt; mso-fareast-font-family=
: &quot;Times New Roman&quot;;">(</span><span style=3D"color: rgb(0, 0, 32)=
; font-family: Consolas; font-size: 10pt; mso-fareast-font-family: &quot;Ti=
mes New Roman&quot;;">part</span><span style=3D"color: rgb(48, 128, 128); f=
ont-family: Consolas; font-size: 10pt; mso-fareast-font-family: &quot;Times=
 New Roman&quot;;">))</span><span style=3D"color: rgb(64, 96, 128); font-fa=
mily: Consolas; font-size: 10pt; mso-fareast-font-family: &quot;Times New R=
oman&quot;;">;</span><span style=3D"color: rgb(89, 89, 121); font-family: C=
onsolas; font-size: 10pt; mso-fareast-font-family: &quot;Times New Roman&qu=
ot;;"><span style=3D"mso-spacerun: yes;">=C2=A0 </span>// relocate/move</sp=
an></p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"background: rgb(246, 248, 255); margin: 0in 0in 0pt; lin=
e-height: normal; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt =
320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732=
..8pt;"><span style=3D"color: rgb(0, 0, 32); font-family: Consolas; font-siz=
e: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;"><span style=
=3D"mso-spacerun: yes;">=C2=A0 </span><span style=3D"mso-spacerun: yes;">=
=C2=A0=C2=A0</span></span><b><span style=3D"color: rgb(32, 0, 128); font-fa=
mily: Consolas; font-size: 10pt; mso-fareast-font-family: &quot;Times New R=
oman&quot;;">return</span></b><span style=3D"color: rgb(0, 0, 32); font-fam=
ily: Consolas; font-size: 10pt; mso-fareast-font-family: &quot;Times New Ro=
man&quot;;"> thng</span><span style=3D"color: rgb(64, 96, 128); font-family=
: Consolas; font-size: 10pt; mso-fareast-font-family: &quot;Times New Roman=
&quot;;">;<span style=3D"mso-spacerun: yes;">=C2=A0 </span><span style=3D"m=
so-spacerun: yes;">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0</span></span><=
span style=3D"color: rgb(89, 89, 121); font-family: Consolas; font-size: 10=
pt; mso-fareast-font-family: &quot;Times New Roman&quot;;">// do not care i=
f copied</span></p><font color=3D"#000000" face=3D"Times New Roman" size=3D=
"3">

</font><p style=3D"background: rgb(246, 248, 255); margin: 0in 0in 0pt; lin=
e-height: normal; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt =
320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732=
..8pt;"><span style=3D"color: rgb(64, 96, 128); font-family: Consolas; font-=
size: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;"><span st=
yle=3D"mso-spacerun: yes;">=C2=A0 </span>}</span></p><font color=3D"#000000=
" face=3D"Times New Roman" size=3D"3">

</font><p style=3D"background: rgb(246, 248, 255); margin: 0in 0in 0pt; lin=
e-height: normal; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt =
320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732=
..8pt;"><span style=3D"color: rgb(0, 0, 32); font-family: Consolas; font-siz=
e: 10pt; mso-fareast-font-family: &quot;Times New Roman&quot;;">=C2=A0</spa=
n></p><font color=3D"#000000" face=3D"Times New Roman" size=3D"3">

</font></div><div><br></div><div>Comments welcome.</div><div><br></div><div=
><br></div><div>On Friday, April 8, 2016 at 4:30:52 PM UTC-6, isocp...@deni=
sbider.com wrote:</div><blockquote class=3D"gmail_quote" style=3D"margin: 0=
px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204);=
 border-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr"><div>O=
r, since we have this problem already when distinguishing between move and =
copy construction: how=C2=A0about=C2=A0a family of=C2=A0special blessed fun=
ctions, like this?</div><div><br></div><div><pre style=3D"background: rgb(2=
46, 248, 255); color: rgb(0, 0, 32);"><span style=3D"color: rgb(32, 0, 128)=
; font-weight: bold;">template</span> <span style=3D"color: rgb(64, 96, 128=
);">&lt;</span><span style=3D"color: rgb(32, 0, 128); font-weight: bold;">t=
ypename</span> T<span style=3D"color: rgb(64, 96, 128);">&gt;</span> T <spa=
n style=3D"color: rgb(32, 0, 128); font-weight: bold;">const</span><span st=
yle=3D"color: rgb(48, 128, 128);">&amp;</span> require_copy     <span style=
=3D"color: rgb(48, 128, 128);">(</span>T <span style=3D"color: rgb(32, 0, 1=
28); font-weight: bold;">const</span><span style=3D"color: rgb(48, 128, 128=
);">&amp;</span><span style=3D"color: rgb(48, 128, 128);">)</span><span sty=
le=3D"color: rgb(64, 96, 128);">;</span>
<span style=3D"color: rgb(32, 0, 128); font-weight: bold;">template</span> =
<span style=3D"color: rgb(64, 96, 128);">&lt;</span><span style=3D"color: r=
gb(32, 0, 128); font-weight: bold;">typename</span> T<span style=3D"color: =
rgb(64, 96, 128);">&gt;</span> T<span style=3D"color: rgb(48, 128, 128);">&=
amp;</span><span style=3D"color: rgb(48, 128, 128);">&amp;</span>      requ=
ire_move     <span style=3D"color: rgb(48, 128, 128);">(</span>T<span style=
=3D"color: rgb(48, 128, 128);">&amp;</span><span style=3D"color: rgb(48, 12=
8, 128);">)</span><span style=3D"color: rgb(64, 96, 128);">;</span>
<span style=3D"color: rgb(32, 0, 128); font-weight: bold;">template</span> =
<span style=3D"color: rgb(64, 96, 128);">&lt;</span><span style=3D"color: r=
gb(32, 0, 128); font-weight: bold;">typename</span> T<span style=3D"color: =
rgb(64, 96, 128);">&gt;</span> T<span style=3D"color: rgb(48, 128, 128);">&=
amp;</span>       require_relocate <span style=3D"color: rgb(48, 128, 128);=
">(</span>T<span style=3D"color: rgb(48, 128, 128);">&amp;</span><span styl=
e=3D"color: rgb(48, 128, 128);">)</span><span style=3D"color: rgb(64, 96, 1=
28);">;</span>

</pre></div><div><br></div><div>Each of these would require the compiler to=
 flag the returned reference, and perform a compile-time verification that =
the reference does in fact end up being passed to a copy constructor; move =
constructor; or relocator, respectively.</div><div><br></div><div>This woul=
d be useful even without relocate. It would allow code like this:</div><div=
><br></div><div><pre style=3D"background: rgb(246, 248, 255); color: rgb(0,=
 0, 32);">BigObj MakeBigObj<span style=3D"color: rgb(48, 128, 128);">(</spa=
n><span style=3D"color: rgb(48, 128, 128);">)</span> <span style=3D"color: =
rgb(64, 96, 128);">{</span>
  BigObj x<span style=3D"color: rgb(64, 96, 128);">;</span>
  x<span style=3D"color: rgb(48, 128, 128);">.</span>This<span style=3D"col=
or: rgb(48, 128, 128);">(</span><span style=3D"color: rgb(48, 128, 128);">)=
</span><span style=3D"color: rgb(64, 96, 128);">;</span>
  x<span style=3D"color: rgb(48, 128, 128);">.</span>That<span style=3D"col=
or: rgb(48, 128, 128);">(</span><span style=3D"color: rgb(48, 128, 128);">)=
</span><span style=3D"color: rgb(64, 96, 128);">;</span>
  <span style=3D"color: rgb(32, 0, 128); font-weight: bold;">return</span> =
<span style=3D"color: rgb(0, 102, 238);">std</span><span style=3D"color: rg=
b(64, 96, 128);">::</span>require_move<span style=3D"color: rgb(48, 128, 12=
8);">(</span>x<span style=3D"color: rgb(48, 128, 128);">)</span><span style=
=3D"color: rgb(64, 96, 128);">;</span>
<span style=3D"color: rgb(64, 96, 128);">}</span>

</pre></div><div><br></div><div>... to verify that what&#39;s happening is =
indeed move construction -=C2=A0not copy construction, by accident.<br></di=
v><div><br></div><div><br>On Friday, April 8, 2016 at 3:44:24 PM UTC-6, <a>=
isocp...@denisbider.com</a> wrote:</div><blockquote class=3D"gmail_quote" s=
tyle=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rg=
b(204, 204, 204); border-left-width: 1px; border-left-style: solid;"><div d=
ir=3D"ltr"><div>You are quite correct.=C2=A0This aspect is being implied, r=
ather than being addressed.</div><div><div>=C2=A0</div></div><div>I am toyi=
ng with the following text - currently rather informal:</div><blockquote><h=
2 style=3D"margin: 12pt 0in 0pt;"><font color=3D"#2e74b5" face=3D"Calibri L=
ight" size=3D"4">&quot;Move optimization</font></h2><font color=3D"#000000"=
 face=3D"Times New Roman" size=3D"3">

</font><p style=3D"margin: 8pt 0in; text-align: justify;"><font color=3D"#0=
00000" face=3D"Calibri" size=3D"3">When a type is relocatable; then
in situations where an implementation would otherwise move an object value =
to
an object of same type by invoking a move constructor, followed by destruct=
ion
of the moved-from object; and where no use of the moved-from object occurs =
between
move and destruction; the implementation may instead invoke the type=E2=80=
=99s relocator,
eliding the move constructor and destructor.</font></p><font color=3D"#0000=
00"><font face=3D"Times New Roman" size=3D"3">

</font><span style=3D"line-height: 107%; font-family: &quot;Calibri&quot;,s=
ans-serif; font-size: 11pt;">This move optimization <b>must</b> occur when =
move construction followed by destruction would otherwise
be used when returning a relocatable type by value from a function, into a =
new object
of same type.&quot;</span></font></blockquote><div>=C2=A0</div><div>This wo=
uld require relocation for return by value, if relocation is available and =
copy elision isn&#39;t. This would be similar to how move vs. copy construc=
tion is already chosen right now. </div><div><div>=C2=A0</div></div><div>It=
 would also open the door for a compiler to detect when an object is being =
moved to a new location, followed by destruction in the previous location.=
=C2=A0In this case, the compiler <em>could</em>=C2=A0use relocation (move d=
estruction), but is not forced to.</div><div><div>=C2=A0</div></div><div>An=
 open concern here is whether this would be, in practice, too subtle. For e=
xample, a developer might want to ensure that relocation is used, instead o=
f move construction + destruction:</div><div><div>=C2=A0</div></div><div><p=
re style=3D"background: rgb(246, 248, 255); color: rgb(0, 0, 32);"><span st=
yle=3D"color: rgb(89, 89, 121);"><pre style=3D"background: rgb(246, 248, 25=
5); color: rgb(0, 0, 32);"><span style=3D"color: rgb(0, 102, 238);">std</sp=
an><span style=3D"color: rgb(64, 96, 128);">::</span><span style=3D"color: =
rgb(0, 48, 96);">unique_ptr</span><span style=3D"color: rgb(64, 96, 128);">=
&lt;</span>Thing<span style=3D"color: rgb(64, 96, 128);">&gt;</span> MakeTh=
ing<span style=3D"color: rgb(48, 128, 128);">(</span><span style=3D"color: =
rgb(48, 128, 128);">)</span> <span style=3D"color: rgb(64, 96, 128);">{</sp=
an>
  <span style=3D"color: rgb(0, 102, 238);">std</span><span style=3D"color: =
rgb(64, 96, 128);">::</span><span style=3D"color: rgb(0, 48, 96);">list</sp=
an><span style=3D"color: rgb(64, 96, 128);">&lt;</span><span style=3D"color=
: rgb(32, 0, 128); font-weight: bold;">int</span><span style=3D"color: rgb(=
64, 96, 128);">&gt;</span> lst <span style=3D"color: rgb(48, 128, 128);">=
=3D</span> <span style=3D"color: rgb(48, 128, 128);">.</span><span style=3D=
"color: rgb(48, 128, 128);">.</span><span style=3D"color: rgb(48, 128, 128)=
;">.</span><span style=3D"color: rgb(64, 96, 128);">;</span>
  InitializeList<span style=3D"color: rgb(48, 128, 128);">(</span>lst<span =
style=3D"color: rgb(48, 128, 128);">)</span><span style=3D"color: rgb(64, 9=
6, 128);">;</span>
  <span style=3D"color: rgb(32, 0, 128); font-weight: bold;">return</span> =
<span style=3D"color: rgb(0, 102, 238);">std</span><span style=3D"color: rg=
b(64, 96, 128);">::</span>make_unique<span style=3D"color: rgb(64, 96, 128)=
;">&lt;</span>Thing<span style=3D"color: rgb(64, 96, 128);">&gt;</span><spa=
n style=3D"color: rgb(48, 128, 128);">(</span><span style=3D"color: rgb(0, =
102, 238);">std</span><span style=3D"color: rgb(64, 96, 128);">::</span><sp=
an style=3D"color: rgb(0, 48, 96);">m<wbr>ove</span><span style=3D"color: r=
gb(48, 128, 128);">(</span>lst<span style=3D"color: rgb(48, 128, 128);">)</=
span><span style=3D"color: rgb(48, 128, 128);">)</span><span style=3D"color=
: rgb(64, 96, 128);">;</span>
    <span style=3D"color: rgb(89, 89, 121);">// Is this copy construction, =
move construction, or relocation?</span>
<span style=3D"color: rgb(64, 96, 128);">}</span>

</pre></span></pre></div><div><div>=C2=A0</div></div><div>On the one hand, =
currently, we do not have syntax that the developer could use to ensure mov=
e construction is used,=C2=A0rather than=C2=A0copy construction. The develo=
per just has to use syntax that allows for move construction, and then coun=
t on that a move constructor is available.</div><div><div>=C2=A0</div></div=
><div>Suppose that we have relocation, and the compiler has determined to u=
se relocation in the above example.</div><div><div>=C2=A0</div></div><div>T=
hen, someone modifies=C2=A0the above=C2=A0function as follows:</div><div><d=
iv>=C2=A0</div></div><div><pre style=3D"background: rgb(246, 248, 255); col=
or: rgb(0, 0, 32);"><span style=3D"color: rgb(0, 102, 238);">std</span><spa=
n style=3D"color: rgb(64, 96, 128);">::</span><span style=3D"color: rgb(0, =
48, 96);">unique_ptr</span><span style=3D"color: rgb(64, 96, 128);">&lt;</s=
pan>Thing<span style=3D"color: rgb(64, 96, 128);">&gt;</span> MakeThing<spa=
n style=3D"color: rgb(48, 128, 128);">(</span><span style=3D"color: rgb(48,=
 128, 128);">)</span> <span style=3D"color: rgb(64, 96, 128);">{</span>
  <span style=3D"color: rgb(0, 102, 238);">std</span><span style=3D"color: =
rgb(64, 96, 128);">::</span><span style=3D"color: rgb(0, 48, 96);">list</sp=
an><span style=3D"color: rgb(64, 96, 128);">&lt;</span><span style=3D"color=
: rgb(32, 0, 128); font-weight: bold;">int</span><span style=3D"color: rgb(=
64, 96, 128);">&gt;</span> lst <span style=3D"color: rgb(48, 128, 128);">=
=3D</span> <span style=3D"color: rgb(48, 128, 128);">.</span><span style=3D=
"color: rgb(48, 128, 128);">.</span><span style=3D"color: rgb(48, 128, 128)=
;">.</span><span style=3D"color: rgb(64, 96, 128);">;</span>
  InitializeList<span style=3D"color: rgb(48, 128, 128);">(</span>lst<span =
style=3D"color: rgb(48, 128, 128);">)</span><span style=3D"color: rgb(64, 9=
6, 128);">;</span>
  <span style=3D"color: rgb(32, 0, 128); font-weight: bold;">auto</span> th=
ing <span style=3D"color: rgb(48, 128, 128);">=3D</span> <span style=3D"col=
or: rgb(0, 102, 238);">std</span><span style=3D"color: rgb(64, 96, 128);">:=
:</span>make_unique<span style=3D"color: rgb(64, 96, 128);">&lt;</span>Thin=
g<span style=3D"color: rgb(64, 96, 128);">&gt;</span><span style=3D"color: =
rgb(48, 128, 128);">(</span><span style=3D"color: rgb(0, 102, 238);">std</s=
pan><span style=3D"color: rgb(64, 96, 128);">::</span><span style=3D"color:=
 rgb(0, 48, 96);">m<wbr>ove</span><span style=3D"color: rgb(48, 128, 128);"=
>(</span>lst<span style=3D"color: rgb(48, 128, 128);">)</span><span style=
=3D"color: rgb(48, 128, 128);">)</span><span style=3D"color: rgb(64, 96, 12=
8);">;</span>
  ReuseListForOtherPurpose<span style=3D"color: rgb(48, 128, 128);">(</span=
>lst<span style=3D"color: rgb(48, 128, 128);">)</span><span style=3D"color:=
 rgb(64, 96, 128);">;</span>
  <span style=3D"color: rgb(32, 0, 128); font-weight: bold;">return</span> =
thing<span style=3D"color: rgb(64, 96, 128);">;</span>
<span style=3D"color: rgb(64, 96, 128);">}</span>

</pre></div><div><div>=C2=A0</div></div><div><div>Now, this definitely no l=
onger uses relocation,=C2=A0because <em>lst</em> is being=C2=A0used again.<=
/div><div><br></div><div>Is this a concern? How do we prevent this?</div><d=
iv><br></div><div>To avoid introducing a keyword, one way could be to add a=
 blessed standard library function, say <em>std::final_reference</em>: </di=
v><div><br></div><div><pre style=3D"background: rgb(246, 248, 255); color: =
rgb(0, 0, 32);"><span style=3D"color: rgb(0, 102, 238);">std</span><span st=
yle=3D"color: rgb(64, 96, 128);">::</span><span style=3D"color: rgb(0, 48, =
96);">unique_ptr</span><span style=3D"color: rgb(64, 96, 128);">&lt;</span>=
Thing<span style=3D"color: rgb(64, 96, 128);">&gt;</span> MakeThing<span st=
yle=3D"color: rgb(48, 128, 128);">(</span><span style=3D"color: rgb(48, 128=
, 128);">)</span> <span style=3D"color: rgb(64, 96, 128);">{</span>
  <span style=3D"color: rgb(0, 102, 238);">std</span><span style=3D"color: =
rgb(64, 96, 128);">::</span><span style=3D"color: rgb(0, 48, 96);">list</sp=
an><span style=3D"color: rgb(64, 96, 128);">&lt;</span><span style=3D"color=
: rgb(32, 0, 128); font-weight: bold;">int</span><span style=3D"color: rgb(=
64, 96, 128);">&gt;</span> lst <span style=3D"color: rgb(48, 128, 128);">=
=3D</span> <span style=3D"color: rgb(48, 128, 128);">.</span><span style=3D=
"color: rgb(48, 128, 128);">.</span><span style=3D"color: rgb(48, 128, 128)=
;">.</span><span style=3D"color: rgb(64, 96, 128);">;</span>
  InitializeList<span style=3D"color: rgb(48, 128, 128);">(</span>lst<span =
style=3D"color: rgb(48, 128, 128);">)</span><span style=3D"color: rgb(64, 9=
6, 128);">;</span>
  <span style=3D"color: rgb(32, 0, 128); font-weight: bold;">auto</span> th=
ing <span style=3D"color: rgb(48, 128, 128);">=3D</span> <span style=3D"col=
or: rgb(0, 102, 238);">std</span><span style=3D"color: rgb(64, 96, 128);">:=
:</span>make_unique<span style=3D"color: rgb(64, 96, 128);">&lt;</span>Thin=
g<span style=3D"color: rgb(64, 96, 128);">&gt;</span><span style=3D"color: =
rgb(48, 128, 128);">(</span><span style=3D"color: rgb(0, 102, 238);">std</s=
pan><span style=3D"color: rgb(64, 96, 128);">::</span>f<wbr>inal_reference<=
span style=3D"color: rgb(48, 128, 128);">(</span>lst<span style=3D"color: r=
gb(48, 128, 128);">)</span><span style=3D"color: rgb(48, 128, 128);">)</spa=
n><span style=3D"color: rgb(64, 96, 128);">;</span>
  ReuseListForOtherPurpose<span style=3D"color: rgb(48, 128, 128);">(</span=
>lst<span style=3D"color: rgb(48, 128, 128);">)</span><span style=3D"color:=
 rgb(64, 96, 128);">;</span>  <span style=3D"color: rgb(89, 89, 121);">// E=
rror: use of &quot;lst&quot; after final_reference</span>
  <span style=3D"color: rgb(32, 0, 128); font-weight: bold;">return</span> =
thing<span style=3D"color: rgb(64, 96, 128);">;</span>
<span style=3D"color: rgb(64, 96, 128);">}</span>

</pre></div><div><br></div></div><div><div>This would require a compiler to=
 detect the reuse of &quot;lst&quot; after it&#39;s used in=C2=A0<em>std::f=
inal_reference</em>, and flag an error when &quot;lst&quot; is reused.</div=
><div><br></div><div>An alternative to a blessed function would be a new ke=
yword, e.g. &quot;final_reference&quot;.</div><div><br></div><div>Thoughts?=
 Ideas?</div><div><br></div><div>=C2=A0</div></div><div><div>On Friday, Apr=
il 8, 2016 at 2:46:35 PM UTC-6, <a>barry....@gmail.com</a> wrote:</div></di=
v><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; pad=
ding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1=
px; border-left-style: solid;"><blockquote class=3D"gmail_quote" style=3D"m=
argin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 20=
4, 204); border-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr=
"><div>&gt; If your relocation support can&#39;t even perform relocation in=
 this most simple of cases:<div>=C2=A0</div></div><div><div>=C2=A0</div></d=
iv><div>How does it <em>not</em> handle that case? If std::list has a reloc=
ator, the compiler can just call the relocator in this case:</div><div><fon=
t color=3D"#666600"></font><div><font color=3D"#666600"></font>=C2=A0</div>=
</div><div><font color=3D"#666600"><pre style=3D"background: rgb(246, 248, =
255); color: rgb(0, 0, 32);">  <span style=3D"color: rgb(0, 102, 238);">std=
</span><span style=3D"color: rgb(64, 96, 128);">::</span><span style=3D"col=
or: rgb(0, 48, 96);">list</span><span style=3D"color: rgb(64, 96, 128);">&l=
t;</span>T<span style=3D"color: rgb(64, 96, 128);">&gt;</span> SomeFunc<spa=
n style=3D"color: rgb(48, 128, 128);">(</span><span style=3D"color: rgb(48,=
 128, 128);">)</span> <span style=3D"color: rgb(64, 96, 128);">{</span>
    <span style=3D"color: rgb(0, 102, 238);">std</span><span style=3D"color=
: rgb(64, 96, 128);">::</span><span style=3D"color: rgb(0, 48, 96);">list</=
span><span style=3D"color: rgb(64, 96, 128);">&lt;</span>T<span style=3D"co=
lor: rgb(64, 96, 128);">&gt;</span> lt <span style=3D"color: rgb(48, 128, 1=
28);">=3D</span> <span style=3D"color: rgb(48, 128, 128);">.</span><span st=
yle=3D"color: rgb(48, 128, 128);">.</span><span style=3D"color: rgb(48, 128=
, 128);">.</span>
    <span style=3D"color: rgb(48, 128, 128);">.</span><span style=3D"color:=
 rgb(48, 128, 128);">.</span><span style=3D"color: rgb(48, 128, 128);">.</s=
pan>
    <span style=3D"color: rgb(32, 0, 128); font-weight: bold;">return</span=
> lt<span style=3D"color: rgb(64, 96, 128);">;</span> <span style=3D"color:=
 rgb(89, 89, 121);">// no special syntax needed; compiler calls relocator &=
gt;&gt;list&lt;T&gt;</span>
  <span style=3D"color: rgb(64, 96, 128);">}</span>

</pre></font></div><div><div>=C2=A0</div></div><div>What prevents the compi=
ler from doing this?</div></div></blockquote><div><div>=C2=A0</div></div><d=
iv>As far as I can tell, your proposal doesn&#39;t say anything about this =
case, or about automatic objects at all. Your invocation section only addre=
sses the use-case of &quot;relocating&quot; one pointer to another.=C2=A0</=
div><div><div>=C2=A0</div></div><div>You should take advantage of the feedb=
ack opportunity to improve your proposal. There&#39;s no need to be so defe=
nsive.=C2=A0</div></blockquote></div></blockquote></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/82db5d5a-bad9-42ce-b1ad-66bcc0dd20b0%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/82db5d5a-bad9-42ce-b1ad-66bcc0dd20b0=
%40isocpp.org</a>.<br />

------=_Part_1140_479930691.1460174730296--
------=_Part_1139_1556648077.1460174730295--

.
