220 35104 <CAGg_6+O6VhTD2vJoLVDONbbfw5EdSU5CW4D_KCdEvPT2V0DGrA@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Nevin Liber <nevin@eviloverlord.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Marking more std::string_view members noexcept
Date: Wed, 25 Oct 2017 19:17:01 -0500
Lines: 109
Approved: news@gmane.org
Message-ID: <CAGg_6+O6VhTD2vJoLVDONbbfw5EdSU5CW4D_KCdEvPT2V0DGrA@mail.gmail.com>
References: <3d03cd7d-2177-98fd-408d-f74b1f6a8552@gmail.com>
 <79ff7517-9d44-4770-8124-a2a036a2e6be@isocpp.org> <CAGg_6+Pv2BYcxMJ5aQ9uLb2qpgVZ3ThFjoWdKBNyZ4oNPm0A-A@mail.gmail.com>
 <5949784.ta64GYsRuq@tjmaciei-mobl1>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="001a114159eec1cb92055c68194b"
X-Trace: blaine.gmane.org 1508977072 15335 195.159.176.226 (26 Oct 2017 00:17:52 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 26 Oct 2017 00:17:52 +0000 (UTC)
To: "std-proposals@isocpp.org" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCE35H5S6IDBBJ6TYTHQKGQEX6JPKKA@isocpp.org Thu Oct 26 02:17:46 2017
Return-path: <std-proposals+bncBCE35H5S6IDBBJ6TYTHQKGQEX6JPKKA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vk0-f71.google.com ([209.85.213.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCE35H5S6IDBBJ6TYTHQKGQEX6JPKKA@isocpp.org>)
	id 1e7Vrd-0002C6-D1
	for gclcip-std-proposals@m.gmane.org; Thu, 26 Oct 2017 02:17:37 +0200
Original-Received: by mail-vk0-f71.google.com with SMTP id b7sf914581vkh.6
        for <gclcip-std-proposals@m.gmane.org>; Wed, 25 Oct 2017 17:17:44 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1508977064; cv=pass;
        d=google.com; s=arc-20160816;
        b=nLO1ZgWZRo6qHfhRa8cA30STEDoPZ7lacTuohJaMjx0d0NYxzH5Wx0+PxDo0NKSLzC
         m3L5itBk+I0FgYWUIMMq5yaOXrLLivWMXdOnv5DRaxPFRTLcGrGWaKLpI4agWWH5aMBx
         jOaM+3UElRc0DV8ewLhuqTozBUmALoSnVu/s5Gw+FeYEO5vegTGVVYisbrXTVHkp3CKV
         CN64UMvubX0aeVBOubirqENtJ+7wuFe/Q155ujPX7KEPerSoPZ0uRKSRLfDE28vZAANC
         46dWqRjDwQ9gAz2w2NDEo6rAI8/8PSOiBrrtaHmmxMMYlKTNfD1jHnIBBtUCJJW9FHKI
         5UIQ==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:references:in-reply-to:sender:mime-version
         :arc-authentication-results:arc-message-signature
         :arc-authentication-results;
        bh=wT54b6jxt3cKqVZdagwFCUfCxNzFCmOjTQR38rgc5kc=;
        b=g/rQMPrT2KagWEoLrft+AEIpfrAobqwIpGOHpWEtdj1m4/OjAbUdiDbj3/R5n7WvMN
         xx4hOwjLxhOtkSZCuReXC7JkMpqzGacwyxhVnq4T4pJSKVR5w6625rjyLzV32m5274I7
         baZ/Z/NXxt4J1pjfPZFlOy+KxP1Y8x0bAs+4c8XE22E9L39s1EOV5G6lqHqGm19Z3lFr
         PTjxOUXoHKedVQ+AK3/ULm8GOMKai3VnyA9k47SAfL73sCiDqW48pE0x44EE2eh1zWa8
         c+pTfq0LLSIpv7yIxmp0Qu0EdJb6AHfBM7r58MRNZw3N4xe4oV+skJih7yYYamRMpkuV
         tWAA==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=X9X8rFef;
       spf=pass (google.com: domain of nliber@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=nliber@gmail.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        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:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=wT54b6jxt3cKqVZdagwFCUfCxNzFCmOjTQR38rgc5kc=;
        b=riumMTp9T/SDodqy8Bl/B+vvJEJU9Pb3ALGbfPygIGJ+i34hiECqUwfmxEZM6EWXlV
         1h+UumttBS10vTMgGqvxrQz4WHHTHNLbOWaK8Mi8dN88mgt0wW5pXNqNODWu4JpzHhA8
         PdSCvuBG6GQTiiqAxoLgl6r9Xbi9ls5gPmc4iGwF3FEaXHBTStfaGOTVCOoXPD57TSle
         kjGL4Dw3aDrPUdhwLlIVp7aMq/CUmMId9zCS7ia7v39UHDyN/k8lrBH6sbQ9und3YpGQ
         syukKceTPfZYeRPJppCOFiX8eCCidhIYbVrWfoKOKfKUpuoy/H4TMS/sKiUZDfbzELMG
         Hvkg==
X-Gm-Message-State: AMCzsaU4kYud7nsvLyNg/ZyW6PhFBQUCISPVdggDmY8lI1nK2lTMb5b8
	7wdhD/xXdQ6vMuOE6L6L05A=
X-Google-Smtp-Source: ABhQp+QJc/jV/Jt2amHm5EaScpe4M+5EMOskUAE0HmETkMA4BnqVCuda5rVnj72AuMmerURaEj/QNw==
X-Received: by 10.176.81.58 with SMTP id e55mr2101725uaa.121.1508977064336;
        Wed, 25 Oct 2017 17:17:44 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.31.115.6 with SMTP id o6ls1032747vkc.14.gmail; Wed, 25 Oct
 2017 17:17:42 -0700 (PDT)
X-Received: by 10.176.87.217 with SMTP id u25mr3181141uac.4.1508977062904;
        Wed, 25 Oct 2017 17:17:42 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1508977062; cv=none;
        d=google.com; s=arc-20160816;
        b=zZOnzvcEpNZGvSh8orI6LJRo6g95W0g3yK7KKhuBBAeP4T6H0ys3X7hEuTYZF5gDS+
         aEW9RWYUtIkK7zbeYDTbVqj6XEl8I0aSP4rCFXavvkLcxfHyOlDO75VaCSSfthL7Hfi+
         mTMdW0crox1Zz+90fh7d2V7fUGSHKrq5My5Lauh1pn51BcGijBkiUwMnrD/uJ5hSy27U
         oa2VwKYBDn70dLqHspc4MbXNqG01E57rYUdYSdMCt+DyTwhJ7m2AYBuxRhAbJPU3SojY
         2heLKIaXnWSBr2+7CmqEDEqJ2PPe63XT5jgiEA1/erpogbC51Jli2nCiWvaPWaS4F5eP
         XBEw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:references:in-reply-to:sender
         :mime-version:dkim-signature:arc-authentication-results;
        bh=Ril+Gox5A0MEriVXxAVvSLj/185vsoijK2LBXiL4h4w=;
        b=lrmxqFIcQCJM/dg9Y54lrjYjS+/ZEy177dnpvgxPulnDUXoScVqPoH4hr9x6FoP89H
         ibZfU+WYCuqTDnzXeMYYu3VokD3oe62/PHv86c/F6W/h9E84iUc0WJVftLUA3QT2SPM1
         WZGc6/KLJaP3/5N4GMg2DF06bdtf+pY+ZgR6nwRT8rg6PBhCGjODmjk1J44CQLpULBlB
         xHvT1TYSHt0GqUqy7KSY7YGILqPuGOCWD0PbD2orBHe8Ix7smRFo4NzgCJvCFTyktmla
         4K5VYKQyfZk2TDRKNfDMyzyaxgav8Ad1JeQFrodZDoUwfDpVV6FjDV0X7NLVSmEymsV/
         +fLQ==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=X9X8rFef;
       spf=pass (google.com: domain of nliber@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=nliber@gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id f197sor1674881vkf.107.2017.10.25.17.17.42
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Wed, 25 Oct 2017 17:17:42 -0700 (PDT)
Received-SPF: pass (google.com: domain of nliber@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 10.31.167.151 with SMTP id q145mr2596363vke.49.1508977062036;
 Wed, 25 Oct 2017 17:17:42 -0700 (PDT)
Original-Sender: nliber@gmail.com
Original-Received: by 10.103.71.140 with HTTP; Wed, 25 Oct 2017 17:17:01 -0700 (PDT)
In-Reply-To: <5949784.ta64GYsRuq@tjmaciei-mobl1>
X-Original-Sender: nevin@eviloverlord.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=X9X8rFef;       spf=pass
 (google.com: domain of nliber@gmail.com designates 209.85.220.41 as permitted
 sender) smtp.mailfrom=nliber@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: <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:35104
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/35104>

--001a114159eec1cb92055c68194b
Content-Type: text/plain; charset="UTF-8"

On Wed, Oct 25, 2017 at 6:09 PM, Thiago Macieira <thiago@macieira.org>
wrote:

> > > template<size_t N>
> > > constexpr basic_string_view(const charT(&str)[N]) noexcept;
> >
> > It hasn't been proposed, has it?
> >
> > My guess would be no, since there is a precondition that str[N-1] == 0,
> > giving it a narrow contract.
>
> Why would it have such a precondition?
>

This constructor is unnecessary unless you want to differentiate between
C-string literals and raw pointers (which is a breaking change BTW).

The problem is, C-string literals are not represented in the type system.

The closest, and by no means is it perfect, is a const char(&str)[N] where
!str[N-1] holds.

Take the following:

string_view a("Hello");
const char s[] = { 'H', 'e', 'l', 'l', 'o' };
string_view b(s);
string_view c("Hello\0World");

Right now:

a.size() == 5;
b.size() // UB
c.size() == 5;

With this change, what should a.size(), b.size() and c.size() be?

Boost.Range has as_literal because you cannot in general deduce the intent
from the type alone.
-- 
 Nevin ":-)" Liber  <mailto:nevin@eviloverlord.com>  +1-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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGg_6%2BO6VhTD2vJoLVDONbbfw5EdSU5CW4D_KCdEvPT2V0DGrA%40mail.gmail.com.

--001a114159eec1cb92055c68194b
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wed, Oct 25, 2017 at 6:09 PM, Thiago Macieira <span dir=
=3D"ltr">&lt;<a href=3D"mailto:thiago@macieira.org" target=3D"_blank">thiag=
o@macieira.org</a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div cla=
ss=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 =
..8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=3D"">&gt; &gt=
; template&lt;size_t N&gt;<br>
&gt; &gt; constexpr basic_string_view(const charT(&amp;str)[N]) noexcept;<b=
r>
&gt;<br>
&gt; It hasn&#39;t been proposed, has it?<br>
&gt;<br>
&gt; My guess would be no, since there is a precondition that str[N-1] =3D=
=3D 0,<br>
&gt; giving it a narrow contract.<br>
<br>
</span>Why would it have such a precondition?<br></blockquote><div><br></di=
v><div>This constructor is unnecessary unless you want to differentiate bet=
ween C-string literals and raw pointers (which is a breaking change BTW).</=
div><div><br></div><div>The problem is, C-string literals are not represent=
ed in the type system.</div><div><br></div><div>The closest, and by no mean=
s is it perfect, is a const char(&amp;str)[N] where !str[N-1] holds.</div><=
div><br></div><div>Take the following:</div><div><br></div><div>string_view=
 a(&quot;Hello&quot;);</div><div>const char s[] =3D { &#39;H&#39;, &#39;e&#=
39;, &#39;l&#39;, &#39;l&#39;, &#39;o&#39; };</div><div>string_view b(s);</=
div><div>string_view c(&quot;Hello\0World&quot;);</div><div><br></div><div>=
Right now:</div><div><br></div><div>a.size() =3D=3D 5;</div><div>b.size() /=
/ UB</div><div>c.size() =3D=3D 5;</div><div><br></div><div>With this change=
, what should a.size(), b.size() and c.size() be?</div><div><br></div><div>=
Boost.Range has as_literal because you cannot in general deduce the intent =
from the type alone.</div></div>-- <br><div class=3D"gmail_signature" data-=
smartmail=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><div>=
=C2=A0Nevin &quot;:-)&quot; Liber=C2=A0 &lt;mailto:<a href=3D"mailto:nevin@=
eviloverlord.com" target=3D"_blank">nevin@eviloverlord.com</a>&gt; =C2=A0+1=
-847-691-1404</div></div></div></div></div>
</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/CAGg_6%2BO6VhTD2vJoLVDONbbfw5EdSU5CW4=
D_KCdEvPT2V0DGrA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGg_6%2BO6VhTD=
2vJoLVDONbbfw5EdSU5CW4D_KCdEvPT2V0DGrA%40mail.gmail.com</a>.<br />

--001a114159eec1cb92055c68194b--

.
