220 24644 <56CDDA31.5090706@gmail.com> article
Path: news.gmane.org!not-for-mail
From: Robin Rowe <robinsrowe@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: String class memory allocation
Date: Wed, 24 Feb 2016 08:28:33 -0800
Lines: 40
Approved: news@gmane.org
Message-ID: <56CDDA31.5090706@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; format=flowed
X-Trace: ger.gmane.org 1456331321 13771 80.91.229.3 (24 Feb 2016 16:28:41 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 24 Feb 2016 16:28:41 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCUOVZFOBEILDNFXWYCRUBCDRTLPU@isocpp.org Wed Feb 24 17:28:37 2016
Return-path: <std-proposals+bncBCUOVZFOBEILDNFXWYCRUBCDRTLPU@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+bncBCUOVZFOBEILDNFXWYCRUBCDRTLPU@isocpp.org>)
	id 1aYcIl-0001Mt-Ld
	for gclcip-std-proposals@m.gmane.org; Wed, 24 Feb 2016 17:28:35 +0100
Original-Received: by mail-ob0-f198.google.com with SMTP id gc3sf49457629obb.1
        for <gclcip-std-proposals@m.gmane.org>; Wed, 24 Feb 2016 08:28:35 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=to:from:subject:message-id:date:user-agent:mime-version
         :content-type: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=sWGN7+gffrVD8TiZ0ITSJ+poq60UPnBEx08tAhu/btI=;
        b=EwEYBbwl/cQ9kz77zBCcNQteUZbetkE5ig7e6Jb1e++HSaNa5rdWYhISJLtQyN8k/0
         RPQx82eTN/Qlc5ZDAYOuwbnguuxxM9S13jm4FSPCzF3iQPYnjCEEH9hLVx1ocLyZQiOy
         aI0RDu6IUIPXjfOcvaXGT5Rgzhtttc/gvlFGHNjtU/CqMOFl/tY3zSNqSNha1y/1Cv/Q
         iIjgUVZcRNhVJO4lYIvvbKMGcMCvT+JBwKkZdw5L2AuSapSngXJi9pubcqGWdR7639jh
         ZSOd5PAgx4sj8Y4Xu2mPaxNBvtmCYYElrbKFj9cqqdXdbTJS+roel/X1WuLuX++de9OH
         54Vw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:to:from:subject:message-id:date:user-agent
         :mime-version:content-type: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=sWGN7+gffrVD8TiZ0ITSJ+poq60UPnBEx08tAhu/btI=;
        b=No+0YgWq9T8t8wIctII2RHvh0879NchPVzPlbn1ma6nYM4Iq3U53cXz3liVJpqO+/t
         Ini38/1bqyR+9BTk3dxZMSP9bgLuYnkv7LLW3DFuxHX++ki91h9Tt94bA87ZztxU7AS8
         LPeKR+qXvnwhCzv6VmUdS9S4pRiB3T/49Z8vxxLgZF4xBukipYA3sm0WjB0934NAJqzk
         kTVm9wxAsJpLrX5gx5vE48hJ+XpL5uNmpHDIkzIBTZBbk++qSWgbaiHrULl1vjqRRtSO
         RMkvmAV98657jwgmFMK+ikIoD3lOuEKif2RKIg5SSWw9oSS32JCf0645aW4Yy7Hq8NVJ
         EzYQ==
X-Gm-Message-State: AG10YOTdRO1+3ag2Ogye1NdbK3rtO31e5FbwB4lz7+yKxOxXO2olqwFED6odcmSyqfDtBw==
X-Received: by 10.50.57.51 with SMTP id f19mr401047igq.0.1456331314793;
        Wed, 24 Feb 2016 08:28:34 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.168.83 with SMTP id r80ls127750ioe.88.gmail; Wed, 24 Feb
 2016 08:28:33 -0800 (PST)
X-Received: by 10.98.13.154 with SMTP id 26mr55985638pfn.164.1456331313293;
        Wed, 24 Feb 2016 08:28:33 -0800 (PST)
Original-Received: from mail-pf0-x236.google.com (mail-pf0-x236.google.com. [2607:f8b0:400e:c00::236])
        by mx.google.com with ESMTPS id h84si5838075pfd.171.2016.02.24.08.28.33
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 24 Feb 2016 08:28:33 -0800 (PST)
Received-SPF: pass (google.com: domain of robinsrowe@gmail.com designates 2607:f8b0:400e:c00::236 as permitted sender) client-ip=2607:f8b0:400e:c00::236;
Original-Received: by mail-pf0-x236.google.com with SMTP id q63so15381747pfb.0
        for <std-proposals@isocpp.org>; Wed, 24 Feb 2016 08:28:33 -0800 (PST)
X-Received: by 10.98.71.15 with SMTP id u15mr56169704pfa.161.1456331313088;
        Wed, 24 Feb 2016 08:28:33 -0800 (PST)
Original-Received: from [192.168.1.145] (cpe-75-82-92-81.socal.res.rr.com. [75.82.92.81])
        by smtp.googlemail.com with ESMTPSA id wh9sm6187947pab.8.2016.02.24.08.28.31
        for <std-proposals@isocpp.org>
        (version=TLSv1/SSLv3 cipher=OTHER);
        Wed, 24 Feb 2016 08:28:31 -0800 (PST)
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101
 Thunderbird/38.6.0
X-Original-Sender: robinsrowe@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of robinsrowe@gmail.com designates 2607:f8b0:400e:c00::236 as
 permitted sender) smtp.mailfrom=robinsrowe@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:24644
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/24644>

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/56CDDA31.5090706%40gmail.com.

.
