220 13752 <835B0691-50CD-490A-86DF-83A709CC550D@gmail.com> article
Path: news.gmane.org!not-for-mail
From: Miro Knejp <miro.knejp@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Proposing std::uninitialized_default /
 uninitialized_emplace algorithm
Date: Wed, 8 Oct 2014 10:25:38 +0200
Lines: 73
Approved: news@gmane.org
Message-ID: <835B0691-50CD-490A-86DF-83A709CC550D@gmail.com>
References: <201410072114.05963.marc.mutz@kdab.com> <CAGNvRgCQJoXKx2q3VgKxQTjeUOteXgoKgoeN4+-EE0fLCVZsGA@mail.gmail.com> <5434AAA1.1090507@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\))
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: ger.gmane.org 1412756756 16984 80.91.229.3 (8 Oct 2014 08:25:56 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 8 Oct 2014 08:25:56 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC6ONSXJ54LBBB7K2OQQKGQE2N6ZTVI@isocpp.org Wed Oct 08 10:25:50 2014
Return-path: <std-proposals+bncBC6ONSXJ54LBBB7K2OQQKGQE2N6ZTVI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ee0-f70.google.com ([74.125.83.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC6ONSXJ54LBBB7K2OQQKGQE2N6ZTVI@isocpp.org>)
	id 1XbmZ7-0007ep-SA
	for gclcip-std-proposals@m.gmane.org; Wed, 08 Oct 2014 10:25:45 +0200
Original-Received: by mail-ee0-f70.google.com with SMTP id c13sf5069310eek.9
        for <gclcip-std-proposals@m.gmane.org>; Wed, 08 Oct 2014 01:25:45 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:subject:from:in-reply-to:date
         :message-id:references:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe:content-type:content-transfer-encoding;
        bh=118zHUXoleL90RtAMB62/Lqjv8yql2yJ4rvL6IpYst0=;
        b=kYGG+tBJPXrnDiUAw6OMqw6EkviPrudZrQPX7D5xfdaqAJMYFpVrS40j1Cj6HVDU4f
         h0SneOJW19ENViG6+FrpCR5dBAl7fND9Md67bf1Ub4WT1XFrfE1I47xBH5AGP9ZctZdf
         Xfcet6uRz9dIYK/UdwplhW698ZG8jqT3IvxDlepADTYD3D7byzRTPFptjWMsnzeXhARH
         06xAEqfaqgZ7HpYPzrjcIURGGOCxiqaYbQdi63o1nWZ5V66gYtBf0Fo9eOBzflRT8ayL
         7JcCInK9bOTlfu9Wcp0ryrRks8t9tmjQZ3KfP5nKnr87fOvGnLkYpdrJQ6U1ynStamzF
         AaUw==
X-Gm-Message-State: ALoCoQmdGpZa9Dpsr9asn+tYPlneGz4AJEZY6nxzndPQ+oD4w7OvP7/erkDa3LoOaDhaw+uoHtFg
X-Received: by 10.152.26.225 with SMTP id o1mr211004lag.4.1412756745593;
        Wed, 08 Oct 2014 01:25:45 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.152.224.161 with SMTP id rd1ls30205lac.95.gmail; Wed, 08 Oct
 2014 01:25:43 -0700 (PDT)
X-Received: by 10.153.6.36 with SMTP id cr4mr9765052lad.40.1412756743385;
        Wed, 08 Oct 2014 01:25:43 -0700 (PDT)
Original-Received: from mail-la0-x22b.google.com (mail-la0-x22b.google.com [2a00:1450:4010:c03::22b])
        by mx.google.com with ESMTPS id c6si31939627laf.105.2014.10.08.01.25.43
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Wed, 08 Oct 2014 01:25:43 -0700 (PDT)
Received-SPF: pass (google.com: domain of miro.knejp@gmail.com designates 2a00:1450:4010:c03::22b as permitted sender) client-ip=2a00:1450:4010:c03::22b;
Original-Received: by mail-la0-f43.google.com with SMTP id mc6so8017221lab.30
        for <std-proposals@isocpp.org>; Wed, 08 Oct 2014 01:25:43 -0700 (PDT)
X-Received: by 10.112.130.41 with SMTP id ob9mr9064832lbb.12.1412756742907;
        Wed, 08 Oct 2014 01:25:42 -0700 (PDT)
Original-Received: from [172.16.3.99] (p3E9EEDEE.dip0.t-ipconnect.de. [62.158.237.238])
        by mx.google.com with ESMTPSA id 2sm584768lai.36.2014.10.08.01.25.41
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Wed, 08 Oct 2014 01:25:41 -0700 (PDT)
In-Reply-To: <5434AAA1.1090507@gmail.com>
X-Mailer: Apple Mail (2.1878.6)
X-Original-Sender: miro.knejp@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of miro.knejp@gmail.com designates 2a00:1450:4010:c03::22b as
 permitted sender) smtp.mail=miro.knejp@gmail.com;       dkim=pass
 header.i=@gmail.com;       dmarc=pass (p=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: <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:13752
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/13752>

On 08 Oct 2014, at 05:08 , John Bytheway <jbytheway@gmail.com> wrote:

> On 2014-10-07 15:20, Daniel Kr=FCgler wrote:
>> 2014-10-07 21:14 GMT+02:00 Marc Mutz <marc.mutz@kdab.com>:
>>> Hi,
>>>=20
>>> I've recently had use of default-constructing a range of T's into
>>> uninitialized memory. When I was filling the range with copies of a T,
>>> std::uninitialized_fill() was a good fit, esp. since it is strongly exc=
eption
>>> safe.
>>>=20
>>> But there's no uninitialized_ algorithm for default-constructing a rang=
e.
>>>=20
>>> The nearest there is,
>>>   std::uninitialized_fill(first, last, T());
>>> has slightly different semantics, as it invokes the copy contructor ins=
tead
>>> (and that one could be deleted).
>>>=20
>>> The same issue plagues the use of raw_memory_iterator.
>>>=20
>>> I ended up writing a loop and a try-catch block :(
>>>=20
>>> So I think there's a place for
>>>  std::uninitialized_default(ForwardIterator first, ForwardIterator last=
);
>>> (better names welcome).
>>=20
>> No better name suggestion at the very moment at my hand, but the
>> general idea looks reasonable and safe to me.
>>=20
>>> Since I don't much like the name 'uninitialized_default', I looked for =
a more
>>> general name / algorithm, and I found "emplace". Emplace without argume=
nts
>>> default-constructs, with one argument or type T, it is a replacement of=
 _fill
>>> (with no intention to deprecate _fill):
>>>   std::uninitialized_emplace(ForwardIterator first, ForwardIterator las=
t,
>>>                   Args&&...args);
>>>=20
>>> Does that make sense?
>>=20
>> I have strong concerns in regard to emplace in that context. Basically
>> everywhere "emplace" means a potential move of the provided arguments
>> to construct a single object. This won't work for a potential
>> multi-construction operation except for special cases (like empty
>> packs or packs of lvalues to const). People will easily get that
>> wrong. If you insist on copying the arguments, you could name it
>> emplace_copy and ensure that the argument pack refers to references to
>> const.

In the context of the standard library functions labeled "emplace" simply d=
o in-place construction at the destination location. What happens to the ar=
guments is solely the responsibility of the invoked constructor. If you con=
struct multiple objects with the same arguments you better use constructors=
 that behave well in that scenario. But you probably do want to receive arg=
uments as lvalue references in this case just to be safe.

--=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/.

.
