220 22101 <3696ecfa-9960-493d-94b7-b15390d0c396@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Evan Teran <evan.teran@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: string view constructed from iterator pair?
Date: Thu, 29 Oct 2015 10:07:42 -0700 (PDT)
Lines: 107
Approved: news@gmane.org
Message-ID: <3696ecfa-9960-493d-94b7-b15390d0c396@isocpp.org>
References: <476bb7a8-15ec-4f9c-a295-592495de3a86@isocpp.org>
 <CANh-dX=dC4HrWVNX9wgs1BB0J8MXUNJwExpL8x0x7ueZswHzuw@mail.gmail.com>
 <CADbh+eQ9yUyfrfJAVYp6R2fPDoCYCjor9xWpS0H4atc9W-95fQ@mail.gmail.com>
 <0fdef179-8304-40fb-bc94-48d908e779d0@isocpp.org>
 <5ee68d17-bb78-4bb7-8ff4-994f1016a0ad@isocpp.org>
 <CADbh+eTyxSzwfsAKpMQCathj1Nc8C1Jse=XAQXgG8BiyivjJ_Q@mail.gmail.com>
 <78099cf0-3d5a-4531-99e4-03ea92e83455@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_615_2098889785.1446138462540"
X-Trace: ger.gmane.org 1446138470 25577 80.91.229.3 (29 Oct 2015 17:07:50 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 29 Oct 2015 17:07:50 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCDNZQVEQMLRBX5EZGYQKGQEH6BWUVQ@isocpp.org Thu Oct 29 18:07:45 2015
Return-path: <std-proposals+bncBCDNZQVEQMLRBX5EZGYQKGQEH6BWUVQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vk0-f71.google.com ([209.85.213.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCDNZQVEQMLRBX5EZGYQKGQEH6BWUVQ@isocpp.org>)
	id 1Zrqfw-00018S-Dk
	for gclcip-std-proposals@m.gmane.org; Thu, 29 Oct 2015 18:07:44 +0100
Original-Received: by vkgy127 with SMTP id y127sf60928231vkg.2
        for <gclcip-std-proposals@m.gmane.org>; Thu, 29 Oct 2015 10:07:43 -0700 (PDT)
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=Mr2uwWMr9ggoVBQKlVwyeRxW8AvYM0WZshdXXQafZZ0=;
        b=ChwO9Vf2n9Wfxk7BqaZS3b34+vxlhtJzzmj8teNDBZBB+mdu6C98sIcPlNLN5clAoW
         tRvhQkiInFQxOyDwnDfiXDb94ffT1/67lI19EBA3YGNnSMR4MIH1UGLBeTdVGKtjUSRc
         LJZX7lLqsK+JwoQdeyPv8EmEhzUxGAUPvXQUzHVO+p5BtuWwfv4Wdsm2naOZf8Q3E0KS
         Y+nhj65JsaMtTPVKUWns1pqfROstKIaWEQk/j5jZLD4JjOfAMQCk7wl5ZT2XOi0gUY6N
         oT7sM57EIKdj7K+yHce/67yRt3NL7wJ/9pNIg8Nhk0ZonpsK1RYNlrcr95jeMQo2V5S8
         sRBg==
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=Mr2uwWMr9ggoVBQKlVwyeRxW8AvYM0WZshdXXQafZZ0=;
        b=gjmfntSMRZoJrJKnHYhgxSXxNb6hah0/pyeQTSxVcNzK9PDpMMP/D4oIg8P7l1xLnq
         +4TyXb7itjuc1e65pvvoBaluRbHRmsRPm7SJy/HWJu20YIJbhLMKuHTOQUsHMnHHJp5S
         jdg/8jcg7wB5LIrk20y5iaqBj5z1BTMOskB1G8ilT5kc659XF6DSgTJ1ViAzfXj9nQ0x
         oDWGHcBkgcTS/9HOTYJ1k7m9ByxM5SgTX8z1Kq7PfLQtBGuMXAlze8Q1/QSuymE/EeCk
         o8pMPr0irqDUaSR66/ytZZ8MgIYmZ+EFtg9K368eMXtDHsnFj1Xc9/INpbcZv3Z3bVuM
         PcIg==
X-Gm-Message-State: ALoCoQnd+uhLPvvumJ0CS0JYoxo4Eq4Lj8qbgm+LA0/JKakScI5tAE/IP+kxvDFmXW289jezFjy9
X-Received: by 10.129.82.193 with SMTP id g184mr2308287ywb.44.1446138463801;
        Thu, 29 Oct 2015 10:07:43 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.19.207 with SMTP id 76ls337869iot.4.gmail; Thu, 29 Oct
 2015 10:07:43 -0700 (PDT)
X-Received: by 10.50.131.196 with SMTP id oo4mr306393igb.5.1446138463026;
        Thu, 29 Oct 2015 10:07:43 -0700 (PDT)
In-Reply-To: <78099cf0-3d5a-4531-99e4-03ea92e83455@isocpp.org>
X-Original-Sender: evan.teran@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: <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: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:22101
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/22101>

------=_Part_615_2098889785.1446138462540
Content-Type: multipart/alternative; 
	boundary="----=_Part_616_1178035029.1446138462553"

------=_Part_616_1178035029.1446138462553
Content-Type: text/plain; charset=UTF-8


Fair enough. Regarding the contiguous and ordering issues, personally, I 
file them under the "give the function bad input, get UB" category, but I 
agree that it's a real concern. If too many inputs result in UB, then it's 
too easy to misuse or abuse. I think that is enough to make this a 
non-starter.

That being said, I actually like the "make_string_view" idea, which could 
have overloads for the various things that we know will work. I have 
another thought on string_views, but it's mostly unrelated, so I'll make 
that a separate post.

Thanks for the feedback.

On Thursday, October 29, 2015 at 12:54:29 PM UTC-4, Nicol Bolas wrote:
>
> On Thursday, October 29, 2015 at 12:24:33 PM UTC-4, Brent Friedman wrote:
>>
>> Evan,
>>
>> Yes that does address the issue I was raising. Of course, if strings and 
>> vectors used pointer iterators then we wouldn't need the if test or the 
>> overload at all.
>>
>
> Even if those two types use pointer iterators, that shouldn't mean that 
> contiguous iterators *ought* to be pointers. What about range adaptors? 
> Some of those can be contiguous iterators, but they're certainly not 
> pointers.
>
> Of course, you wouldn't be able to use range adaptors in string_views 
> either. They're more for template code. So there's another strike against 
> this overload. `string_view` is meant for arrays of characters, which in 
> C++ is specified by pointers.
>
> Ultimately, what you want isn't for std::string and std::vector iterators 
> to be pointers. You want them to be *convertible* to pointers (and 
> vice-versa).
>

-- 

--- 
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_616_1178035029.1446138462553
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><br></div>Fair enough. Regarding the contiguous and o=
rdering issues, personally, I file them under the &quot;give the function b=
ad input, get UB&quot; category, but I agree that it&#39;s a real concern. =
If too many inputs result in UB, then it&#39;s too easy to misuse or abuse.=
 I think that is enough to make this a non-starter.<div><br></div><div>That=
 being said, I actually like the &quot;make_string_view&quot; idea, which c=
ould have overloads for the various things that we know will work. I have a=
nother thought on string_views, but it&#39;s mostly unrelated, so I&#39;ll =
make that a separate post.</div><div><br></div><div>Thanks for the feedback=
..<br><br>On Thursday, October 29, 2015 at 12:54:29 PM UTC-4, Nicol Bolas wr=
ote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex=
;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">On Thursd=
ay, October 29, 2015 at 12:24:33 PM UTC-4, Brent Friedman wrote:<blockquote=
 class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px =
#ccc solid;padding-left:1ex"><div dir=3D"ltr">Evan,<div><br></div><div>Yes =
that does address the issue I was raising. Of course, if strings and vector=
s used pointer iterators then we wouldn&#39;t need the if test or the overl=
oad at all.</div></div></blockquote><div><br>Even if those two types use po=
inter iterators, that shouldn&#39;t mean that contiguous iterators <i>ought=
</i> to be pointers. What about range adaptors? Some of those can be contig=
uous iterators, but they&#39;re certainly not pointers.<br><br>Of course, y=
ou wouldn&#39;t be able to use range adaptors in string_views either. They&=
#39;re more for template code. So there&#39;s another strike against this o=
verload. `string_view` is meant for arrays of characters, which in C++ is s=
pecified by pointers.<br><br>Ultimately, what you want isn&#39;t for std::s=
tring and std::vector iterators to be pointers. You want them to be <i>conv=
ertible</i> to pointers (and vice-versa).</div></div></blockquote></div></d=
iv>

<p></p>

-- <br />
<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 <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 />
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_616_1178035029.1446138462553--
------=_Part_615_2098889785.1446138462540--

.
