220 35138 <CAGg_6+MhHrsgMcAsqr_BiQu584PzypU+GMaRsPuo8XQ7V4RdoA@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Nevin Liber <nevin@eviloverlord.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Add .emplace() method to std::unique_ptr and
 std::shared_ptr like it is in std::optional.
Date: Mon, 30 Oct 2017 11:37:53 -0500
Lines: 87
Approved: news@gmane.org
Message-ID: <CAGg_6+MhHrsgMcAsqr_BiQu584PzypU+GMaRsPuo8XQ7V4RdoA@mail.gmail.com>
References: <58eb77f6-2c2d-4ec1-85f8-08dcfe25a23e@isocpp.org> <db8aed18-d3b3-4df6-8e15-15f8c50e4bed@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="089e082577e0fcdee3055cc6447c"
X-Trace: blaine.gmane.org 1509381526 2761 195.159.176.226 (30 Oct 2017 16:38:46 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 30 Oct 2017 16:38:46 +0000 (UTC)
To: "std-proposals@isocpp.org" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCE35H5S6IDBBC5L3XHQKGQEOEEOQMY@isocpp.org Mon Oct 30 17:38:38 2017
Return-path: <std-proposals+bncBCE35H5S6IDBBC5L3XHQKGQEOEEOQMY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vk0-f71.google.com ([209.85.213.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCE35H5S6IDBBC5L3XHQKGQEOEEOQMY@isocpp.org>)
	id 1e9D53-0007Th-B5
	for gclcip-std-proposals@m.gmane.org; Mon, 30 Oct 2017 17:38:29 +0100
Original-Received: by mail-vk0-f71.google.com with SMTP id k195sf6955821vke.7
        for <gclcip-std-proposals@m.gmane.org>; Mon, 30 Oct 2017 09:38:37 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1509381516; cv=pass;
        d=google.com; s=arc-20160816;
        b=mQ8uv8IBlB8HuJrhMcD7S9TRAE/6qI3+uk5Magct/R0+LnV9O9jT9XvFzaaEY8k+zY
         qzBfqBMhzNm6rQ9RmxLbsskQXgK2Q3xlEnLu/aycnMYvfiYthcsd6IVGrc93yT/jAChp
         H91MpObc45n8Y9K/kJFegoDOad5xVc4v1TAYFLpMJL0M2hCCO1LQ0b/siUpcBP/IXfD6
         Mnr9u7tCdhRMhQ1tu54ofoiIGzes8jdRK8rleskrqbq52WtQNdfQ99HaD+lTvw7RNh+d
         QcvzGNjuu+1W161H/6s6J1PpJ8THLR+7EAAwuhx4lNJpehykKRDLCaqATNhgNVi2np9e
         jFyg==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:references:in-reply-to:sender:mime-version
         :arc-authentication-results:arc-message-signature
         :arc-authentication-results;
        bh=PnCTJzYcDmYnK356QqIOmXTbYY8HK5FPB/2gRB0eqeQ=;
        b=T8TkA2QajD+3CsvpX+U84XDeGKy1X48Zyb1URL8Os7GbM21nccS2qfWgFM/9G/Vde9
         BtL0YhWmJ/2C2Kqo76Cy8jpvtw/yUVfrJxjUWlzJvyxEKGAuz5qeiJM63oA0ReU0eCkZ
         ft/9YFD4GDKkryicw32VSUdQ+I2wMhleo2y7pdVfhd0+nXEFXiY7jpXtAkxShHbAyIM5
         cCtLC3NXvr6ybl/rnh2E0vTEI0JS3SDdcEyeHeHiHPvKd63ZkDK21lcEZAqcLKG3Jtmx
         OAaOCHGlfmgZCSs99fG3eA9idDEC+2RRO/pNGWmf2d2sowkO+Wn2qTRJSEoFMKw/flpa
         3nag==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=Fp5FasXD;
       spf=pass (google.com: domain of nliber@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=nliber@gmail.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:sender:in-reply-to:references:from
         :date:message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=PnCTJzYcDmYnK356QqIOmXTbYY8HK5FPB/2gRB0eqeQ=;
        b=c0ngF3li9Bg0bFCjoGnB8Qxf6WfbDtd5vqIfTlrXZmQdCMiwkBMwKGLC2Q3wM8IFi1
         S/0oFQAmGO+ONZykeMfVpkaUHSQJ3u0gWHtvISmUUdS+gKdBl6Xa2qYYjx87HBKn2C3j
         5ffbw24nwUFqgkaaw3rizLskSrXLUQftXN8MJ21H1U6Yqi9dbqJZoMjhsFVSXTh4Ql0i
         A+j7yIII6DKU7xMpODT7yIqY8dJJwglgmskK5K+8Bo+zo+y2tNB2+LxQsdLuYAHqa8sy
         obyNZ5627aneBCBOGdMVtCmRkoPWNWHD+3HhI7Lvj+0Y+yxUrGsg58jqscDHpDD3yNhz
         pMxQ==
X-Gm-Message-State: AMCzsaU25sVkMNzuyCo5vO3LbSIa8ta08Bla6tW/Gf7KNkArnlq+C4ZX
	lZY2D5uB4ZvvvWDxT/70Ou4=
X-Google-Smtp-Source: ABhQp+QAy+BFukwyUwTgs9jZSoBcTq8G9V2rtbidafmnnDaj+pK0rbw3UuKdDkIrZYc8vZ8SA2i8sA==
X-Received: by 10.176.82.245 with SMTP id w50mr10940230uaw.102.1509381516526;
        Mon, 30 Oct 2017 09:38:36 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.176.75.129 with SMTP id v1ls4228875uaf.18.gmail; Mon, 30 Oct
 2017 09:38:35 -0700 (PDT)
X-Received: by 10.176.89.205 with SMTP id k13mr8155430uad.5.1509381514996;
        Mon, 30 Oct 2017 09:38:34 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1509381514; cv=none;
        d=google.com; s=arc-20160816;
        b=g1VSZm4cg2f46KVlmcqQcsDgsPhMJAzcccGfMsR74qV0T8JUiCkRQtOo6rGsltCSK2
         R92zacYV23U3xRbUP71XCFJwCx8ij4N99/bi6AmCZU6LBqnpoyWjm5WJABODXTblo60a
         SqwnJKFzJDtlNsvvPkbbb7tjSprzvhKEgpeEfDfnvvJbrwnquL11l1AKGPtrBj0fCuvX
         3M0GrPB3T/Y6GosSAET4YBX06ZnDKefE5o8SPhZRBg27Via43Jylw3WXgPZwqfL+NKTG
         ZSb+Vic7fXY+NHHyiLiQDQWlyS7vzFpzmZL2GwBLsd36Bl0foDN9TuHaNT0W8NlRUM/5
         SqPQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:references:in-reply-to:sender
         :mime-version:dkim-signature:arc-authentication-results;
        bh=h+5OdNBqLIJX3tV3jnBHd6YZ/oT5BwlYU0wHkCstTeY=;
        b=fg/kwG/5yOVK82VV45QeIFaLqw0X3jPVXqEiFU3Q/zXB3zn7RAou+DW2vLmJE1u+VP
         aSCRAc4xAVN3mPILtP3cIrgjs3ymz/uxLa6vdeUeRDW9xjcoVWftsB2QqPsLTSKRm6KX
         tX5MUojJ0tQJTy/e8ErBI3FHTa1e+V69j/a9ntTwC9c6nYC05ZtHBJoMaE9TfYcTTVNM
         WbmARGaZQL2sfFIDgsh8fZKpBeReZvnnznG7CYbnKoin9tKuVFlJauoBNKlhnsp8bfjJ
         jzL1UELwqxmHU2faQFsMZ7UO08tetf5vzo3ZpvMORUC08z2Cq+qua2/G1x6NWADVALmI
         BMwA==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=Fp5FasXD;
       spf=pass (google.com: domain of nliber@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=nliber@gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id l10sor6125412uab.289.2017.10.30.09.38.34
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Mon, 30 Oct 2017 09:38:34 -0700 (PDT)
Received-SPF: pass (google.com: domain of nliber@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 10.176.13.153 with SMTP id i25mr1634534uak.139.1509381514253;
 Mon, 30 Oct 2017 09:38:34 -0700 (PDT)
Original-Sender: nliber@gmail.com
Original-Received: by 10.103.71.140 with HTTP; Mon, 30 Oct 2017 09:37:53 -0700 (PDT)
In-Reply-To: <db8aed18-d3b3-4df6-8e15-15f8c50e4bed@isocpp.org>
X-Original-Sender: nevin@eviloverlord.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=Fp5FasXD;       spf=pass
 (google.com: domain of nliber@gmail.com designates 209.85.220.41 as permitted
 sender) smtp.mailfrom=nliber@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:35138
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/35138>

--089e082577e0fcdee3055cc6447c
Content-Type: text/plain; charset="UTF-8"

On Mon, Oct 30, 2017 at 11:05 AM, <antanubis@gmail.com> wrote:

> void(?) unique_ptr<T>::emplace(Args &&... args) { *this =
>> make_unique<T>(std::forward<Args>(args)...); }
>> void(?) shared_ptr<T>::emplace(Args &&... args) { *this =
>> make_shared<T>(std::forward<Args>(args)...); }
>>
>
Thoughts:

   - Neither shared_ptr nor unique_ptr store an allocator, so
   shared_ptr::emplace and unique_ptr::emplace are being tied to a particular
   allocation scheme.  This makes it harder when people refactor code to use
   other allocation schemes.
   - unique_ptr has a deleter, which may not go along with emplace calling
   "new".  Will this function still exist if default_delete<T> isn't being
   used?
   - Unless you templatize it, emplace will not work for polymorphic types,
   which IMO is one of the major use cases for unique_ptr (and a less major
   one for shared_ptr).

Note:  I'm not saying these are reasons I would vote against such a
proposal; rather, these are things which need to be discussed in the
proposal.
-- 
 Nevin ":-)" Liber  <mailto:nevin@eviloverlord.com>  +1-847-691-1404

-- 
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGg_6%2BMhHrsgMcAsqr_BiQu584PzypU%2BGMaRsPuo8XQ7V4RdoA%40mail.gmail.com.

--089e082577e0fcdee3055cc6447c
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Mon, Oct 30, 2017 at 11:05 AM,  <span dir=3D"ltr">&lt;<=
a href=3D"mailto:antanubis@gmail.com" target=3D"_blank">antanubis@gmail.com=
</a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div class=3D"gmail_qu=
ote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-le=
ft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span class=3D""><bloc=
kquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-lef=
t:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>void(?) unique_ptr=
&lt;T&gt;::emplace(Args &amp;&amp;... args) { *this =3D make_unique&lt;T&gt=
;(std::forward&lt;Ar<wbr>gs&gt;(args)...); }</div><div>void(?) shared_ptr&l=
t;T&gt;::emplace(Args &amp;&amp;... args) { *this =3D make_shared&lt;T&gt;(=
std::forward&lt;Ar<wbr>gs&gt;(args)...); }</div></div></blockquote></span><=
/div></blockquote><div><br></div><div>Thoughts:</div><div><ul><li>Neither s=
hared_ptr nor unique_ptr store an allocator, so shared_ptr::emplace and uni=
que_ptr::emplace are being tied to a particular allocation scheme.=C2=A0 Th=
is makes it harder when people refactor code to use other allocation scheme=
s.</li><li>unique_ptr has a deleter, which may not go along with emplace ca=
lling &quot;new&quot;.=C2=A0 Will this function still exist if default_dele=
te&lt;T&gt; isn&#39;t being used?<br></li><li>Unless you templatize it, emp=
lace will not work for polymorphic types, which IMO is one of the major use=
 cases for unique_ptr (and a less major one for shared_ptr).</li></ul><div>=
Note: =C2=A0I&#39;m not saying these are reasons I would vote against such =
a proposal; rather, these are things which need to be discussed in the prop=
osal.</div></div></div>-- <br><div class=3D"gmail_signature" data-smartmail=
=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><div>=C2=A0Nevi=
n &quot;:-)&quot; Liber=C2=A0 &lt;mailto:<a href=3D"mailto:nevin@eviloverlo=
rd.com" target=3D"_blank">nevin@eviloverlord.com</a>&gt; =C2=A0+1-847-691-1=
404</div></div></div></div></div>
</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/CAGg_6%2BMhHrsgMcAsqr_BiQu584PzypU%2B=
GMaRsPuo8XQ7V4RdoA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGg_6%2BMhHr=
sgMcAsqr_BiQu584PzypU%2BGMaRsPuo8XQ7V4RdoA%40mail.gmail.com</a>.<br />

--089e082577e0fcdee3055cc6447c--

.
