220 19897 <CAFdMc-3YnTpF2ycFPKSVMgnZjOohaa2xePeV_PVRnjLduRpSAQ@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: "dgutson ." <danielgutson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: First working prototype for static allocation: we can
 have complex containers in ROM
Date: Tue, 18 Aug 2015 13:51:05 -0300
Lines: 71
Approved: news@gmane.org
Message-ID: <CAFdMc-3YnTpF2ycFPKSVMgnZjOohaa2xePeV_PVRnjLduRpSAQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: ger.gmane.org 1439916671 16222 80.91.229.3 (18 Aug 2015 16:51:11 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 18 Aug 2015 16:51:11 +0000 (UTC)
To: std-proposals <std-proposals@isocpp.org>, andrewtomazos@gmail.com
Original-X-From: std-proposals+bncBDE3NBMV6UFBB6OEZWXAKGQEYE7DRLA@isocpp.org Tue Aug 18 18:51:10 2015
Return-path: <std-proposals+bncBDE3NBMV6UFBB6OEZWXAKGQEYE7DRLA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qk0-f200.google.com ([209.85.220.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDE3NBMV6UFBB6OEZWXAKGQEYE7DRLA@isocpp.org>)
	id 1ZRk6N-0002u2-9E
	for gclcip-std-proposals@m.gmane.org; Tue, 18 Aug 2015 18:51:07 +0200
Original-Received: by qkfn3 with SMTP id n3sf246819510qkf.3
        for <gclcip-std-proposals@m.gmane.org>; Tue, 18 Aug 2015 09:51:06 -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:date:message-id:subject:from:to
         :content-type: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=CxGQN9pldvJrrw7S2fjyXALsbwyLz7K6D/4Jn2cEtfI=;
        b=Gi5d3yJX/YGSS+8gx/SuepOHqc/ji9UDkV5ko/LU/peKCuvFEVIDTwqGrtzELseB8K
         LfVjaRCmRPoK1RGrKe+cTdjDqBdLgs4n1NPFrxePHVgpbUIPIDkL7k+YjW/Qe1K6iBdI
         83cdgMc5cnG6o4LzqUuE0H+bgzOHzyQnOzFnFEurSstCLt9xY5lFyLSRwTk/4L85MwQO
         LIgd5iIj1DemwgJ/mgrq5bEis98mS9EcUyUaVC7ejUIsCfpk2hGAh/a5wiS95a9AXOtT
         xiAM+rMDES6M5m/ELYyHNElUXpCu7qI9xtqoy4CrIsYp4+iFXuTKHXAxQm8UOmAl56KB
         4blA==
X-Gm-Message-State: ALoCoQmYd8c32JsAvUm36nOF+EX54cEnWC4eMxJSGqpiZWnWIh7RxcI/qcVkpN8KoKuDAxcW2h/Q
X-Received: by 10.13.203.77 with SMTP id n74mr6635156ywd.35.1439916666532;
        Tue, 18 Aug 2015 09:51:06 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.25.194 with SMTP id 185ls2014124ioz.90.gmail; Tue, 18 Aug
 2015 09:51:05 -0700 (PDT)
X-Received: by 10.107.10.9 with SMTP id u9mr7345618ioi.118.1439916665613;
        Tue, 18 Aug 2015 09:51:05 -0700 (PDT)
Original-Received: from mail-ig0-x229.google.com (mail-ig0-x229.google.com. [2607:f8b0:4001:c05::229])
        by mx.google.com with ESMTPS id c199si12530734ioc.129.2015.08.18.09.51.05
        for <std-proposals@isocpp.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 18 Aug 2015 09:51:05 -0700 (PDT)
Received-SPF: pass (google.com: domain of danielgutson@gmail.com designates 2607:f8b0:4001:c05::229 as permitted sender) client-ip=2607:f8b0:4001:c05::229;
Original-Received: by igxp17 with SMTP id p17so85471751igx.1
        for <std-proposals@isocpp.org>; Tue, 18 Aug 2015 09:51:05 -0700 (PDT)
X-Received: by 10.50.64.147 with SMTP id o19mr24345571igs.15.1439916665443;
 Tue, 18 Aug 2015 09:51:05 -0700 (PDT)
Original-Received: by 10.36.116.147 with HTTP; Tue, 18 Aug 2015 09:51:05 -0700 (PDT)
X-Original-Sender: danielgutson@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of danielgutson@gmail.com designates 2607:f8b0:4001:c05::229 as
 permitted sender) smtp.mailfrom=danielgutson@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-Spam-Checked-In-Group: 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:19897
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/19897>

Hi.

We are working in a custom gcc (plus a plugin) which is able to
"statically allocate" memory and modify its content during constexpr
constructors.
We basically provide a "static_alloc<T>(size_t n)" function for this purpos=
e.
With this infrastructure, we were able to write two examples:
- an uppercase_static_string class that receives a C-string in its
constexpr ctor, allocates a (const) char array, copies the content
transforming all the
characters to uppercase. The whole object is stored in the .rodata
section of the binary. The access methods are a subset of the const of
the std::string.
- a static_sorted_array class that receives an initializer_list<int>,
allocates the content and sorts it. The resulting array also is stored
in the .rodata section.

We are working towards applying the same infrastructure for
non-constant objects (of static storage duration) as a superior
solution to
allocators with pre-allocated memory pools, since the exact required
memory is calculated during compile time and out-of-memory detection
can cause a compilation failure.

This work is mainly inspired by embedded and safety systems needs, and
has relation with Andrew's "predynamic storage".

As for our need, we have to provide a "static" version of some STL
containers, though a deeper analysis has to be done in order to
see if this infrastructure (or the "static_alloc" direction) could be
applied to the current STL containers by adding new constexpr
constructors
(I don't think it's possible, but I didn't get into it yet).

If there are people attending the forthcoming meetings interested in
championship this and being a co-author, please let me know (PM) and
we
will provide details and the prototype (which is actively under
development in order to overcome two implementation issues). We are
also
looking for help to implement the static containers (we will implement
only the unordered_map and multiset counterparts).

What is going to happen soon is: we will send some patches to gcc and
I will write a technical report about this with details.

Thanks,

   Daniel.

--=20
Who=E2=80=99s got the sweetest disposition?
One guess, that=E2=80=99s who?
Who=E2=80=99d never, ever start an argument?
Who never shows a bit of temperament?
Who's never wrong but always right?
Who'd never dream of starting a fight?
Who get stuck with all the bad luck?

--=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/.

.
