220 8650 <CAGg_6+M5rMg0oAoxCTEXjb4eurH0zWorHAfGvv8Qf7595EDLxA@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Nevin Liber <nevin@eviloverlord.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: string_view::is_null()
Date: Fri, 17 Jan 2014 13:58:37 -0600
Lines: 107
Approved: news@gmane.org
Message-ID: <CAGg_6+M5rMg0oAoxCTEXjb4eurH0zWorHAfGvv8Qf7595EDLxA@mail.gmail.com>
References: <8045a4d2-721d-4725-8bb7-7a91b6f53ec8@isocpp.org>
 <186E0927-C962-4E34-AED0-E7509DD1F0A0@gmail.com> <7aad44d8-6b4e-438a-b309-bd898b994b34@isocpp.org>
 <9C2C439F-7983-4224-B272-53CAD0E2E456@gmail.com> <3379bbae-dd54-461c-bf90-228e476ca7db@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=047d7bb04c442e701004f02ffa41
X-Trace: ger.gmane.org 1389988753 24702 80.91.229.3 (17 Jan 2014 19:59:13 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 17 Jan 2014 19:59:13 +0000 (UTC)
To: "std-proposals@isocpp.org" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCE35H5S6IDBBF4X42LAKGQEHVSFV7I@isocpp.org Fri Jan 17 20:59:21 2014
Return-path: <std-proposals+bncBCE35H5S6IDBBF4X42LAKGQEHVSFV7I@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ee0-f71.google.com ([74.125.83.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCE35H5S6IDBBF4X42LAKGQEHVSFV7I@isocpp.org>)
	id 1W4FZY-0001tr-6A
	for gclcip-std-proposals@m.gmane.org; Fri, 17 Jan 2014 20:59:20 +0100
Original-Received: by mail-ee0-f71.google.com with SMTP id t10sf7761675eei.6
        for <gclcip-std-proposals@m.gmane.org>; Fri, 17 Jan 2014 11:59:19 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:sender:in-reply-to:references:from
         :date:message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe:content-type;
        bh=WvUpeA+IFXBW74Czsv7flZxBLbjLo7wrp3g3Q7Br1CI=;
        b=FA5uvAeNauFGn+7YoHaI6ZhUTA2g8sZpqLAH0XrFo6VDbA7K526UIsA/e3ph5BE4fQ
         2Ne1V6nhC6hJpVywQE6CfXXLdjmZFTH1jKaXbUr5SbUpIY8uH/JAZ5/JHL7bAtnOKM/c
         X76cB+1z/oIRUCdDoUgSLlSd8dQ84zNE8p2e15mtrvJzGeKkS2eGtoJScTkTAOHhDqvL
         cLnEUd6ljK2+uOz/R6M4xu2SNlsLp4R6Ari8JlGhY3NGwyyw1QhfO61Xvqzb6XahBxvV
         eAN/nBkhshwZQqUONljE3nqYN3PaISDVHw72gQT2pImZ2YNxgOL9sa5z7z0MXPF2VWy4
         t2iA==
X-Gm-Message-State: ALoCoQm4Lq+BIRPjpL1w9QEA0v4zcFnLvNz5+/IQzEJHkrclJF2hwMLN5XCmru5JcX6/mJE0dotS
X-Received: by 10.152.27.73 with SMTP id r9mr1804451lag.4.1389988759756;
        Fri, 17 Jan 2014 11:59:19 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.180.89.2 with SMTP id bk2ls175779wib.13.canary; Fri, 17 Jan
 2014 11:59:18 -0800 (PST)
X-Received: by 10.180.94.7 with SMTP id cy7mr27444wib.21.1389988758454;
        Fri, 17 Jan 2014 11:59:18 -0800 (PST)
Original-Received: from mail-wi0-x234.google.com (mail-wi0-x234.google.com [2a00:1450:400c:c05::234])
        by mx.google.com with ESMTPS id mw18si2164654wic.8.2014.01.17.11.59.18
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Fri, 17 Jan 2014 11:59:18 -0800 (PST)
Received-SPF: pass (google.com: domain of nliber@gmail.com designates 2a00:1450:400c:c05::234 as permitted sender) client-ip=2a00:1450:400c:c05::234;
Original-Received: by mail-wi0-f180.google.com with SMTP id d13so1177552wiw.1
        for <std-proposals@isocpp.org>; Fri, 17 Jan 2014 11:59:18 -0800 (PST)
X-Received: by 10.195.13.130 with SMTP id ey2mr3739021wjd.7.1389988758317;
 Fri, 17 Jan 2014 11:59:18 -0800 (PST)
Original-Sender: nliber@gmail.com
Original-Received: by 10.194.121.163 with HTTP; Fri, 17 Jan 2014 11:58:37 -0800 (PST)
In-Reply-To: <3379bbae-dd54-461c-bf90-228e476ca7db@isocpp.org>
X-Original-Sender: nevin@eviloverlord.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of nliber@gmail.com designates 2a00:1450:400c:c05::234 as permitted
 sender) smtp.mail=nliber@gmail.com;       dkim=pass header.i=@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: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:8650
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/8650>

--047d7bb04c442e701004f02ffa41
Content-Type: text/plain; charset=ISO-8859-1

On 17 January 2014 12:34, Peter Bigot <bigotp@acm.org> wrote:

>
> While the half-open range argument is true in isolation, it's missing the
> point that the value of data() is well-known based on how the string_view
> was created and what operations have been performed on it.
>

How does the callee know how the string_view was created?  If the callee
has more preconditions than those enforced by string_view, you might be
better off using a separate type.  If the callee "knows" how it was
created, why use a string_view at all?


> Adjusting the string_view to the point where size() is zero does not
> invalidate data().
>
> Based on how sv2 is constructed in that example, I believe it's guaranteed
> that deref(sv2) will return the '\0' that terminates the string literal
> used to initialize sv2, and that doing so does not invoke undefined
> behavior.
>

What compilers are allowed to assume from the specification of the standard
library is an interesting question... :-)

Take for example:

std::vector<std::string> v(1);
auto p1 = v.data();
v.pop_back();

Can I legally do a placement new of a std::string into the space pointed to
by p1?  Beats me.
-- 
 Nevin ":-)" Liber  <mailto:nevin@eviloverlord.com>  (847) 691-1404

-- 

--- 
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/.

--047d7bb04c442e701004f02ffa41
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On 17 January 2014 12:34, Peter Bigot <span dir=3D"ltr">&l=
t;<a href=3D"mailto:bigotp@acm.org" target=3D"_blank">bigotp@acm.org</a>&gt=
;</span> wrote:<br><div class=3D"gmail_extra"><div class=3D"gmail_quote"><b=
lockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px =
#ccc solid;padding-left:1ex">

<div dir=3D"ltr"><br><div>While the half-open range argument is true in iso=
lation, it&#39;s missing the point that the value of data() is well-known b=
ased on how the string_view was created and what operations have been perfo=
rmed on it.</div>

</div></blockquote><div><br></div><div>How does the callee know how the str=
ing_view was created?=A0 If the callee has more preconditions than those en=
forced by string_view, you might be better off using a separate type.=A0 If=
 the callee &quot;knows&quot; how it was created, why use a string_view at =
all?<br>

</div><div>=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0=
 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div> A=
djusting the string_view to the point where size() is zero does not invalid=
ate data().<br>

<br>Based on how sv2 is constructed in that example, I believe it&#39;s gua=
ranteed that deref(sv2) will return the &#39;\0&#39; that terminates the st=
ring literal used to initialize sv2, and that doing so does not invoke unde=
fined behavior.=A0</div>

</div></blockquote><div><br></div><div>What compilers are allowed to assume=
 from the specification of the standard library is an interesting question.=
... :-)<br><br></div><div>Take for example:<br><br></div><div>std::vector&lt=
;std::string&gt; v(1);<br>

</div><div>auto p1 =3D v.data();<br></div><div>v.pop_back();<br><br></div><=
div>Can I legally do a placement new of a std::string into the space pointe=
d to by p1?=A0 Beats me.</div></div>-- <br>=A0Nevin &quot;:-)&quot; Liber=
=A0 &lt;mailto:<a href=3D"mailto:nevin@eviloverlord.com" target=3D"_blank">=
nevin@eviloverlord.com</a>&gt;=A0 (847) 691-1404
</div></div>

<p></p>

-- <br />
&nbsp;<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--047d7bb04c442e701004f02ffa41--

.
