220 24662 <8ffac287-1ea1-4c04-9a9b-817610e013f1@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: String class memory allocation
Date: Thu, 25 Feb 2016 07:32:45 -0800 (PST)
Lines: 153
Approved: news@gmane.org
Message-ID: <8ffac287-1ea1-4c04-9a9b-817610e013f1@isocpp.org>
References: <Nicol Bolas's message of "Wed\, 24 Feb 2016 09\:54\:23 -0800 \(PST\)
	\(1 hour\, 18 minutes\, 22 seconds ago\)">
 <87io1dlxx7.fsf@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_867_1167178551.1456414365329"
X-Trace: ger.gmane.org 1456414373 25772 80.91.229.3 (25 Feb 2016 15:32:53 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 25 Feb 2016 15:32:53 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBHV5XS3AKGQEUQGXJZY@isocpp.org Thu Feb 25 16:32:49 2016
Return-path: <std-proposals+bncBCEKFTV6ZUMBBHV5XS3AKGQEUQGXJZY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ig0-f197.google.com ([209.85.213.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBHV5XS3AKGQEUQGXJZY@isocpp.org>)
	id 1aYxuK-0000Mo-60
	for gclcip-std-proposals@m.gmane.org; Thu, 25 Feb 2016 16:32:48 +0100
Original-Received: by mail-ig0-f197.google.com with SMTP id o1sf40803589igz.1
        for <gclcip-std-proposals@m.gmane.org>; Thu, 25 Feb 2016 07:32:47 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :content-type:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=i6sCoqxgK1aBjO826ResTjzrCUq/cIrhcpK1BcalBXc=;
        b=nUTDA/XTzXpWJpvDSf+ejsYW9si1Zb8ZJvyG48XBlZyUlR3+zwzVPZtsVy3DaXJQnR
         QbqT81IedGEDywnwFKPe2OTkpRalnh6St8jRa9qsZId91/0NaU+5y2dqGHII33lZ42d1
         zrSUaNkDP09tq3G5Kln4PcS0eohg92HWBQBsWgghhRQwb58O3JdsAZ65FFAZRVDlPJBw
         OSD+NFfe3v+JSbtN80Upti7abVuVBK7RjJ/k340oQXMytqrhWoKRpLRbc8el1sfK2sqJ
         t/LbwVjyl3PsLP8lQSFx5NwXwGgrhBHxNic7/Q4j0iremi4GoaxHQAxFrmRCx3Zf6yJp
         FLPQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :content-type:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=i6sCoqxgK1aBjO826ResTjzrCUq/cIrhcpK1BcalBXc=;
        b=H1Il7cJpDi5KywCvM8pnB4aAsONZ1sN5zAAcaXGgLRjry66/IWuuihvynefU8/nv2P
         a/EQ1qQYtXmlnEsuB0PvJH/a2fLbPhuF6kpTnswHNFQ6XJROr/JopRrMX1JuHEndO0yx
         WUhvx1uGSKe2o/J941HDFQPrVWdWWMXCY1UXnx34B4inY9L08fKt+OilHadLop1IqASg
         ARJfx9XXt0UkG/IFY9C/WFzuT1AEuwaVoIm6xF/oeVbY2rAMp06mLFbttsNc31GT3Xvc
         /30gQo+DMbt8M/IRNj+kPDksvocegex30vo6xQ74wKcZAH5trc2MMly8QGgRwe4qc/dH
         Ogpw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:content-type:x-original-sender:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=i6sCoqxgK1aBjO826ResTjzrCUq/cIrhcpK1BcalBXc=;
        b=FdqkDh1OEnWV8opX3N+W3AGHaj0fSTs9b9Hgtjkm8b8mGoj7MjeeUiHCKWE8IEwLUg
         L13yI+HlGN7t2BLTBSty3WK1beAxcKK7xFVUlamoOUl9r+Ty4wC749foZxf0K/ItreY/
         L8SGpdIJjGs7BBM/8mfkXLr38e/TLb0kJNNX8SLTe1GGWaO9/Y6GuRMuqBPndFhEe+rV
         f2KX0SrTqVE5y2AZLtyv9tpHhJB/aeHzlDyMJf2Nh0P7FeVjLAOez0QhBjuvOoq7LkfC
         JHba1OxtZxvczW+DvdmhjME9VDVvM5CxzQ8+QCFqsJbXJOW1LBXv0nJRgF0DQqxxFnQS
         5V8Q==
X-Gm-Message-State: AG10YOQIo2ZTF6MVLHm26q6PSRRIuOm7rix8XhxtwBn0mvHcm741Fl8JDxSfLdALeGzvzA==
X-Received: by 10.182.19.164 with SMTP id g4mr41310574obe.42.1456414367245;
        Thu, 25 Feb 2016 07:32:47 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.17.11 with SMTP id z11ls454695ioi.54.gmail; Thu, 25 Feb
 2016 07:32:46 -0800 (PST)
X-Received: by 10.50.102.106 with SMTP id fn10mr77450igb.5.1456414365994;
        Thu, 25 Feb 2016 07:32:45 -0800 (PST)
In-Reply-To: <87io1dlxx7.fsf@gmail.com>
X-Original-Sender: jmckesson@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:24662
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/24662>

------=_Part_867_1167178551.1456414365329
Content-Type: multipart/alternative; 
	boundary="----=_Part_868_564565729.1456414365330"

------=_Part_868_564565729.1456414365330
Content-Type: text/plain; charset=UTF-8

On Wednesday, February 24, 2016 at 2:18:34 PM UTC-5, Moritz Klammler wrote:
>
> Nicol Bolas <jmck...@gmail.com <javascript:>> writes: 
>
> > On Wednesday, February 24, 2016 at 12:36:26 PM UTC-5, Moritz Klammler 
> wrote: 
> >> 
> >> Given that we already have `std::array` and almost certainly will 
> >> have `std::string_view` soon, I think that this isssue is solved. 
> >> 
> > 
> > `string_view` will not obviate the need for a fixed-length string 
> > class.  And `array<char>` is not a string; it's an array of char. 
>
> In case this wasn't clear, my point is of course that you can use 
> `std::array` to *store* the data and *atop of that* a `std::string_view` 
> to *access* it through the "string interface" the OP requested.


Really? So naturally, this works, right?

array<char, 20> arr = "A String";

Oh wait, it doesn't. And neither does this:

array<char, 20> arr = {'N', 'U', 'L', 'L', '\0'};
string_view sv(arr);

It'll compile, but `sv` will get its size from `arr.size()`, which most 
assuredly not the intended value of 4.

Obviously you could write wrapper functions and/or types that make all of 
these work; nobody's arguing that it isn't possible to create such things. 
But the whole point of the question was whether such things *already exist* 
in the standard library, not whether the standard library has a bunch of 
pieces that could be assembled into such things.

-- 
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/8ffac287-1ea1-4c04-9a9b-817610e013f1%40isocpp.org.

------=_Part_868_564565729.1456414365330
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wednesday, February 24, 2016 at 2:18:34 PM UTC-5, Morit=
z Klammler wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">Nicol Bolas &=
lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"po8KG=
xBcAgAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&#39;;=
return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;">jm=
ck...@gmail.com</a>&gt; writes:
<br>
<br>&gt; On Wednesday, February 24, 2016 at 12:36:26 PM UTC-5, Moritz Klamm=
ler wrote:
<br>&gt;&gt;
<br>&gt;&gt; Given that we already have `std::array` and almost certainly w=
ill
<br>&gt;&gt; have `std::string_view` soon, I think that this isssue is solv=
ed.
<br>&gt;&gt;
<br>&gt;
<br>&gt; `string_view` will not obviate the need for a fixed-length string
<br>&gt; class. =C2=A0And `array&lt;char&gt;` is not a string; it&#39;s an =
array of char.
<br>
<br>In case this wasn&#39;t clear, my point is of course that you can use
<br>`std::array` to *store* the data and *atop of that* a `std::string_view=
`
<br>to *access* it through the &quot;string interface&quot; the OP requeste=
d.</blockquote><div><br>Really? So naturally, this works, right?<br><br><di=
v class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); bord=
er-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-=
wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint=
"><span style=3D"color: #000;" class=3D"styled-by-prettify">array</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">char</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" clas=
s=3D"styled-by-prettify">20</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> arr </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #080;" class=3D"styled-by-prettify">&quot;A St=
ring&quot;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
;</span></div></code></div><br>Oh wait, it doesn&#39;t. And neither does th=
is:<br><br><div class=3D"prettyprint" style=3D"background-color: rgb(250, 2=
50, 250); border-color: rgb(187, 187, 187); border-style: solid; border-wid=
th: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"=
subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-prettify">a=
rray</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">char</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #066;" class=3D"styled-by-prettify">20</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> arr </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">{</span><span style=3D"color: #080;" class=3D"styled-by-prettify">&#39;=
N&#39;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #080;" class=3D"styled-by-prettify">&#39;U&#39;</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #080;" class=3D"styled-by-prettify">&#39;L&#39;</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D=
"styled-by-prettify">&#39;L&#39;</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-pret=
tify">&#39;\0&#39;</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">};</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>string_view sv</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">a=
rr</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div=
></code></div><br>It&#39;ll compile, but `sv` will get its size from `arr.s=
ize()`, which most assuredly not the intended value of 4.<br><br>Obviously =
you could write wrapper functions and/or types that make all of these work;=
 nobody&#39;s arguing that it isn&#39;t possible to create such things. But=
 the whole point of the question was whether such things <i>already exist</=
i> in the standard library, not whether the standard library has a bunch of=
 pieces that could be assembled into such things.</div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/8ffac287-1ea1-4c04-9a9b-817610e013f1%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/8ffac287-1ea1-4c04-9a9b-817610e013f1=
%40isocpp.org</a>.<br />

------=_Part_868_564565729.1456414365330--
------=_Part_867_1167178551.1456414365329--

.
