220 24648 <87mvqqko2z.fsf@gmail.com> article
Path: news.gmane.org!not-for-mail
From: Moritz Klammler <moritz.klammler@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: String class memory allocation
Date: Wed, 24 Feb 2016 18:36:20 +0100
Lines: 46
Approved: news@gmane.org
Message-ID: <87mvqqko2z.fsf@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
X-Trace: ger.gmane.org 1456335393 30799 80.91.229.3 (24 Feb 2016 17:36:33 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 24 Feb 2016 17:36:33 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDHI7IWJYALRBGGUW63AKGQEUL5LA7Y@isocpp.org Wed Feb 24 18:36:27 2016
Return-path: <std-proposals+bncBDHI7IWJYALRBGGUW63AKGQEUL5LA7Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lb0-f199.google.com ([209.85.217.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDHI7IWJYALRBGGUW63AKGQEUL5LA7Y@isocpp.org>)
	id 1aYdMQ-0004j9-Iy
	for gclcip-std-proposals@m.gmane.org; Wed, 24 Feb 2016 18:36:26 +0100
Original-Received: by mail-lb0-f199.google.com with SMTP id h8sf9264872lbh.3
        for <gclcip-std-proposals@m.gmane.org>; Wed, 24 Feb 2016 09:36:26 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=from:to:subject:date:in-reply-to:message-id:user-agent:mime-version
         :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=qDY+qeSZOd5/6xI6sDl6NqJs7bTsOgkkbPZO7gcI4YE=;
        b=yKNmZ0BD09vVQDWFyBCbVZuKdJTB3UKl8vltC0rDWjBe48dAdicpatdfEriGT0om/s
         ZR9i5uzxU3oa5HgClNvo2RBNW3U2RgZm9chN4wDFc+lNO8zIPPHHK2M3xIlzqNO/+igE
         vTBKRbGcqLVydq2U22BIKF9EbRj0L3gxjz0hnkc37ScWdYI2Ol5rzGGsZkg5L48rv29o
         Ge4WAJU+pe+jq9fg+BsdPJ5r27/6kLxod/LL9vgpdb9Sv6k9u8N+lsrF+NxKrA8lxrxL
         bnddu3lFttRFYONqFVPN+lAXQ+Qfn7vOj4a7NBx2hvUvUi05uZqiuJTMf0y1XHc+fq4z
         3DAw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:to:subject:date:in-reply-to:message-id
         :user-agent:mime-version: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=qDY+qeSZOd5/6xI6sDl6NqJs7bTsOgkkbPZO7gcI4YE=;
        b=KybmV0yhAUFe2nrgy0TEOyVUecBJjbUmBsSSkx/kxHCw67NEZvKwPc3V0h0R7xmzHg
         kjXI7XOnJP010JV5/IOuY2Og5JHB5Y4OEP7SSZl0EkmjnSHKBWJ7WkuVyI5e1ZMYnOnn
         qudc+T++aWgZQehJvbxdyeiTSwZMrmQpdr5y1KMpQxHakRl0FxYUuELV6xc79QgyJL75
         Khcn6eApPWJhMH7H9Zbqey1Vxqj6cSX+oe2Jqhkgu6KtBuZpE+eTRqKe0lekQ9GKGWdd
         OBbfeYQGTK6NRqmEb5aDAG5e0qL5q86gD/2/TkCDumAzDVmvTLFe6nGjpZDJYEPU0z+E
         nE3Q==
X-Gm-Message-State: AG10YOSECkMPxfCeXoTz8VBFnsZwOYoxxWLGIGweBdsWjYHPN2F2k05Q4J3V1WYnmPvm4g==
X-Received: by 10.28.6.14 with SMTP id 14mr2831107wmg.6.1456335386072;
        Wed, 24 Feb 2016 09:36:26 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.126.130 with SMTP id z124ls129529wmc.19.gmail; Wed, 24 Feb
 2016 09:36:24 -0800 (PST)
X-Received: by 10.194.123.35 with SMTP id lx3mr39662683wjb.132.1456335384051;
        Wed, 24 Feb 2016 09:36:24 -0800 (PST)
Original-Received: from mail-wm0-x22d.google.com (mail-wm0-x22d.google.com. [2a00:1450:400c:c09::22d])
        by mx.google.com with ESMTPS id w4si4751412wje.208.2016.02.24.09.36.24
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 24 Feb 2016 09:36:24 -0800 (PST)
Received-SPF: pass (google.com: domain of moritz.klammler@gmail.com designates 2a00:1450:400c:c09::22d as permitted sender) client-ip=2a00:1450:400c:c09::22d;
Original-Received: by mail-wm0-x22d.google.com with SMTP id g62so283259289wme.1
        for <std-proposals@isocpp.org>; Wed, 24 Feb 2016 09:36:24 -0800 (PST)
X-Received: by 10.28.136.19 with SMTP id k19mr24063572wmd.11.1456335383847;
        Wed, 24 Feb 2016 09:36:23 -0800 (PST)
Original-Received: from moritz-desktop (HSI-KBW-46-223-128-55.hsi.kabel-badenwuerttemberg.de. [46.223.128.55])
        by smtp.gmail.com with ESMTPSA id w144sm32185084wmd.8.2016.02.24.09.36.21
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 24 Feb 2016 09:36:22 -0800 (PST)
In-Reply-To: Robin Rowe's message of "Wed\, 24 Feb 2016 08\:28\:33 -0800 \(1 hour\,
	6 minutes\, 1 second ago\)"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
X-Original-Sender: moritz.klammler@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of moritz.klammler@gmail.com designates 2a00:1450:400c:c09::22d as
 permitted sender) smtp.mailfrom=moritz.klammler@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: <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:24648
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/24648>

Given that we already have `std::array` and almost certainly will have
`std::string_view` soon, I think that this isssue is solved.


Robin Rowe <robinsrowe@gmail.com> writes:

> What's in the standard to avoid heap allocation during string creation?
>
> Is there a standard string class that doesn't use 'new', that works something
> like this?
>
> template <unsigned bufsize>
> class FixedLengthString
> {   char buffer[bufsize]
> public:
>    ... [ typical string interface ]
> };
>
> FixedLengthString<80> s("hello world");
>
> Is there a standard memory pool class, something like this?
>
> template <unsigned poolsize>
> class MemoryPoolString
> {   static MemoryPool memoryPool;//shared by all strings
>     char* buffer;
> public:
>     MemoryPoolString()
>     {   if(!memoryPool)
>         {    memoryPool.Create(poolsize);
>         }
>         buffer=0;
>     }
>    ...
> };
>
> My reason for caring is the cost of calling new on every string creation.
>
> Robin

-- 
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/87mvqqko2z.fsf%40gmail.com.

.
