220 35148 <ebeab15d-5424-034b-7d86-b84b381a1977@gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: =?UTF-8?Q?Jonathan_M=c3=bcller?= <jonathanmueller.dev@gmail.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 19:36:55 +0100
Lines: 56
Approved: news@gmane.org
Message-ID: <ebeab15d-5424-034b-7d86-b84b381a1977@gmail.com>
References: <58eb77f6-2c2d-4ec1-85f8-08dcfe25a23e@isocpp.org>
 <db8aed18-d3b3-4df6-8e15-15f8c50e4bed@isocpp.org>
 <CAGg_6+MhHrsgMcAsqr_BiQu584PzypU+GMaRsPuo8XQ7V4RdoA@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"; format=flowed
Content-Transfer-Encoding: quoted-printable
X-Trace: blaine.gmane.org 1509388623 11486 195.159.176.226 (30 Oct 2017 18:37:03 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 30 Oct 2017 18:37:03 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.4.0
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCUMHC4Z6QGBBSPC3XHQKGQEXW35GNI@isocpp.org Mon Oct 30 19:36:58 2017
Return-path: <std-proposals+bncBCUMHC4Z6QGBBSPC3XHQKGQEXW35GNI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wm0-f71.google.com ([74.125.82.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCUMHC4Z6QGBBSPC3XHQKGQEXW35GNI@isocpp.org>)
	id 1e9Evb-0001qi-8K
	for gclcip-std-proposals@m.gmane.org; Mon, 30 Oct 2017 19:36:51 +0100
Original-Received: by mail-wm0-f71.google.com with SMTP id n8sf6570892wmg.4
        for <gclcip-std-proposals@m.gmane.org>; Mon, 30 Oct 2017 11:36:59 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1509388618; cv=pass;
        d=google.com; s=arc-20160816;
        b=CSltehVmx4+35sofGqlkClooylnDx906loRK6foDRgr+ey9Ppkm0gl/Hzo/YXPYfIx
         V8v+lPYNlgvR6w8eAlISO30Rkh2rI7lM5/FS3vARUxBX40qxW9OcofCqOaY2C81vZLgs
         42bLpA1GuuNKBuwx/6Uac7mLPo8qsSkjWVxFDaAi7IK/ZwJJoqd3r0fJjU8HDM/3oKsU
         v8gJFsCT7OQcaHsL7kx4b+4VEBSNB+zT807FKlrfEywENrmyK//HhoqMeBWJLrnCCiPX
         M6L/N3XJ74NGOxGbuXoJwmmjjxqeGAyS4Op1eFo31pgAtRGT3pGjBJwVdGb0patx9Mp2
         MjHg==
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:content-transfer-encoding
         :content-language:in-reply-to:mime-version:user-agent:date
         :message-id:from:references:to:subject:arc-authentication-results
         :arc-message-signature:dkim-signature:arc-authentication-results;
        bh=5OqBbc+ORb3rWHANCMkieFDEpdseZe0TMC5jNNMqspg=;
        b=vUNltF29RC5eLx6HRPMGsD8HaTz97ZisQXoPbmSSWizu5VedU5gBeqUZK2qOhJQ8C0
         t/uqX/GHKGFA8UCClDCa3xRqWrs8oEPCunmIw9tBgaoJJyLph68A3rwK5y5ZqjJOAyjD
         HAONnAae577C7T0Cs/nktBXv044MCQNwJETemplxDrx7YppskeS0jI2Wy80Lp5YplqDt
         EEeDHelIcuInqU4su5g2joyeMV28WGSIJYYRFUDpaHrp6xU8nd3t/HUJHyiUiYjshId6
         uEUr//1sd5kPq2KRcAV7O19k0e8k7TQk4iyVAVRYVOzh2o0HxAjhDDU2FmHra0 
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=vbYq2cC5;
       spf=pass (google.com: domain of jonathanmueller.dev@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jonathanmueller.dev@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=subject:to:references:from:message-id:date:user-agent:mime-version
         :in-reply-to:content-language:content-transfer-encoding
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=5OqBbc+ORb3rWHANCMkieFDEpdseZe0TMC5jNNMqspg=;
        b=bkyxT1inVrUeA811VMSQvH9pyd3Nu5J/9U5WhDOd4yPqB/8JXcLCy0xT2eBf6rMhq7
         ioCF4M23aZW9cSoKOdTERtAkHFVYaIfdJDIogmzZ8rUdWxQ63REYiiBDgQ8E1XB39XR+
         shswaOWfi2MP5SmNnhzLbdmXAkZA1GK3e5yyoHDNf0+A2P82yhsVAgzgwin7kJtM4EQs
         7iR2y0k/538rUHUwoDh0n9oV5K9HD/elSZkSB5Vhvre/z2qUYpFTdGX+YEn700UH9vAj
         CfS5F13wlhpB52L28nPtuxVvO5vggkiQvVLEOQRga6T1vfhTOhLvawUi7gmFE6Jze8nn
         M3D 
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:subject:to:references:from:message-id:date
         :user-agent:mime-version:in-reply-to:content-language
         :content-transfer-encoding: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=5OqBbc+ORb3rWHANCMkieFDEpdseZe0TMC5jNNMqspg=;
        b=GLywLgS41LhjpBLZ6XEfDqZqiMLwbXDoZbTLIbf7Hfuba3oN24TtjKn42VqqC+xLFC
         asSsvAsKh/zY3ehvkNxFQdyuy3TJCsWIwRDgYhwbjX8FtLmtPiN6UQFccvVUcXImjVWR
         el6w6vU6eYKZQylvxL0adAVw03xKkARrWpmi688b4qD6Vtm45qMMUFQIMKf7oD4AQLEN
         I1/gNNiwFt4pNHbyyUajwZYdofcEXFERj2Pp0eZCRRBs3QPVJJ+99y+VEiA4VQcoRnBV
         oRjKxrZKs1ExxJly74KFzy33+gBJaOEgYT/ELgcxZJ/ 
X-Gm-Message-State: AMCzsaX60c+Yex68tmKflQfD0hrQ9/noVvFQwfIABhU0HlmjIxhNHRKg
	CR/Cwz0YYHupz5nZtsmS9CcpHw==
X-Google-Smtp-Source: ABhQp+Rr3x1DyQt2HlNGZgWNYniDdTCMEf23nMBC2I7NhHtk1in3YMN63/jQmz7Xj2F8GCrMuft95A==
X-Received: by 10.80.163.214 with SMTP id t22mr7525401edb.12.1509388618804;
        Mon, 30 Oct 2017 11:36:58 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.80.240.143 with SMTP id v15ls5861482edl.4.gmail; Mon, 30 Oct
 2017 11:36:57 -0700 (PDT)
X-Received: by 10.80.242.154 with SMTP id f26mr13466624edm.6.1509388617664;
        Mon, 30 Oct 2017 11:36:57 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1509388617; cv=none;
        d=google.com; s=arc-20160816;
        b=mlvJM/eYcRfU5RX2K4m+NnV2+Ne3k01Dqhi61DEz9Fj/Gd054mhz7DmV7avLCQtStK
         vt5qw8RSRsIXwVqi+m5yk2c5SuVOHG46p3qjspFIhQfvsfNJww9lr4RXTCerWMsIXQVL
         cbYQ4Dtf8Iapcbzo7cWD/LOZwHkhOiITurSY0ETbqEiGruoTfHHOMC/xiNMsqFWUO+gN
         brZmWQrep9C1RhZTo27lWip126Kerl3P7AOi9YTuHZAt/4neFhO446g4Mu5jx+QaxlGZ
         F2+ZUF21ihaaUW9NBNU7quLgsNP0HykZUxY7srqS0b3TeviUANEUdRtz34fGvsxZczWg
         //SQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:content-language:in-reply-to:mime-version
         :user-agent:date:message-id:from:references:to:subject
         :dkim-signature:arc-authentication-results;
        bh=lphzRdVkwylpEEDZihVeOjpl5bIBFz0Uu1heYjGVWMI=;
        b=epm9oCZIaEF+94uSr0d7/BEU/94jJDq24D0Rcd+czhMcoqDPHbEnFqIIBM1r5GBX7E
         ATSqag7ri2uAHXLeKQJl/1og5XGkhlP+QemNWEWYbQ76oTJE8/HzBHhSBuvYsS4Mz19n
         OV8GOPbW297r+JLXtRwNB08bm4QfotYE3HWeAmhXgz0mdNcrJlXsArDlJ671tZzYLEXF
         IaR52SB9BKgMeKDhHKikDIHQJhMdfwmasn7BPmdCYoGdSXzycPkb5mZf2pf5fGIs8B0X
         tfJPrPIRkB+hAL63/TSyOdRp7sI9IlSrSXVA4ISjRBeiDaxOMb+bMwdcWPQm6GG43sS4
         iv5A==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=vbYq2cC5;
       spf=pass (google.com: domain of jonathanmueller.dev@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jonathanmueller.dev@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65])
        by mx.google.com with SMTPS id q7sor7200145edh.11.2017.10.30.11.36.57
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Mon, 30 Oct 2017 11:36:57 -0700 (PDT)
Received-SPF: pass (google.com: domain of jonathanmueller.dev@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65;
X-Received: by 10.80.146.209 with SMTP id l17mr12868589eda.13.1509388617169;
        Mon, 30 Oct 2017 11:36:57 -0700 (PDT)
Original-Received: from [192.168.1.98] (dslb-084-060-195-012.084.060.pools.vodafone-ip.de. [84.60.195.12])
        by smtp.gmail.com with ESMTPSA id h56sm17326140ede.15.2017.10.30.11.36.56
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 30 Oct 2017 11:36:56 -0700 (PDT)
In-Reply-To: <CAGg_6+MhHrsgMcAsqr_BiQu584PzypU+GMaRsPuo8XQ7V4RdoA@mail.gmail.com>
Content-Language: en-US
X-Original-Sender: jonathanmueller.dev@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=vbYq2cC5;       spf=pass
 (google.com: domain of jonathanmueller.dev@gmail.com designates 209.85.220.65
 as permitted sender) smtp.mailfrom=jonathanmueller.dev@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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:35148
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/35148>

On 30.10.2017 17:37, Nevin Liber wrote:
> On Mon, Oct 30, 2017 at 11:05 AM, <antanubis@gmail.com=20
> <mailto:antanubis@gmail.com>> wrote:
>=20
>         void(?) unique_ptr<T>::emplace(Args &&... args) { *this =3D
>         make_unique<T>(std::forward<Args>(args)...); }
>         void(?) shared_ptr<T>::emplace(Args &&... args) { *this =3D
>         make_shared<T>(std::forward<Args>(args)...); }
>=20
>=20
> Thoughts:
>=20
>   * 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.=C2=A0 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".=C2=A0 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).
>=20
> Note: =C2=A0I'm not saying these are reasons I would vote against such a=
=20
> proposal; rather, these are things which need to be discussed in the=20
> proposal.

Furthermore:

* The smart pointers and optional behave very differently: optional has=20
value semantics, so it makes sense to say "create a new object".
I don't think it makes sense to ask the same from unique_ptr.

* If we have `emplace()` what about a constructor of the same form?
Yes, there's make_XXX but with class template argument deduction we=20
don't really want make_XXX anymore.

* If `ptr.emplace(obj)` works, what about `ptr =3D obj`? If you say no to=
=20
assignment because it doesn't make sense, why allow emplace?

* Why go through all that just to save a `=3D make_unique<T>(blah)`?=20
That's not too much typing.

--=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/ebeab15d-5424-034b-7d86-b84b381a1977%40gmail.com=
..

.
