220 22082 <83f0d229-23f0-4930-85dd-7081f9e1eee1@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 07:24:27 -0700 (PDT)
Lines: 76
Approved: news@gmane.org
Message-ID: <83f0d229-23f0-4930-85dd-7081f9e1eee1@isocpp.org>
References: <476bb7a8-15ec-4f9c-a295-592495de3a86@isocpp.org>
 <CANh-dX=dC4HrWVNX9wgs1BB0J8MXUNJwExpL8x0x7ueZswHzuw@mail.gmail.com>
 <CADbh+eQ9yUyfrfJAVYp6R2fPDoCYCjor9xWpS0H4atc9W-95fQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_9124_267743453.1446128667816"
X-Trace: ger.gmane.org 1446128674 16031 80.91.229.3 (29 Oct 2015 14:24:34 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 29 Oct 2015 14:24:34 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCDNZQVEQMLRBHGYZCYQKGQEXURBNGY@isocpp.org Thu Oct 29 15:24:33 2015
Return-path: <std-proposals+bncBCDNZQVEQMLRBHGYZCYQKGQEXURBNGY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ig0-f199.google.com ([209.85.213.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCDNZQVEQMLRBHGYZCYQKGQEXURBNGY@isocpp.org>)
	id 1Zro7y-0007z9-33
	for gclcip-std-proposals@m.gmane.org; Thu, 29 Oct 2015 15:24:30 +0100
Original-Received: by igbhv6 with SMTP id hv6sf85538946igb.3
        for <gclcip-std-proposals@m.gmane.org>; Thu, 29 Oct 2015 07:24:29 -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=6Y4oFiya+G/edSAtrXFgPTV8b1D9DWV23I/v5I6DfZc=;
        b=e3LgYTeu0zS/NRQS5rqSBjJDa8aWE/i82+9ay2TaEoi0wDWZx6ytaAi7dg7s8nxUfY
         Ju3sdnyfupHJ8DDIBwVlVzAdoS0KLpdxFoB3VzEaKgd/K0N6o/o+D5n851CTl0PoIUOf
         IQ7vv9c9jZH17B32ZgYAthZ21CJTy+wO1IFTK0QT6IeHDuk1tVly93rXUoDxEGE+vips
         B7HG9zTBXHX3OEF0x0pDtADifK0cTnUe5K25m7zEJD5wptsctfKT0/0pAqxRlPNFuuu6
         R95USqUNdLcRk/6NotpWT9IYLDYUBWDV8ysRNBql5Kude8pArwb30jLQ8oHphoy5Manm
         N6Kw==
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=6Y4oFiya+G/edSAtrXFgPTV8b1D9DWV23I/v5I6DfZc=;
        b=OfJgmHkNEJMG6tXpHxqnRKJjTRQy1+XzPdYrYB0iIymWBc+YF5yFbRXrw4b4QKT8pn
         gXrXC5iJqj79QfI2VgJxxyQFiqOgFHX9NSLj65NI1Coq0HVsFdij7BOFEoSL28cgtcTK
         sDAI9kcMQ8+Yhr0pVXnFwLHA4lH9m+ypvU8PtlO/wQZTND9BU6xwDcqwqspQL9KnHRUM
         qwF5SqcZYlmau5zPwAlNFIPIEo/5+/kyujzgX6j8AJfrIW1eR6Xpfds68+Yn2zp2S/HS
         REMk/IEy81+S9bMw/Opbg6h2iD6Buuig/KbmMI7712Dv2ZFagwazZjHXakJxmQBq8eJD
         q36Q==
X-Gm-Message-State: ALoCoQkpNaHUgYpS+AaaYu4ckRX5gWC82sozUr7vCagwihfp0ZYVnFYlSrMtNRXvwuzufbLU6P7P
X-Received: by 10.107.136.19 with SMTP id k19mr2726105iod.5.1446128669146;
        Thu, 29 Oct 2015 07:24:29 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.61.101 with SMTP id o5ls265797igr.43.gmail; Thu, 29 Oct
 2015 07:24:28 -0700 (PDT)
X-Received: by 10.50.45.74 with SMTP id k10mr268417igm.0.1446128668328;
        Thu, 29 Oct 2015 07:24:28 -0700 (PDT)
In-Reply-To: <CADbh+eQ9yUyfrfJAVYp6R2fPDoCYCjor9xWpS0H4atc9W-95fQ@mail.gmail.com>
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:22082
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/22082>

------=_Part_9124_267743453.1446128667816
Content-Type: multipart/alternative; 
	boundary="----=_Part_9125_1730764730.1446128667816"

------=_Part_9125_1730764730.1446128667816
Content-Type: text/plain; charset=UTF-8


@Jeffery, that's a fair enough point. But could probably be addressed by 
saying "the result is undefined if the iterators are not part of the same 
contiguous sequence" or similar. There's lot of things in c++ that if you 
pas the wrong parameters, it is simply undefined. For example, just about 
every algorithm.

@Brent, another valid point, but easy enough to fix:

template <class Ran>
string_view(Ran first, Ran last) {
    if(first != last) {
        s_ = &*first;
        n_ = distance(first, last);
    } else {
        s_ = nullptr;
        n_ = 0;
    }
}

Both of these points are reasonable, but don't seem insurmountable. Anyway, 
thanks for quick thoughts on this.

-- 

--- 
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_9125_1730764730.1446128667816
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><br></div>@Jeffery, that&#39;s a fair enough point. B=
ut could probably be addressed by saying &quot;the result is undefined if t=
he iterators are not part of the same contiguous sequence&quot; or similar.=
 There&#39;s lot of things in c++ that if you pas the wrong parameters, it =
is simply undefined. For example, just about every algorithm.<div><br></div=
><div>@Brent, another valid point, but easy enough to fix:</div><div><br></=
div><div><div>template &lt;class Ran&gt;</div><div>string_view(Ran first, R=
an last) {</div><div>=C2=A0 =C2=A0 if(first !=3D last) {</div><div>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 s_ =3D &amp;*first;</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 n_ =3D distance(first, last);</div><div>=C2=A0 =C2=A0 } else {</div><di=
v>=C2=A0 =C2=A0 =C2=A0 =C2=A0 s_ =3D nullptr;</div><div>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 n_ =3D 0;</div><div>=C2=A0 =C2=A0 }</div><div>}</div></div><div>=
<br></div><div>Both of these points are reasonable, but don&#39;t seem insu=
rmountable. Anyway, thanks for quick thoughts on this.</div></div>

<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_9125_1730764730.1446128667816--
------=_Part_9124_267743453.1446128667816--

.
