220 35137 <CAFk2RUaq1T6tMwAwsdkyorNM8gt550mYRwWkWGWa6gX4a=7koQ@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Ville Voutilainen <ville.voutilainen@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 18:06:45 +0200
Lines: 55
Approved: news@gmane.org
Message-ID: <CAFk2RUaq1T6tMwAwsdkyorNM8gt550mYRwWkWGWa6gX4a=7koQ@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: text/plain; charset="UTF-8"
X-Trace: blaine.gmane.org 1509379614 3717 195.159.176.226 (30 Oct 2017 16:06:54 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 30 Oct 2017 16:06:54 +0000 (UTC)
Cc: antanubis@gmail.com
To: "ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBC5JHI7A7ALRBF443XHQKGQEGLJXYVI@isocpp.org Mon Oct 30 17:06:45 2017
Return-path: <std-proposals+bncBC5JHI7A7ALRBF443XHQKGQEGLJXYVI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f70.google.com ([209.85.218.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBC5JHI7A7ALRBF443XHQKGQEGLJXYVI@isocpp.org>)
	id 1e9CaG-0007xp-UN
	for gclcip-std-proposals@m.gmane.org; Mon, 30 Oct 2017 17:06:41 +0100
Original-Received: by mail-oi0-f70.google.com with SMTP id e123sf16118390oig.14
        for <gclcip-std-proposals@m.gmane.org>; Mon, 30 Oct 2017 09:06:48 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1509379608; cv=pass;
        d=google.com; s=arc-20160816;
        b=cds1Rc9DzDiT/pjQR+E9aDJAKQG9J/1wHpo2H7gOp2ekoNIAz6CzjbsFldhouVRAda
         eonijHd5tHCuv8nZWE6tpSpGlWBBN7PaOLxilOU0UwpgUW1zh32roRwg3XVl8U+hO/o4
         AQdfW4IwC3XnnHmJ0LHDu7OXUWhsfDTidyWPjSku7L4HZONo3kbihHyan8fipkT3uNUM
         T2JUKRCu6UGY23VRMEy2dh+H76YhLFDD5yzl22WOF3S2q/8SAwoFYR66EsaWTKN1+NUE
         o9S9W15tz8U+F2W2uHc5g753xprLd4aMVKhMgOcJbdAWhT9vA3/qarOFEL/lVG3zcYzo
         kDJQ==
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:cc:to:subject:message-id
         :date:from:references:in-reply-to:mime-version
         :arc-authentication-results:arc-message-signature:dkim-signature
         :arc-authentication-results;
        bh=yFCfiBZYev3MbXC8bsAFrFbKJF3imbJx55i0ADx6rUA=;
        b=XwQDehzPzNDOTUQ4nzEbjn3Jly/Po0tC2i+o0wCaNublT3mWFl+Y5IiM59sf6Z0KBf
         E9v2lP1zOl14a/wJP/emc6ObTbkZFzyqRcxrK69SNstgXMHxnPNlMDnL1GX+hb+pTi86
         gqtbkYE0w0RGQ/st/I1MLqFa5H7+lIbOVaWxcRM5wjXsGPo5giDz7nEGHHJHopJdbsRl
         2oK1pQ2PrD8pgYqGRvGJyWo1mUe6vS5xI1GEd8a1tqC2LB5p/a0lxzIEU9UL145450kT
         XuAFjOGNPOFrxnfIDXLf2sJ9+Cct4uNvZ8NMkgLuiL3Ms4HPOyyehCyqx79HkQWRWSCb
         xNhA==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=NnWWgi9c;
       spf=pass (google.com: domain of ville.voutilainen@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=ville.voutilainen@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=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :cc: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=yFCfiBZYev3MbXC8bsAFrFbKJF3imbJx55i0ADx6rUA=;
        b=kwT6WbFkUvaIL2j3kG3EHUFxhRP06h8+zPHBq4G544ah6vW3WnkP6IB7le26ChYgqt
         A5IbJ9EhGfFc2EqFtPUS7K8BKi4KekIco8VU1e1SGS7l4aHxq6K8osPUUdeKZrN5eA7K
         IVl3YyJb9NJ3e8H287bO2g/aVd+kpkMaNglk2i5/3xaOdkF7FHeHEc97wPHJO0wc/1AI
         1xb0tkWQ7S3wANjvvYX/5fYHvJH/Mp2Ju30Buda101lZCQ6LYguSzSwfzJWnRYdRoxfn
         6lUeg6oi+F0MA+3DcX/+711U17CzJGqMvJoCrlYcjHh+IQRNAbjk2oWWICGipNA37t/+
         USrA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:cc: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=yFCfiBZYev3MbXC8bsAFrFbKJF3imbJx55i0ADx6rUA=;
        b=NSDSYjNWwhZIXdQPNRAvOLICjzLkOwKe2HuJZ9IBzDlIVo9N/ov0XKP7ppqmPf65em
         GVLYZmnNTTXmPXxSeDV21EnmN13hrhlZpMt0X3I8gR7YX3lE5Mx6n6VT7C7o5VKIgf9d
         cwMsA2v20nmOlYKBscoCenF4tJ7RlRmU0idLipP8RBMVJwC6MCnhnbfMUeS0KpM2D4uC
         f23/aa68tHXd5Sf87KxCpi1+UoU85dr1SdwAw0T+og5rYwb7auAv2b4Stz1GM4aVV1bT
         6p70i5sTnSNeb8aZy2o5os8ly321UlUJyLVUFReyynNwPusTG+hTXu1jBTXAXmEKBPxw
         tPTQ==
X-Gm-Message-State: AMCzsaX0LgF/PwMOhPlfwWBUoK9DixbmkC3YWfCa10jVUkY/m5IVQgLc
	0IfAO3ludD8F3gdpiA1+nuqTZw==
X-Google-Smtp-Source: ABhQp+SVRablB7bDf6BWmBlsYmWKKVvJqQGzfE2Rx+0tugDRg1iu/GgzbmuWB1jSq59+X8rs7ZLHig==
X-Received: by 10.157.67.136 with SMTP id t8mr9399686ote.1.1509379608145;
        Mon, 30 Oct 2017 09:06:48 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.202.76.8 with SMTP id z8ls4075251oia.4.gmail; Mon, 30 Oct 2017
 09:06:46 -0700 (PDT)
X-Received: by 10.157.26.14 with SMTP id a14mr5565238ote.439.1509379606909;
        Mon, 30 Oct 2017 09:06:46 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1509379606; cv=none;
        d=google.com; s=arc-20160816;
        b=uxMXPrFHBojyr6de1vcIz5DV+i1Z99+GK5aM0ruXMcuT8NR6f31a3QHZ2aty8Qa98j
         tPz+QAUHZXb8Z1W6WJj3W2k2jsUQ1WVAt693uJpWaN2rPHbP/lLDQroNol2tP4WeV285
         gLOxEZzpMf6IXy9dkl5L7Xus9enuvop02LYsB8VQZxg6h3wWZ6NjjzbPipSWrgqlaAZb
         boNZYVTBR3MEYvmo3FH0pbqejEv+tOWNYuOovtj7vvccX1jJ7ic24r/C1dS7b0t8Him4
         Di8Q1og9T7OobkUbgSHLrxMw+nw6dyjoGCTygC/n33nIOAAlY1z3PtAlwggBPFe68SdJ
         bRFg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=cc:to:subject:message-id:date:from:references:in-reply-to
         :mime-version:dkim-signature:arc-authentication-results;
        bh=1mcTmuGHqU36uxugAIB1I7DnLFUkVH+luVkh/U+1M0c=;
        b=uR34F50ZyOffp/rC+rO1U2DG4CW+bpHefs5bihPJGIpennZRM7a+lJ8OgfZWDHNEkr
         AbWlp9NSVfxDP1Bf/rb5xjiISUBOhpFR8MeouYjHDvOejqlFqZrz6Iuet5VBuLnekCEH
         ruMl6k5ykIrkmT4uyxTs2L7t0hRWUfQK9y5fF7jXTPX0lmvogQ14zECv9DJvScNyKD2D
         1ghjdYqzO+/uNp64A0skKiClHrZujkuUiDwa+2PBmyxHK4n1HREn8WMSFfcQHXrxMpVr
         IqC+ZEXiRiXw/sRlA0/zdIwiBenD5WQU55QxkVl4gU1k72ekh/HMqNUQXW6bmSv216nd
         tYlQ==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=NnWWgi9c;
       spf=pass (google.com: domain of ville.voutilainen@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=ville.voutilainen@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 p54sor5715640otc.86.2017.10.30.09.06.46
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Mon, 30 Oct 2017 09:06:46 -0700 (PDT)
Received-SPF: pass (google.com: domain of ville.voutilainen@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 10.157.83.6 with SMTP id g6mr6645944oth.432.1509379606425; Mon,
 30 Oct 2017 09:06:46 -0700 (PDT)
Original-Received: by 10.157.6.16 with HTTP; Mon, 30 Oct 2017 09:06:45 -0700 (PDT)
In-Reply-To: <db8aed18-d3b3-4df6-8e15-15f8c50e4bed@isocpp.org>
X-Original-Sender: ville.voutilainen@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=NnWWgi9c;       spf=pass
 (google.com: domain of ville.voutilainen@gmail.com designates 209.85.220.41
 as permitted sender) smtp.mailfrom=ville.voutilainen@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:35137
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/35137>

On 30 October 2017 at 18:05,  <antanubis@gmail.com> wrote:
> Perhaps being a nice substitution for "= make_...<T>(...)" the return type
> should be the reference to smart pointer and the return value should be
> *this.

The idea looks reasonable enough to me that I would recommend writing
a proposal for it.

>
> On Monday, October 30, 2017 at 8:01:25 PM UTC+4, anta...@gmail.com wrote:
>>
>> I've found really helpful in my own smart pointer classes to have
>> something like .create(Args &&..args) method that creates an object for an
>> owning shared pointer without the necessity for repeating the type in the
>> make_* non-member function.
>>
>> It's a shame that standard smart pointers don't have such method, so in
>> order to create a value you always need to repeat the type name, while it is
>> contained in the pointer type itself.
>>
>> After that I realized, that std::optional<> has such method named
>> .emplace() together with a free function make_optional<>. In some way
>> std::optional<> is a lot like "in-place std::unique_ptr<>" with deep-copying
>> by default.
>>
>> So I thought that proposing a member function "ptr.emplace(Args&&...
>> args)" for both std::unique_ptr and std::shared_ptr will be a really good
>> idea, it will also fit well with std::optional. The naive (but working)
>> implementation would be just:
>>
>> 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)...); }
>>
>> What do you think? Are there reasons not to add such methods? Or was this
>> discussed / proposed already?
>>
>> Vasilii Babich.
>
> --
> 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/db8aed18-d3b3-4df6-8e15-15f8c50e4bed%40isocpp.org.

-- 
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/CAFk2RUaq1T6tMwAwsdkyorNM8gt550mYRwWkWGWa6gX4a%3D7koQ%40mail.gmail.com.

.
