220 18333 <CAFk2RUbREdNuGDaZugxDwG=Ck66LhC4knWTTR-mLGvGktfP5Rg@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Ville Voutilainen <ville.voutilainen@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Use cases for dyn_array
Date: Mon, 1 Jun 2015 19:13:26 +0300
Lines: 37
Approved: news@gmane.org
Message-ID: <CAFk2RUbREdNuGDaZugxDwG=Ck66LhC4knWTTR-mLGvGktfP5Rg@mail.gmail.com>
References: <a0542458-0240-4644-b313-55e257823db1@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: ger.gmane.org 1433175209 23157 80.91.229.3 (1 Jun 2015 16:13:29 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 1 Jun 2015 16:13:29 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC5JHI7A7ALRBJ4JWKVQKGQEZMWG2QY@isocpp.org Mon Jun 01 18:13:29 2015
Return-path: <std-proposals+bncBC5JHI7A7ALRBJ4JWKVQKGQEZMWG2QY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ob0-f198.google.com ([209.85.214.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC5JHI7A7ALRBJ4JWKVQKGQEZMWG2QY@isocpp.org>)
	id 1YzSLA-0004lU-LA
	for gclcip-std-proposals@m.gmane.org; Mon, 01 Jun 2015 18:13:28 +0200
Original-Received: by obbnx5 with SMTP id nx5sf201347849obb.3
        for <gclcip-std-proposals@m.gmane.org>; Mon, 01 Jun 2015 09:13:27 -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:in-reply-to:references:date
         :message-id:subject:from:to:content-type: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=ZB+rByU8WMmal7oOKKtrbsUY46qq7NFY87vvgB2jfPc=;
        b=C4yKcz6xVd2DPooLcMu00xHJiY/2neMWtsd/Xx8ro4YBcmHriMNNLSSijrdIj8xyYB
         uPxn1vFb9LgSQmLr1yCKlNax1qRVHG6eidleGKX86lq7ItsimjeyERBJbDEVX2cVV5Ur
         1GhCbgAwx/HTGB4609sSBKdk+syl2qIjx9xu4JJOjfU/jbdhYa8VGmJZjnOeLRTEZ4lG
         QjWFND1/3xCN60ovK49cYiX+6WIJegqY1JfflJBh9XSihS9TrPc8PQMujKLJ0b+MbgDc
         tekAu9iYSfIYGFCf6a2j1GnARaKDKwjVuuJeNSEuJ616zh5JhG5H9B7uaUXzz+oauiQB
         lRqw==
X-Gm-Message-State: ALoCoQkXZL1ia+E7VHktOLD6GbOJkHoh2eAK7MZtrpXRvP/rFmO3XNRy5xdJ86B4AER1iWkpUiyA
X-Received: by 10.43.126.71 with SMTP id gv7mr12726548icc.27.1433175207722;
        Mon, 01 Jun 2015 09:13:27 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.154.196 with SMTP id c187ls1359628ioe.101.gmail; Mon, 01
 Jun 2015 09:13:26 -0700 (PDT)
X-Received: by 10.50.111.131 with SMTP id ii3mr14354947igb.47.1433175206925;
        Mon, 01 Jun 2015 09:13:26 -0700 (PDT)
Original-Received: from mail-ie0-x231.google.com (mail-ie0-x231.google.com. [2607:f8b0:4001:c03::231])
        by mx.google.com with ESMTPS id b6si8656483ign.1.2015.06.01.09.13.26
        for <std-proposals@isocpp.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 01 Jun 2015 09:13:26 -0700 (PDT)
Received-SPF: pass (google.com: domain of ville.voutilainen@gmail.com designates 2607:f8b0:4001:c03::231 as permitted sender) client-ip=2607:f8b0:4001:c03::231;
Original-Received: by iesa3 with SMTP id a3so112875453ies.2
        for <std-proposals@isocpp.org>; Mon, 01 Jun 2015 09:13:26 -0700 (PDT)
X-Received: by 10.107.166.203 with SMTP id p194mr15759088ioe.30.1433175206779;
 Mon, 01 Jun 2015 09:13:26 -0700 (PDT)
Original-Received: by 10.36.152.8 with HTTP; Mon, 1 Jun 2015 09:13:26 -0700 (PDT)
In-Reply-To: <a0542458-0240-4644-b313-55e257823db1@isocpp.org>
X-Original-Sender: ville.voutilainen@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of ville.voutilainen@gmail.com designates 2607:f8b0:4001:c03::231 as
 permitted sender) smtp.mail=ville.voutilainen@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:18333
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/18333>

On 1 June 2015 at 19:07, Matthew Fioravante <fmatthew5876@gmail.com> wrote:
> I know dyn_array was removed from the standard for now, but I have some uses
> cases for a type like this. Specifically for a fixed size heap allocated
> array. I don't much care whether or not its optimized to use stack memory.

Then it's not dyn_array that you want.

>
> Specifically, a fixed size heap allocated array gives you the following
> capabilities that std::vector does not. Note that these may or may not be
> possible with the latest specification of dyn_array.
>
> 1) You can store a collection of non-copyable / non-movable types in a
> contiguous memory block, improving cache locality.
> 2) You can store const objects. This allows you to construct once and then
> enforce invariants that the objects are never modified forever after.
> 3) The container will always perform an exact size memory allocation for
> you, unlike vector which may allocate more in anticipation of future
> push_back() calls.
> 4) The container only needs to store 2 pointers instead of 3, making objects
> of this type much more cache line friendly.

Any particular reason why you don't just use the array version of unique_ptr?

> For this to work, first dyn_array<const T> should be move constructible from
> dyn_array<T>. The move constructor should also be implemented to just steal

...especially since unique_ptr for array types gives you this.

-- 

--- 
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.
