220 34039 <38511f1a-5d75-4c95-a240-89e19a03bbe6@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: std::vector<T, Alloc>::expand_uninitialized
Date: Mon, 21 Aug 2017 18:46:26 -0700 (PDT)
Lines: 101
Approved: news@gmane.org
Message-ID: <38511f1a-5d75-4c95-a240-89e19a03bbe6@isocpp.org>
References: <405bc3a4-4fbf-41af-b213-b24894ba2f6e@isocpp.org> <0304ee31-d873-25a5-1ff9-3364e76dff67@gmail.com>
 <CAKiZDp151PprK6Q_Gajnyh0URotphRK98M154jjPQEjAUOkX4Q@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_7769_1398986133.1503366386239"
X-Trace: blaine.gmane.org 1503366400 29011 195.159.176.226 (22 Aug 2017 01:46:40 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 22 Aug 2017 01:46:40 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBB44Z53GAKGQEL477TJI@isocpp.org Tue Aug 22 03:46:33 2017
Return-path: <std-proposals+bncBCEKFTV6ZUMBB44Z53GAKGQEL477TJI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pg0-f70.google.com ([74.125.83.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBB44Z53GAKGQEL477TJI@isocpp.org>)
	id 1djyGs-0006T5-59
	for gclcip-std-proposals@m.gmane.org; Tue, 22 Aug 2017 03:46:22 +0200
Original-Received: by mail-pg0-f70.google.com with SMTP id q3sf96471620pgr.3
        for <gclcip-std-proposals@m.gmane.org>; Mon, 21 Aug 2017 18:46:28 -0700 (PDT)
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
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=7bnrZ21QjVJ40Uy8YU5IFHv+LRJQ8Z0BUIGW9Z/4bhw=;
        b=QOn4BhUR6D/07G1CbpCRuNCLUigjh/mGk8UeJJ0dY9fY+u3Ph9u8Hpk7/JSFgz1/PW
         HNZzK5fWGPTrOCSVawFUir2ibsrYBBJe2zDu/rYi3b4P3ZqFiP/BonpLID0mANgSjGUc
         x/o9nNLeo500+aCVJfLwoR0U0fv++ZCgskK9qylRCur3PMvTdpr/wJTd0G2BeBz0Hn4k
         u9CKocn8Y3pr9PgjwOBOLq05OMpA2e/owJZMu31fzPumfBZ1/MQtSD76pXekVjkU9L4o
         1APnsKGF4BtNqWfUAq06ZomEfT5haSsjPtBbbbXCEyLLTeKIryyNd/vLBLlBbB3ew6zG
         T0Tw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        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;
        bh=7bnrZ21QjVJ40Uy8YU5IFHv+LRJQ8Z0BUIGW9Z/4bhw=;
        b=ozjwZpdOpuV4Y3LQtBD0LA2avK7ucPYGOPTe6DTawoHC5QpUkbmRRktc78NJ5LPPhQ
         5QVRPzZcPCNOXo2q9t4krSImHU0qDBmPcPdNPLEj4/W7/OtiE1HMtnglVRn5j6e9i3mz
         w1BEpXrUAkMgKGSxbFa3Ve+kNI2RCbE516kXq0t1gbASdpsjIlLQ/u+0W6HjQ0YFwL7w
         5phfz0NRoBAHuN0UtVqDhvQg7nNaO+vWSPi8Tvfn8mohUTkp1GYMwvBevU6h34jjsOYQ
         ZCJSR3UYUkDqi9KFeGsrilyqj/7D3UiRBlWUL0NQ3Rt426epskzYj5EuPVeTFWT5BDeb
         bd3A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        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:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=7bnrZ21QjVJ40Uy8YU5IFHv+LRJQ8Z0BUIGW9Z/4bhw=;
        b=r68o/1Zp4shtuumYVM3hNwJvlLWkn1SBPDbpifqFeO8A/NUI77UYyofVzYNyaFu7Nm
         s20KJx+mbvT3iqZSajMtIuLB/1CfqySSQnJ6awfLYU5sq+ATKWJgYoyFIij7tr5//80b
         gEUqmGiJ+uLhMXy4AWJlzZrgQEr6aGPS3lEouER16UzK6m+xF5rvj+8N2z3RXMh10+y5
         dOUEj5pnSCsm9wmOE5teIkv7uvBzXiGUBKCfW+NtSEVNlpMDIFely//rvdpx6yBfJ+IJ
         flhStd0ZR/8uMOHqk+BhsE0fPkTIf6SJZdw4/Gfod0VFMW7SdFM6VP4/EFXW2BfcF8iv
         DQGw==
X-Gm-Message-State: AHYfb5gJzkrZSB3PIQPNq2gs/H2+Tk7o9z9U/8O/nmQ5YY3p/EYMVZTd
	9kYd0pVYA1u+Jm+L
X-Received: by 10.101.69.138 with SMTP id o10mr7547991pgq.63.1503366388280;
        Mon, 21 Aug 2017 18:46:28 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.36.116.211 with SMTP id o202ls1383582itc.12.canary-gmail; Mon,
 21 Aug 2017 18:46:26 -0700 (PDT)
X-Received: by 10.31.160.13 with SMTP id j13mr23379vke.25.1503366386820;
        Mon, 21 Aug 2017 18:46:26 -0700 (PDT)
In-Reply-To: <CAKiZDp151PprK6Q_Gajnyh0URotphRK98M154jjPQEjAUOkX4Q@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: <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:34039
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/34039>

------=_Part_7769_1398986133.1503366386239
Content-Type: multipart/alternative; 
	boundary="----=_Part_7770_1460825058.1503366386240"

------=_Part_7770_1460825058.1503366386240
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable



On Monday, August 21, 2017 at 9:19:46 PM UTC-4, Patrice Roy wrote:
>
> +1. Really looks like a reserve() use-case to me.
>
> 2017-08-21 4:29 GMT-04:00 Jonathan M=C3=BCller <jonathanm...@gmail.com=20
> <javascript:>>:
>
>> On 20.08.2017 22:22, Ryan Nicholl wrote:
>>
>>> My motivating example consists of a serialization routine. Ideally, the=
=20
>>> serialization routine would expand the vector uninitialized and then wr=
ite=20
>>> the data in. This can't be done however, because the resize function wr=
ites=20
>>> 0s to the data thanks to the default allocator's construct method.
>>>
>>
>> Could you clarify why reserve + push_back() doesn't work here?
>>
>
I expect it's the reason he stated: he wants to prevent the value=20
initialization of the object, since he's going to initialize it from the=20
serialization routine. He wants to avoid the double-initialization.

Again, that's a reason to allow default initialization, not to do what he=
=20
suggests.=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/38511f1a-5d75-4c95-a240-89e19a03bbe6%40isocpp.or=
g.

------=_Part_7770_1460825058.1503366386240
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Monday, August 21, 2017 at 9:19:46 PM UTC-4, Pa=
trice Roy wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"lt=
r">+1. Really looks like a reserve() use-case to me.<br></div><div><br><div=
 class=3D"gmail_quote">2017-08-21 4:29 GMT-04:00 Jonathan M=C3=BCller <span=
 dir=3D"ltr">&lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-m=
ailto=3D"6q72mOxdCwAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;jav=
ascript:&#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;re=
turn true;">jonathanm...@gmail.com</a><wbr>&gt;</span>:<br><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pad=
ding-left:1ex"><span>On 20.08.2017 22:22, Ryan Nicholl wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
My motivating example consists of a serialization routine. Ideally, the ser=
ialization routine would expand the vector uninitialized and then write the=
 data in. This can&#39;t be done however, because the resize function write=
s 0s to the data thanks to the default allocator&#39;s construct method.<br=
>
</blockquote>
<br></span>
Could you clarify why reserve + push_back() doesn&#39;t work here?<span></s=
pan><br></blockquote></div></div></blockquote><div><br>I expect it&#39;s th=
e reason he stated: he wants to prevent the value initialization of the obj=
ect, since he&#39;s going to initialize it from the serialization routine. =
He wants to avoid the double-initialization.<br><br>Again, that&#39;s a rea=
son to allow default initialization, not to do what he suggests. <br></div>=
</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/38511f1a-5d75-4c95-a240-89e19a03bbe6%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/38511f1a-5d75-4c95-a240-89e19a03bbe6=
%40isocpp.org</a>.<br />

------=_Part_7770_1460825058.1503366386240--

------=_Part_7769_1398986133.1503366386239--

.
