220 22535 <a728bfde-15ae-4c32-8424-034ff1c44207@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: leni536@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: std::vector (and other containers) to have a
 perfect forwarding constructor
Date: Wed, 11 Nov 2015 23:35:16 -0800 (PST)
Lines: 173
Approved: news@gmane.org
Message-ID: <a728bfde-15ae-4c32-8424-034ff1c44207@isocpp.org>
References: <14fb89ea-443b-4696-93ec-29889f642bca@isocpp.org>
 <CAGNvRgBEn=wGT0Z3Wq+Pq4eKXinwEgsO66eQS6bw8WoCrgqC1A@mail.gmail.com>
 <cf9b040c-5008-4f40-bd53-0bf898f95ac2@isocpp.org> <CAGNvRgCgeNDgcJXUWQtqpR=eF=uVZpmHpDsZwm0QHXDd6jxdGw@mail.gmail.com>
 <5cd9879e-a6e7-447f-8475-edc6b52d9716@isocpp.org>
 <CAGg_6+P8mZiJ2kr+AuwKeh2OOhyAkr0VHdwWqnXMUc56_zGO4Q@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_9378_1156900636.1447313716235"
X-Trace: ger.gmane.org 1447313724 31786 80.91.229.3 (12 Nov 2015 07:35:24 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 12 Nov 2015 07:35:24 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDXJR44QUQHBBNMCSGZAKGQEXRDU7SA@isocpp.org Thu Nov 12 08:35:23 2015
Return-path: <std-proposals+bncBDXJR44QUQHBBNMCSGZAKGQEXRDU7SA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pa0-f70.google.com ([209.85.220.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDXJR44QUQHBBNMCSGZAKGQEXRDU7SA@isocpp.org>)
	id 1ZwmPf-00043A-Ko
	for gclcip-std-proposals@m.gmane.org; Thu, 12 Nov 2015 08:35:19 +0100
Original-Received: by pabur2 with SMTP id ur2sf35980902pab.0
        for <gclcip-std-proposals@m.gmane.org>; Wed, 11 Nov 2015 23:35:18 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp_org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :content-type: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=Rd/KKjf7KeiUhEEqfxWj9UJzoKJgkzcSh85qAx0DmfA=;
        b=PUAlZ1mJvhpEryyyFt0OQP6TNwRgDSfLB5JzNnNIYyLftX2/j0DnAZ1tTgXNSkSByk
         YArwhRKRbxb6SKDhg8zVoTQlUe4C4LnJEz7TWJ7TtKBn3q2bWwSlFEPNyMGlEIadl+Rt
         XaoPFZYRNAWQPNSJfK20MA2moSNXqAsOtlo56hT6vAV2TgtVsT5W/h/bd+MVZWKmtB6I
         UIyRLOcxec0/Hl4eXtNVpPgjlWJmCIph0yajztvQaFvj1xDXDRqz5f/nFRBCYGSau9f4
         L+/cfoQx7gKed6hJzkQN+TmA3HGhXPtX9YBs/iKkoq1jWqGgpojUlqWerS/ZX966TNo4
         gXrg==
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
         :content-type: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=Rd/KKjf7KeiUhEEqfxWj9UJzoKJgkzcSh85qAx0DmfA=;
        b=NgVzCDy7BPY8GkQr4OlWBzFG36QqcI8333x7uPrpFkImASWAXUz99FoqrMi7Wg9qW2
         exX05pWVKXm3cnDtMfZmIC30iiH+CmK8sq3BMG31Vp2wcfrYoxmAxJmeRRBX2zmgm3qi
         s3AbRJcKcZuR9aXnxfJ0e9x5m0yskNdrj2gXhM4pZ1QesQn0R115USsmDiYtw1TtCXac
         d3DWzWwmxQcF/QVIT83Uv9RqVNmREhGgf9qm7M0wgXmTdU1LM7W00mu2MNj5BxMTcffk
         3mF+fO7kSOt8+0nbqvx47vWMGzqUCQfcVAA283X/1V5zYwM/7bV+YeQ/RXsti+tUl2OK
         GMRg==
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:content-type: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=Rd/KKjf7KeiUhEEqfxWj9UJzoKJgkzcSh85qAx0DmfA=;
        b=YTkitqQR3n52BhsLDsLNMkQRin3emqwvL6rCbFDUpC8g3k6kXWxrCy/ejN72egT13V
         ggkOAE1mWOZ9shVZ/A/Fa7qf3/zZ9PmjGfjE0+0mGeWp8MRrlmVA59bJuTPaNNuD/3F/
         nt4RmJtZ401zS1mWgZzeUFWfU245TQ00pDeKHgZrhbSA3TXRTDc6cI/guyf5/jtSxg/5
         kdKSIsYR0HQoiLF56AQtE6mSNoRh722kb3Hi5CsqvFaPRvxpndJhGj+fa9O7TVi9Eq0c
         lpOYrdnOFI+slFcyTwKeS5tpHOB/kgURopb9OptVCEF7IUCiAs63hoXUaUnzkrLi1cjG
         ybpQ==
X-Gm-Message-State: ALoCoQnMD+iv4t5LYZXiPb9DbE7tZEW4rwB0wPSK/2dzVe0Tn55MIYGf8UHTDIGFlCclRmEqVeBu
X-Received: by 10.68.196.169 with SMTP id in9mr5476253pbc.2.1447313718256;
        Wed, 11 Nov 2015 23:35:18 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.18.228 with SMTP id 97ls403276ios.75.gmail; Wed, 11 Nov
 2015 23:35:17 -0800 (PST)
X-Received: by 10.50.33.73 with SMTP id p9mr302820igi.4.1447313717370;
        Wed, 11 Nov 2015 23:35:17 -0800 (PST)
In-Reply-To: <CAGg_6+P8mZiJ2kr+AuwKeh2OOhyAkr0VHdwWqnXMUc56_zGO4Q@mail.gmail.com>
X-Original-Sender: leni536@gmail.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: <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: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:22535
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/22535>

------=_Part_9378_1156900636.1447313716235
Content-Type: multipart/alternative; 
	boundary="----=_Part_9379_710222595.1447313716236"

------=_Part_9379_710222595.1447313716236
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



On Wednesday, November 11, 2015 at 6:42:29 PM UTC+1, Nevin ":-)" Liber=20
wrote:
>
> On 11 November 2015 at 04:53, <len...@gmail.com <javascript:>> wrote:
>
>> Ok, this is my last try :).
>>
>> What if we use the first declaration:
>>
>> vector(size_type n,vector::forward_args_type,Args&&... args);
>>
>> But inside vector's constructor we convert every rvalue references in=20
>> args to const ref.
>>
>
> But then it is no longer perfect forwarding, is it?
>
=20
I agree.=20

Worse, the signature looks like it *should* do perfect forwarding.
>
=20
I'm not familiar with the conventions of modern C++. Is it already settled=
=20
that if you see a universal reference in a signature it should be moved or=
=20
perfect forwarded (so eventually moved)? AFAIK rvalue references are only=
=20
candidates for moving. Anyway this convention (if it exist) seems too=20
limiting. I only use a variadic universal reference because AFAIK it's the=
=20
only way to catch mixed const and non-const lvalue references and keep=20
their "constness" in a variadic parameter.


> For instance, if you have move-only parameters that get moved into the=20
> object being constructed, it looks like it ought to work even though it=
=20
> won't compile.  Take this example:
>
> unique_ptr<int> p;
> vector<unique_ptr<int>> v(1, forward_args_type(), std::move(p));
>
=20
Well not compiling is not that bad. Maybe a static assert is possible with=
=20
useful information.=20

=20
>
>> I'm getting a little bit lost here though, maybe this suggestion adds=20
>> even more problems than what it solves.
>>
>
> I think the idea was certainly worth exploring, but I'm leaning towards=
=20
> the same conclusion.
>
=20
I worry more about more convoluted corner cases. I think this case is not=
=20
that bad.

- L=C3=A9n=C3=A1rd

--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_9379_710222595.1447313716236
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br><br>On Wednesday, November 11, 2015 at 6:42:29 PM UTC+1, Nevin &quot;:-=
)&quot; Liber wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">On 11 November 2015 at 04:53,  <span dir=3D"ltr">&lt;<a href=3D"ja=
vascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"e5b7Sos7FwAJ" rel=3D"=
nofollow" onmousedown=3D"this.href=3D&#39;javascript:&#39;;return true;" on=
click=3D"this.href=3D&#39;javascript:&#39;;return true;">len...@gmail.com</=
a>&gt;</span> wrote:<br><div><div class=3D"gmail_quote"><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex"><div dir=3D"ltr">Ok, this is my last try :).<div><br></div><d=
iv>What if we use the first declaration:</div><div><br></div><div><div styl=
e=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;background-colo=
r:rgb(250,250,250)"><code><div><span style=3D"color:rgb(0,0,0)"><span style=
=3D"color:#000">vector</span></span><span style=3D"color:rgb(102,102,0)"><s=
pan style=3D"color:#660">(</span></span><span style=3D"color:rgb(0,0,0)"><s=
pan style=3D"color:#000">size_type n</span></span><span style=3D"color:rgb(=
102,102,0)"><span style=3D"color:#660">,</span></span><span style=3D"color:=
rgb(0,0,0)"><span style=3D"color:#000">vector</span></span><span style=3D"c=
olor:rgb(102,102,0)"><span style=3D"color:#660">::</span><span style=3D"col=
or:#000">forward_args</span></span><span style=3D"color:rgb(0,0,0)"><span s=
tyle=3D"color:#000">_type</span></span><span style=3D"color:rgb(102,102,0)"=
><span style=3D"color:#660">,</span></span><span style=3D"color:rgb(102,0,1=
02)"><span style=3D"color:#606">Ar<wbr>gs</span></span><span style=3D"color=
:rgb(102,102,0)"><span style=3D"color:#660">&amp;&amp;...</span></span><spa=
n style=3D"color:rgb(0,0,0)"><span style=3D"color:#000"> args</span></span>=
<span style=3D"color:rgb(102,102,0)"><span style=3D"color:#660">);</span></=
span><span style=3D"color:#000"><br></span></div></code></div><br>But insid=
e vector&#39;s constructor we convert every rvalue references in args to co=
nst ref.</div></div></blockquote><div><br></div><div>But then it is no long=
er perfect forwarding, is it?</div></div></div></div></blockquote><div>=C2=
=A0</div><div>I agree.=C2=A0</div><div><br></div><blockquote class=3D"gmail=
_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;p=
adding-left: 1ex;"><div dir=3D"ltr"><div><div class=3D"gmail_quote"><div>Wo=
rse, the signature looks like it <i>should</i> do perfect forwarding.</div>=
</div></div></div></blockquote><div>=C2=A0</div><div>I&#39;m not familiar w=
ith the conventions of modern C++. Is it already settled that if you see a =
universal reference in a signature it should be moved or perfect forwarded =
(so eventually moved)? AFAIK rvalue references are only candidates for movi=
ng. Anyway this convention (if it exist) seems too limiting. I only use a v=
ariadic universal reference because AFAIK it&#39;s the only way to catch mi=
xed const and non-const lvalue references and keep their &quot;constness&qu=
ot; in a variadic parameter.</div><div><br></div><blockquote class=3D"gmail=
_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;p=
adding-left: 1ex;"><div dir=3D"ltr"><div><div class=3D"gmail_quote"><div><b=
r></div><div>For instance, if you have move-only parameters that get moved =
into the object being constructed, it looks like it ought to work even thou=
gh it won&#39;t compile.=C2=A0 Take this example:</div><div><br></div><div>=
unique_ptr&lt;int&gt; p;</div><div>vector&lt;unique_ptr&lt;int&gt;&gt; v(1,=
 forward_args_type(), std::move(p));</div></div></div></div></blockquote><d=
iv>=C2=A0</div><div>Well not compiling is not that bad. Maybe a static asse=
rt is possible with useful information.=C2=A0</div><div><br></div><blockquo=
te class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left:=
 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><div class=3D"gma=
il_quote"><div>=C2=A0<br></div><blockquote class=3D"gmail_quote" style=3D"m=
argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"l=
tr"><div> I&#39;m getting a little bit lost here though, maybe this suggest=
ion adds even more problems than what it solves.</div></div></blockquote><d=
iv><br></div><div>I think the idea was certainly worth exploring, but I&#39=
;m leaning towards the same conclusion.</div></div></div></div></blockquote=
><div>=C2=A0</div><div>I worry more about more convoluted corner cases. I t=
hink this case is not that bad.</div><div><br></div><div>- L=C3=A9n=C3=A1rd=
</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_9379_710222595.1447313716236--
------=_Part_9378_1156900636.1447313716235--

.
