220 2762 <5095aadf-58c1-458b-bc9f-6bbd7499aa59@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: optional references -- take 2
Date: Wed, 6 Feb 2013 19:55:22 -0800 (PST)
Lines: 125
Approved: news@gmane.org
Message-ID: <5095aadf-58c1-458b-bc9f-6bbd7499aa59@isocpp.org>
References: <8d57e9e9-e4cc-441c-abeb-e6526531fad5@isocpp.org>
 <CAOHCbiuw0zezce9kcXVsEcE=mPmp=93zQHSRMzUcNw6u3TCsBQ@mail.gmail.com>
 <ca43f129-cd55-43d3-89fc-1e4402af0e9f@isocpp.org> <3534ECE0-D67E-443E-9593-76B644FDDF6A@gmail.com>
 <3aca8f41-7a21-40d8-9bf9-9c27dfa778f3@isocpp.org>
 <CAGg_6+PRK5Szu=51fPjx35aiC=MM07NYsZZnCS3c+0zdkv3qiQ@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_1536_7806428.1360209322599"
X-Trace: ger.gmane.org 1360209322 2912 80.91.229.3 (7 Feb 2013 03:55:22 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 7 Feb 2013 03:55:22 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBK6LZSEAKGQEJR2L67Q@isocpp.org Thu Feb 07 04:55:43 2013
Return-path: <std-proposals+bncBCEKFTV6ZUMBBK6LZSEAKGQEJR2L67Q@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vc0-f199.google.com ([209.85.220.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBK6LZSEAKGQEJR2L67Q@isocpp.org>)
	id 1U3IaM-0007Lg-Ph
	for gclcip-std-proposals@m.gmane.org; Thu, 07 Feb 2013 04:55:43 +0100
Original-Received: by mail-vc0-f199.google.com with SMTP id fo13sf2743760vcb.10
        for <gclcip-std-proposals@m.gmane.org>; Wed, 06 Feb 2013 19:55:23 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=x-received:x-beenthere:x-received: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=QWdWuSLoMrnl47s+q18MgvBTwAzP+Eq9YlWmFvdFxCI=;
        b=nsurvMACMrTKhXooHE0l/1B5EHRHI1MCiCPc4NIMMAgGpLT5u0CfLhyD7GK6DeIlau
         /LVIJQodcrvBkn6NUIifhrobZy/cfXNh5OtBaV6eJoBldBV1uYqUaMa3j1p89k/wyTh9
         XxUefXP3dqc7HXQKkJWXSoWTwaHIc8PvxWaGKKLWrjmlf2idmD1Ep0YA5jvFpa9W+dPJ
         Rj7i2veUz3LUAFZ5Uxf8xv9LPmW2YSsmS8LHNQoY3F+sVAVVFLPcl/wwprEec8BpDRIo
         5rzZ04kixEjGnCgpP8KwLwvZD/4UuvkZtabHG5VE913hFlqdU/JCulBF0U4hAIFNQ5kF
         HdXQ==
X-Received: by 10.236.147.234 with SMTP id t70mr14677445yhj.12.1360209323275;
        Wed, 06 Feb 2013 19:55:23 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.127.174 with SMTP id nh14ls630883qeb.28.gmail; Wed, 06 Feb
 2013 19:55:22 -0800 (PST)
X-Received: by 10.49.12.97 with SMTP id x1mr2703819qeb.25.1360209322903;
        Wed, 06 Feb 2013 19:55:22 -0800 (PST)
In-Reply-To: <CAGg_6+PRK5Szu=51fPjx35aiC=MM07NYsZZnCS3c+0zdkv3qiQ@mail.gmail.com>
X-Original-Sender: jmckesson@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?hl=en>,
 <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?hl=en&topic=25838>,
 <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:2762
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/2762>

------=_Part_1536_7806428.1360209322599
Content-Type: text/plain; charset=ISO-8859-1



On Wednesday, February 6, 2013 7:25:09 PM UTC-8, Nevin ":-)" Liber wrote:
>
> On 6 February 2013 20:40, Nicol Bolas <jmck...@gmail.com <javascript:>>wrote:
>
>> That's really the question I have about this whole `optional<T&>` thing: 
>> what exactly is the use case for this functionality that `T*` can't also 
>> cover?
>>
>
> How about optional<T&&>?
>

I would say that should be illegal. Consider:

T&& t1 = GetT();
T t2(t1); //Calls copy constructor.
T t3(std::move(t1)); //Explicit std::move required to cause move.

optional<T&&> ot1 = GetOptT();
T t2(*ot1); //Calls move constructor. No explicit std::move required.

Much language was expended in the C++11 standard to ensure that you *must*use an explicit std::move for anything that isn't a temporary or the return 
from a variable that's going out of scope. optional<T&&> breaks this, 
allowing movement without the explicit use of std::move.

optional<T&&>is dangerous.

-- 

--- 
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/?hl=en.



------=_Part_1536_7806428.1360209322599
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br><br>On Wednesday, February 6, 2013 7:25:09 PM UTC-8, Nevin ":-)" Liber =
wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8=
ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div class=3D"gmail_quot=
e">On 6 February 2013 20:40, Nicol Bolas <span dir=3D"ltr">&lt;<a href=3D"j=
avascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"1UjJtl3lfBYJ">jmck..=
..@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" styl=
e=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>That's really the question I have about this whole `optional&lt;T&amp;=
&gt;` thing: what exactly is the use case for this functionality that `T*` =
can't also cover?</div><div><div>

</div></div></blockquote></div><br>How about optional&lt;T&amp;&amp;&gt;?<b=
r></blockquote><div><br>I would say that should be illegal. Consider:<br><d=
iv class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); bor=
der-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; word=
-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprin=
t"><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>T</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">&amp;&amp;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> t1 </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
06;" class=3D"styled-by-prettify">GetT</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">();</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>T t2</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">t1</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">//Calls copy co=
nstructor.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>T t3</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 sty=
le=3D"color: #000;" class=3D"styled-by-prettify">move</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">t1</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">));</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-=
prettify">//Explicit std::move required to cause move.</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br><br>optional</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">&amp;&amp;&gt;</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> ot1 </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"st=
yled-by-prettify">GetOptT</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br>T t2</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">(*</span><span style=3D"color: #000;" class=3D"styled-by-prettify">ot=
1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #800;" class=3D"styled-by-prettify">//Calls move constructor. =
No explicit std::move required.</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br></span></div></code></div><br>Much language was ex=
pended in the C++11 standard to ensure that you <i>must</i> use an explicit=
 std::move for anything that isn't a temporary or the return from a variabl=
e that's going out of scope. optional&lt;T&amp;&amp;&gt; breaks this, allow=
ing movement without the explicit use of std::move.</div><br>optional&lt;T&=
amp;&amp;&gt;is dangerous.<br>

<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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_1536_7806428.1360209322599--

.
