220 11753 <dafa9468-d341-4742-9c15-54b25cae3b6f@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: tomaszkam@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: N4078: Rvalue reference overloads for value()
 method returns object by value
Date: Wed, 9 Jul 2014 12:51:24 -0700 (PDT)
Lines: 92
Approved: news@gmane.org
Message-ID: <dafa9468-d341-4742-9c15-54b25cae3b6f@isocpp.org>
References: <b538efba-faf4-4ffc-a553-302b9d2ba2c0@isocpp.org>
 <CANh-dX=M7niArNp-1sCcqxaREEJSxmjMftgw7uMHN9YnZC-h+w@mail.gmail.com> <CAFk2RUYVE=vq=DnYvZRRQh5Cgf5dFuxXi9H-3q-QgRJ0jMRpeQ@mail.gmail.com>
 <CANh-dXnBzUouc2ZAVtKco0P2ueFPvvA2uwx03Zu=trvA6vWwWg@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_490_4862776.1404935484685"
X-Trace: ger.gmane.org 1404935495 14245 80.91.229.3 (9 Jul 2014 19:51:35 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 9 Jul 2014 19:51:35 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDNPVXXG6IGBBPV262OQKGQEROLGAFA@isocpp.org Wed Jul 09 21:51:28 2014
Return-path: <std-proposals+bncBDNPVXXG6IGBBPV262OQKGQEROLGAFA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oa0-f72.google.com ([209.85.219.72])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDNPVXXG6IGBBPV262OQKGQEROLGAFA@isocpp.org>)
	id 1X4xtn-0004yW-Kr
	for gclcip-std-proposals@m.gmane.org; Wed, 09 Jul 2014 21:51:27 +0200
Original-Received: by mail-oa0-f72.google.com with SMTP id l6sf3572980oag.11
        for <gclcip-std-proposals@m.gmane.org>; Wed, 09 Jul 2014 12:51:26 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=vdISjUtaq/D6MIaHtYM7i7DYAeap3RXGb+6Yw1PUquI=;
        b=Q3EQBjkR24JrXuGc7OLi8pWMq+wR9S8zhrHu9c8ZM0SL3527UJ2coh1gednwuIrace
         BLB2ySZJeIXld9BL3ToZLDgZ2OPZrxEA7hGnBIpNue5b6Lle7oUvmDnAhD3U914RAm0G
         KHiuH6d4z39QMuAt26MxplJ36a9WLo43xuN6dcUO56zEpjW6s5/vuP5YrZNFcQBOOLml
         ZHOqr1VTmc3egPksE5k9diohdQ5bmjmEtGyIl+XVfVOKrG0ck/U5Tl+Slx+apTXTqzMv
         7deTfO9wA3ixeYwp9NIUrsgqqNI90Fd0/S49tuCq/i6hkXUwVVPXOubspishM9XAYWA7
         BVpg==
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:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=vdISjUtaq/D6MIaHtYM7i7DYAeap3RXGb+6Yw1PUquI=;
        b=KOEYxR8fxS7lw/86NGxUM+x4eIPDhEa4EfI6ya2n2E4igYnBKo2nngxYXuWld5sckw
         1kY0vGu2lqWrY0jD6LAT+Dd2QNP+DXyf6qOvv7futOYb0zkNdvCXBa2gYl2JOC/zhN8k
         XFApNHBit3wT19RPOnAYA2MgY4MK+9z6PxQMuIVCB+D4pDdWk/lj0JJ/BKTWL3mAsLXN
         KT55wKPxT4P2dXD1CaTvQsMex2GcU0JTXOPHebCF8pXqqFYVkCZqcbOdBrySpGFomW7L
         GIQ75AcbGtoUAFaTAotw33MU/VNzcCrhboRKuqe5XaRMF3COJHx3kR8CQkSdfAkUxx4v
         ocZQ==
X-Gm-Message-State: ALoCoQmSgJIEKARgT13wghjNDXRPnAHAlYaDrc77MNvbMEZcf3X44sXGBBfNUzxFxeJnAMA32hZX
X-Received: by 10.182.130.169 with SMTP id of9mr22217303obb.27.1404935486742;
        Wed, 09 Jul 2014 12:51:26 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.42.195 with SMTP id q3ls1331509obl.97.gmail; Wed, 09 Jul
 2014 12:51:25 -0700 (PDT)
X-Received: by 10.182.24.1 with SMTP id q1mr725obf.42.1404935485903;
        Wed, 09 Jul 2014 12:51:25 -0700 (PDT)
In-Reply-To: <CANh-dXnBzUouc2ZAVtKco0P2ueFPvvA2uwx03Zu=trvA6vWwWg@mail.gmail.com>
X-Original-Sender: tomaszkam@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:11753
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/11753>

------=_Part_490_4862776.1404935484685
Content-Type: text/plain; charset=UTF-8

After some thinking of the idea, I am not sure why it was choosen to 
introduce a additional construction of the temporary to the .value() method 
of the optional, even if we want to just:
 a) read the value passing opt.value() to function that takes the value 
type by contt reference:
      optional<T> g();
      std::cout << g.value() << std::endl;
 * Ville I would like you to add this to the gut report, because 
constructing a temporary to simply print a value may be overkill especially 
if used in generic context with forward:*
  template<typename Nullable> //optional, smart_ptr
  void (Nullable&& nullable)
  {
     //do something
     f(*std::forward<Nullable>(nullable)); //does it make a temporary here, 
or not??
  }
  b) construct another value from it:
      optional<T> g();
      auto opt = g();
To make the following code to work correclty:
     auto&& opt = g().value();
When it may be fixed by writing:
     auto opt = g().value();
and this will still invoke the same amount of construcotr as the above one, 
because:
    auto&& opt = g().value(); is construction T from T&& and binding it to 
reference
    auto opt = g(); is constructing T from T&& on stack

I start to think if the this auto&& everywhere recommendation that seems to 
pop up form time to time is actually a good design guide.
   

-- 

--- 
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_490_4862776.1404935484685
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">After some thinking of the idea, I am not sure why it was =
choosen to introduce a additional construction of the temporary to the .val=
ue() method of the optional, even if we want to just:<br>&nbsp;a) read the =
value passing opt.value() to function that takes the value type by contt re=
ference:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; optional&lt;T&gt; g();<br>&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; g.value() &lt;&lt; std::endl;<b=
r>&nbsp;<b> Ville I would like you to add this to the gut report, because c=
onstructing a temporary to simply print a value may be overkill especially =
if used in generic context with forward:</b><br>&nbsp; template&lt;typename=
 Nullable&gt; //optional, smart_ptr<br>&nbsp; void (Nullable&amp;&amp; null=
able)<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp; //do something<br>&nbsp;&nbsp=
;&nbsp;&nbsp; f(*std::forward&lt;Nullable&gt;(nullable)); //does it make a =
temporary here, or not??<br>&nbsp; }<br>&nbsp; b) construct another value f=
rom it:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; optional&lt;T&gt; g();<br>&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp; auto opt =3D g();<br>To make the following code to =
work correclty:<br>&nbsp;&nbsp;&nbsp;&nbsp; auto&amp;&amp; opt =3D g().valu=
e();<br>When it may be fixed by writing:<br>&nbsp;&nbsp;&nbsp;&nbsp; auto o=
pt =3D g().value();<br>and this will still invoke the same amount of constr=
ucotr as the above one, because:<br>&nbsp;&nbsp;&nbsp; auto&amp;&amp; opt =
=3D g().value(); is construction T from T&amp;&amp; and binding it to refer=
ence<br>&nbsp;&nbsp;&nbsp; auto opt =3D g(); is constructing T from T&amp;&=
amp; on stack<br><br>I start to think if the this auto&amp;&amp; everywhere=
 recommendation that seems to pop up form time to time is actually a good d=
esign guide.<br>&nbsp;&nbsp; <br></div>

<p></p>

-- <br />
<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 <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 />
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 />

------=_Part_490_4862776.1404935484685--

.
