220 8739 <0a730641-1b13-4290-8c01-5420515a1482@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Peter Bigot <bigotp@acm.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: string_view::is_null()
Date: Mon, 20 Jan 2014 05:13:11 -0800 (PST)
Lines: 122
Approved: news@gmane.org
Message-ID: <0a730641-1b13-4290-8c01-5420515a1482@isocpp.org>
References: <CAGNvRgDH=X2h4K_u3zOu7gUNuQbAcNHGNh=HfCRO9qG1mmiG1w@mail.gmail.com>
 <CANh-dXnytwWwS7E_BGA-xK8E-zw788TJKzM=HJdC-9JbF7+gTQ@mail.gmail.com>
 <104254A6-C69A-4571-8455-89D7E466D493@gmail.com> <CANh-dXngzdnwZZnLRxd=AXQcqLaQky9Cpdw6pkbH8tFqRyZavw@mail.gmail.com>
 <6a95bf9c-55c9-4ae2-966f-d1b1f4df6a37@isocpp.org> <52D9E336.1060801@knejp.de>
 <1B534FD7-B385-4A7E-A718-3C73F0AB61DC@gmail.com> <11f13f8f-1270-427c-8942-94027a181ff4@isocpp.org>
 <20140119174431.GA16875@faust.lysator.liu.se> <CAPOJ94Nt8tinr8hGeR-=rWZS0a529kY38NU-yo6BYM6kVo7czg@mail.gmail.com>
 <20140119192238.GA19497@faust.lysator.liu.se> <60842af6-5ec4-4364-b2d5-a0be9d578bd6@isocpp.org>
 <6c82c4ae-c144-443a-81b2-ea1a6b645601@isocpp.org> <CAGg_6+NYK0pndHN1sUk9=Lzz2gda_c5Yb1R_MXHXEPudwM5TmA@mail.gmail.com>
 <CANh-dXk8xb3aWcSr7qG75hjSNAu5hQR0EopiELSTdDLF-OjXuw@mail.gmail.com> <CAGg_6+OHw8jAO_m0Sj1GxkiB__mxPXfMDVh7tEiZsparxqi1HA@mail.gmail.com>
 <CANh-dXmQ7eqpzJqeXQsoYxZ3L221OfxegPySmZ3V0o0rhMsT9w@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_699_2367907.1390223591514"
X-Trace: ger.gmane.org 1390223586 9639 80.91.229.3 (20 Jan 2014 13:13:06 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 20 Jan 2014 13:13:06 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDA3LUEAQACBB2GB6SLAKGQEHGHETKY@isocpp.org Mon Jan 20 14:13:14 2014
Return-path: <std-proposals+bncBDA3LUEAQACBB2GB6SLAKGQEHGHETKY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vc0-f197.google.com ([209.85.220.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDA3LUEAQACBB2GB6SLAKGQEHGHETKY@isocpp.org>)
	id 1W5EfC-0008Av-1g
	for gclcip-std-proposals@m.gmane.org; Mon, 20 Jan 2014 14:13:14 +0100
Original-Received: by mail-vc0-f197.google.com with SMTP id hq11sf11669966vcb.4
        for <gclcip-std-proposals@m.gmane.org>; Mon, 20 Jan 2014 05:13:13 -0800 (PST)
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:x-original-sender:reply-to:precedence
         :mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=N5foJTk/BKp6SjotVTWjkYYdkgWYHeUItoVOnVG4l18=;
        b=hyvYeFdTbCSqdBMdiYGzXMVg96cva/t4pc6m0owMv1bPMEPm/eqPVtdIFd0abGvaj7
         JbwMRkQdfwl/Rx4HcLKI0dchnEMbAyrO23hrWnx8OFQOgabAm3vwPHU86rbol5udIxlw
         OUNWLFnX1aFn7iiyJmohk0rLAgDKREuFQsgMmwMBXgyNRG+89qcbdotkfe86ayjbDI3A
         ZKxioig0kbPwN8k4SblcUdLP35snOLcgnwwskEDhYgmYF3T/c99/kiGGTU3BU48NhOck
         cvVibk6ySiUH3DqO+w3eaejvlPWumARnOUuiuSwDO1WFTAydZQDjHkaE1VK278ZK88kN
         cDmA==
X-Gm-Message-State: ALoCoQms0y58eTV9dlOS69PwmuKJHCtqB8USE22N7euVbiXwE52lyt9lw5cOH7LPrO6JgWNvagtP
X-Received: by 10.236.180.2 with SMTP id i2mr5342005yhm.4.1390223593043;
        Mon, 20 Jan 2014 05:13:13 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.19.165 with SMTP id g5ls919832obe.59.gmail; Mon, 20 Jan
 2014 05:13:12 -0800 (PST)
X-Received: by 10.182.73.228 with SMTP id o4mr5484obv.34.1390223592139;
        Mon, 20 Jan 2014 05:13:12 -0800 (PST)
In-Reply-To: <CANh-dXmQ7eqpzJqeXQsoYxZ3L221OfxegPySmZ3V0o0rhMsT9w@mail.gmail.com>
X-Original-Sender: bigotp@acm.org
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:8739
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/8739>

------=_Part_699_2367907.1390223591514
Content-Type: text/plain; charset=UTF-8



On Monday, January 20, 2014 1:36:00 AM UTC-6, Jeffrey Yasskin wrote:
>
> On Sun, Jan 19, 2014 at 10:25 PM, Nevin Liber <ne...@eviloverlord.com<javascript:>> 
> wrote: 
> > On 20 January 2014 00:12, Jeffrey Yasskin <jyas...@google.com<javascript:>> 
> wrote: 
> >> 
> >> > My personal preference for all this is that string_view(nullptr, 0) 
> be 
> >> > allowed, and it is a Quality of Implementation issue whether or not 
> >> > sv.data() can ever return a nullptr; i.e., it would be allowed to 
> return 
> >> > any 
> >> > legal pointer it wants for an empty string_view. 
> >> 
> >> That's interesting. It's easier to both specify and implement to just 
> >> say that string_view(x, y).data()==x and string_view(x, y).size()==y, 
> >> assuming [x, x+y) is a valid range. Why would you special-case data() 
> >> to return arbitrary things when y==0? 
> > 
> > 
> > A debugging implementation may want to ensure that developers aren't 
> > dependent on "knowing" that a nullptr was passed in. 
>
> Thanks. I think I don't personally want that, but I've added your 
> reason to the "if we want data()==nullptr" section in the attached 
> draft. I plan to send this to Clark tomorrow (Monday) morning. 
>
 
I believe your alternative section also needs something like:

In subclause "x.1 basic_string_view constructors and assignment operators 
[string.view.cons]" 

    basic_string_view(const charT* str);
    Requires: [str,str + traits::length(str)) is a valid range, or that str 
is a null pointer value

along with setting the size() to zero in the added case, if I'm correct in 
my understanding that traits::length(str) is undefined when str is null.

Peter

-- 

--- 
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/.

------=_Part_699_2367907.1390223591514
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Monday, January 20, 2014 1:36:00 AM UTC-6, Jeff=
rey Yasskin wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On Sun, Jan =
19, 2014 at 10:25 PM, Nevin Liber &lt;<a href=3D"javascript:" target=3D"_bl=
ank" gdf-obfuscated-mailto=3D"pimK0eE3_H0J" onmousedown=3D"this.href=3D'jav=
ascript:';return true;" onclick=3D"this.href=3D'javascript:';return true;">=
ne...@eviloverlord.com</a>&gt; wrote:
<br>&gt; On 20 January 2014 00:12, Jeffrey Yasskin &lt;<a href=3D"javascrip=
t:" target=3D"_blank" gdf-obfuscated-mailto=3D"pimK0eE3_H0J" onmousedown=3D=
"this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript=
:';return true;">jyas...@google.com</a>&gt; wrote:
<br>&gt;&gt;
<br>&gt;&gt; &gt; My personal preference for all this is that string_view(n=
ullptr, 0) be
<br>&gt;&gt; &gt; allowed, and it is a Quality of Implementation issue whet=
her or not
<br>&gt;&gt; &gt; sv.data() can ever return a nullptr; i.e., it would be al=
lowed to return
<br>&gt;&gt; &gt; any
<br>&gt;&gt; &gt; legal pointer it wants for an empty string_view.
<br>&gt;&gt;
<br>&gt;&gt; That's interesting. It's easier to both specify and implement =
to just
<br>&gt;&gt; say that string_view(x, y).data()=3D=3Dx and string_view(x, y)=
..size()=3D=3Dy,
<br>&gt;&gt; assuming [x, x+y) is a valid range. Why would you special-case=
 data()
<br>&gt;&gt; to return arbitrary things when y=3D=3D0?
<br>&gt;
<br>&gt;
<br>&gt; A debugging implementation may want to ensure that developers aren=
't
<br>&gt; dependent on "knowing" that a nullptr was passed in.
<br>
<br>Thanks. I think I don't personally want that, but I've added your
<br>reason to the "if we want data()=3D=3Dnullptr" section in the attached
<br>draft. I plan to send this to Clark tomorrow (Monday) morning.
<br></blockquote><div>&nbsp;<br>I believe your alternative section also nee=
ds something like:<br><br>In subclause "x.1 basic_string_view constructors =
and assignment operators [string.view.cons]" <br><br>&nbsp;&nbsp;&nbsp; bas=
ic_string_view(const charT* str);<br>&nbsp;&nbsp;&nbsp; Requires: [str,str =
+ traits::length(str)) is a valid range, or that str is a null pointer valu=
e<br><br>along with setting the size() to zero in the added case, if I'm co=
rrect in my understanding that traits::length(str) is undefined when str is=
 null.<br><br>Peter<br></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 />

------=_Part_699_2367907.1390223591514--

.
