Topic: string_view constructor that takes a slice of a std::string
Author: Evan Teran <evan.teran@gmail.com>
Date: Thu, 29 Oct 2015 10:20:03 -0700 (PDT)
Raw View
------=_Part_9265_1449888022.1446139203032
Content-Type: multipart/alternative;
boundary="----=_Part_9266_1682989032.1446139203032"
------=_Part_9266_1682989032.1446139203032
Content-Type: text/plain; charset=UTF-8
So, my thoughts on string_view is that it can be tremendously useful for
dealing with sub-strings without copying. I already have code which I think
will benefit greatly from this.
That being said, I was surprised to see that the basic_string_view
constructor has no direct means of being created to view a sub-string
directly. We have this:
template <class A>
basic_string_view(const basic_string<Ch, Tr, A> &str);
I think that it would be nice to have this as well:
template <class A>
basic_string_view(const basic_string<Ch, Tr, A> &str, size_type pos,
size_type count);
I would define this as:
Creates a basic_string_view as if by basic_string_view(basic_string_view(str).substr(pos,
count));
This way, creating a substring to pass to a function will be trivial and
clear. Of course, an equivalent but more invasive suggestion would be to
change std::basic_string::substr to return a basic_string_view. At first
glance, I think that wouldn't be a bad idea, since a basic_string_view is convertible to
a basic_string. Such a change may in fact "automagically" make some code
already out there more efficient. But there may be more nuance than that,
which I am missing.
Thoughts?
--
---
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_9266_1682989032.1446139203032
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">So, my thoughts on <font face=3D"courier new, monospace">s=
tring_view </font>is that it can be tremendously useful for dealing with su=
b-strings without copying. I already have code which I think will benefit g=
reatly from this.<div><br></div><div>That being said, I was surprised to se=
e that the <font face=3D"courier new, monospace">basic_string_view</font> c=
onstructor has no direct means of being created to view a sub-string direct=
ly. We have this:</div><div><br></div><div><font face=3D"courier new, monos=
pace">template <class A></font></div><div><font face=3D"courier new, =
monospace">basic_string_view(const basic_string<Ch, Tr, A> &str);=
</font></div><div><br></div><div>I think that it would be nice to have this=
as well:</div><div><br></div><div><div><font face=3D"courier new, monospac=
e">template <class A></font></div><div><font face=3D"courier new, mon=
ospace">basic_string_view(const basic_string<Ch, Tr, A> &str, siz=
e_type pos, size_type count);</font></div></div><div><font face=3D"arial, s=
ans-serif"><br></font></div><div><font face=3D"arial, sans-serif">I would d=
efine this as:</font></div><div><font face=3D"arial, sans-serif"><br></font=
></div><div><font face=3D"arial, sans-serif">Creates a </font><font face=3D=
"courier new, monospace">basic_string_view</font><font face=3D"arial, sans-=
serif"> as if by </font><font face=3D"courier new, monospace">basic_string_=
view(basic_string_view(str).substr(pos, count));</font></div><div><font fac=
e=3D"courier new, monospace"><br></font></div><div><font face=3D"arial, san=
s-serif">This way, creating a substring to pass to a function will be trivi=
al and clear. Of course, an equivalent but more invasive suggestion would b=
e to change </font><font face=3D"courier new, monospace">std::basic_string:=
:substr</font><font face=3D"arial, sans-serif"> to return a </font><font fa=
ce=3D"courier new, monospace">basic_string_view</font><font face=3D"arial, =
sans-serif">. At first glance, I think that wouldn't be a bad idea, sin=
ce a </font><font face=3D"courier new, monospace">basic_string_view </font>=
<font face=3D"arial, sans-serif">is=C2=A0convertible=C2=A0to a </font><font=
face=3D"courier new, monospace">basic_string</font><font face=3D"arial, sa=
ns-serif">. Such a change may in fact "automagically" make some c=
ode already out there more efficient. But there may be more nuance than tha=
t, which I am missing.</font></div><div><font face=3D"arial, sans-serif"><b=
r></font></div><div><font face=3D"arial, sans-serif">Thoughts?</font></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" 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_9266_1682989032.1446139203032--
------=_Part_9265_1449888022.1446139203032--
.
Author: Evan Teran <evan.teran@gmail.com>
Date: Thu, 29 Oct 2015 10:50:01 -0700 (PDT)
Raw View
------=_Part_609_1517185370.1446141001414
Content-Type: multipart/alternative;
boundary="----=_Part_610_462608495.1446141001415"
------=_Part_610_462608495.1446141001415
Content-Type: text/plain; charset=UTF-8
Minor improvement:
template <class A>
basic_string_view(const basic_string<Ch, Tr, A> &str, size_type pos,
size_type count = npos);
I didn't want to overload the existing basic_string constructor since this
one will do a little more work and may throw. But I see no harm in making count
default to npos since this overload will only be triggered if they specify
pos.
Additionally, I thought of a fairly good reason why we can't just make
basic_string::substr return a basic_string_view, it breaks any code which
looks like this:
std::string s = "whatever";
auto v = s.substr(s, e);
// any modifying operation on v here!
If v is a basic_string_view, won't compile. If it's a basic_string, it
will. Perhaps the simplest solution is to take a page from Qt and have a
different name for methods that return a view? (They have things like "
midRef" and similar).
Something like:
basic_string_view<Ch, Tr, A> basic_string<Ch, Tr, A>::substr_view(size_type
pos, size_type count = npos);
On Thursday, October 29, 2015 at 1:20:03 PM UTC-4, Evan Teran wrote:
>
> So, my thoughts on string_view is that it can be tremendously useful for
> dealing with sub-strings without copying. I already have code which I think
> will benefit greatly from this.
>
> That being said, I was surprised to see that the basic_string_view
> constructor has no direct means of being created to view a sub-string
> directly. We have this:
>
> template <class A>
> basic_string_view(const basic_string<Ch, Tr, A> &str);
>
> I think that it would be nice to have this as well:
>
> template <class A>
> basic_string_view(const basic_string<Ch, Tr, A> &str, size_type pos,
> size_type count);
>
> I would define this as:
>
> Creates a basic_string_view as if by basic_string_view(basic_string_view(str).substr(pos,
> count));
>
> This way, creating a substring to pass to a function will be trivial and
> clear. Of course, an equivalent but more invasive suggestion would be to
> change std::basic_string::substr to return a basic_string_view. At first
> glance, I think that wouldn't be a bad idea, since a basic_string_view is convertible to
> a basic_string. Such a change may in fact "automagically" make some code
> already out there more efficient. But there may be more nuance than that,
> which I am missing.
>
> Thoughts?
>
--
---
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_610_462608495.1446141001415
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Minor improvement:<div><br></div><div><div><font face=3D"c=
ourier new, monospace">template <class A></font></div><div><font face=
=3D"courier new, monospace">basic_string_view(const basic_string<Ch, Tr,=
A> &str, size_type pos, size_type count =3D npos);</font></div><div=
><font face=3D"courier new, monospace"><br></font></div><div><font face=3D"=
arial, sans-serif">I didn't want to overload the existing </font><font =
face=3D"courier new, monospace">basic_string </font><font face=3D"arial, sa=
ns-serif">constructor since this one will do a little more work and may thr=
ow. But I see no harm in making </font><font face=3D"courier new, monospace=
">count </font><font face=3D"arial, sans-serif">default to </font><font fac=
e=3D"courier new, monospace">npos </font><font face=3D"arial, sans-serif">s=
ince this overload will only be triggered if they specify </font><font face=
=3D"courier new, monospace">pos</font><font face=3D"arial, sans-serif">.</f=
ont></div><div><font face=3D"arial, sans-serif"><br></font></div><div><font=
face=3D"arial, sans-serif">Additionally, I thought of a fairly good reason=
why we can't just make </font><font face=3D"courier new, monospace">ba=
sic_string::substr</font><font face=3D"arial, sans-serif"> return a </font>=
<font face=3D"courier new, monospace">basic_string_view</font><font face=3D=
"arial, sans-serif">, it breaks any code which looks like this:</font></div=
><div><font face=3D"arial, sans-serif"><br></font></div><div><font face=3D"=
courier new, monospace">std::string s =3D "whatever";</font></div=
><div><font face=3D"courier new, monospace">auto v =3D s.substr(s, e);</fon=
t></div><div><font face=3D"courier new, monospace"><br></font></div><div><f=
ont face=3D"courier new, monospace">// any modifying operation on v here!</=
font></div><div><font face=3D"arial, sans-serif"><br></font></div><div><fon=
t face=3D"arial, sans-serif">If </font><font face=3D"courier new, monospace=
">v</font><font face=3D"arial, sans-serif"> is a </font><font face=3D"couri=
er new, monospace">basic_string_view</font><font face=3D"arial, sans-serif"=
>, won't compile. If it's a </font><font face=3D"courier new, monos=
pace">basic_string</font><font face=3D"arial, sans-serif">, it will.=C2=A0P=
erhaps=C2=A0the simplest solution is to take a page from Qt and have a diff=
erent name for methods that return a view? (They have things like "</f=
ont><font face=3D"courier new, monospace">midRef</font><font face=3D"arial,=
sans-serif">" and similar).</font></div><div><font face=3D"arial, san=
s-serif"><br></font></div><div><font face=3D"arial, sans-serif">Something l=
ike:</font></div><div><font face=3D"arial, sans-serif"><br></font></div><di=
v><font face=3D"courier new, monospace">basic_string_view<Ch, Tr, A> =
basic_string<Ch, Tr, A>::substr_view(size_type pos, size_type count =
=3D npos);</font></div><br>On Thursday, October 29, 2015 at 1:20:03 PM UTC-=
4, Evan Teran wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">So, my thoughts on <font face=3D"courier new, monospace">string_vi=
ew </font>is that it can be tremendously useful for dealing with sub-string=
s without copying. I already have code which I think will benefit greatly f=
rom this.<div><br></div><div>That being said, I was surprised to see that t=
he <font face=3D"courier new, monospace">basic_string_view</font> construct=
or has no direct means of being created to view a sub-string directly. We h=
ave this:</div><div><br></div><div><font face=3D"courier new, monospace">te=
mplate <class A></font></div><div><font face=3D"courier new, monospac=
e">basic_string_view(const basic_string<Ch, Tr, A> &str);</font><=
/div><div><br></div><div>I think that it would be nice to have this as well=
:</div><div><br></div><div><div><font face=3D"courier new, monospace">templ=
ate <class A></font></div><div><font face=3D"courier new, monospace">=
basic_string_view(const basic_string<Ch, Tr, A> &str, size_type p=
os, size_type count);</font></div></div><div><font face=3D"arial, sans-seri=
f"><br></font></div><div><font face=3D"arial, sans-serif">I would define th=
is as:</font></div><div><font face=3D"arial, sans-serif"><br></font></div><=
div><font face=3D"arial, sans-serif">Creates a </font><font face=3D"courier=
new, monospace">basic_string_view</font><font face=3D"arial, sans-serif"> =
as if by </font><font face=3D"courier new, monospace">basic_string_view(bas=
ic_<wbr>string_view(str).substr(pos, count));</font></div><div><font face=
=3D"courier new, monospace"><br></font></div><div><font face=3D"arial, sans=
-serif">This way, creating a substring to pass to a function will be trivia=
l and clear. Of course, an equivalent but more invasive suggestion would be=
to change </font><font face=3D"courier new, monospace">std::basic_string::=
substr</font><font face=3D"arial, sans-serif"> to return a </font><font fac=
e=3D"courier new, monospace">basic_string_view</font><font face=3D"arial, s=
ans-serif">. At first glance, I think that wouldn't be a bad idea, sinc=
e a </font><font face=3D"courier new, monospace">basic_string_view </font><=
font face=3D"arial, sans-serif">is=C2=A0convertible=C2=A0to a </font><font =
face=3D"courier new, monospace">basic_string</font><font face=3D"arial, san=
s-serif">. Such a change may in fact "automagically" make some co=
de already out there more efficient. But there may be more nuance than that=
, which I am missing.</font></div><div><font face=3D"arial, sans-serif"><br=
></font></div><div><font face=3D"arial, sans-serif">Thoughts?</font></div><=
/div></blockquote></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" 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_610_462608495.1446141001415--
------=_Part_609_1517185370.1446141001414--
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Thu, 29 Oct 2015 13:51:47 -0400
Raw View
--047d7b3a82900010e3052341f710
Content-Type: text/plain; charset=UTF-8
On Thu, Oct 29, 2015 at 1:20 PM, Evan Teran <evan.teran@gmail.com> wrote:
> So, my thoughts on string_view is that it can be tremendously useful for
> dealing with sub-strings without copying. I already have code which I think
> will benefit greatly from this.
>
> That being said, I was surprised to see that the basic_string_view
> constructor has no direct means of being created to view a sub-string
> directly. We have this:
>
> template <class A>
> basic_string_view(const basic_string<Ch, Tr, A> &str);
>
> I think that it would be nice to have this as well:
>
> template <class A>
> basic_string_view(const basic_string<Ch, Tr, A> &str, size_type pos,
> size_type count);
>
Looks completely reasonable.
>
> I would define this as:
>
> Creates a basic_string_view as if by basic_string_view(basic_string_view(str).substr(pos,
> count));
>
> This way, creating a substring to pass to a function will be trivial and
> clear. Of course, an equivalent but more invasive suggestion would be to
> change std::basic_string::substr to return a basic_string_view. At first
> glance, I think that wouldn't be a bad idea, since a basic_string_view is convertible to
> a basic_string. Such a change may in fact "automagically" make some code
> already out there more efficient. But there may be more nuance than that,
> which I am missing.
>
>
string str = "hello world";
auto s = str.substr(6, 5); // "world" (I think)
at this point in the code, I think I *own* the characters in s.
Don't change that.
Thoughts?
>
> --
>
> ---
> 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/.
>
--
---
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/.
--047d7b3a82900010e3052341f710
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Thu, Oct 29, 2015 at 1:20 PM, Evan Teran <span dir=3D"ltr"><<a hr=
ef=3D"mailto:evan.teran@gmail.com" target=3D"_blank">evan.teran@gmail.com</=
a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0=
0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">So,=
my thoughts on <font face=3D"courier new, monospace">string_view </font>is=
that it can be tremendously useful for dealing with sub-strings without co=
pying. I already have code which I think will benefit greatly from this.<di=
v><br></div><div>That being said, I was surprised to see that the <font fac=
e=3D"courier new, monospace">basic_string_view</font> constructor has no di=
rect means of being created to view a sub-string directly. We have this:</d=
iv><div><br></div><div><font face=3D"courier new, monospace">template <c=
lass A></font></div><div><font face=3D"courier new, monospace">basic_str=
ing_view(const basic_string<Ch, Tr, A> &str);</font></div><div><b=
r></div><div>I think that it would be nice to have this as well:</div><div>=
<br></div><div><div><font face=3D"courier new, monospace">template <clas=
s A></font></div><div><font face=3D"courier new, monospace">basic_string=
_view(const basic_string<Ch, Tr, A> &str, size_type pos, size_typ=
e count);</font></div></div></div></blockquote><div><br></div><div>Looks co=
mpletely reasonable.<br>=C2=A0<br></div><blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div=
dir=3D"ltr"><div><font face=3D"arial, sans-serif"><br></font></div><div><f=
ont face=3D"arial, sans-serif">I would define this as:</font></div><div><fo=
nt face=3D"arial, sans-serif"><br></font></div><div><font face=3D"arial, sa=
ns-serif">Creates a </font><font face=3D"courier new, monospace">basic_stri=
ng_view</font><font face=3D"arial, sans-serif"> as if by </font><font face=
=3D"courier new, monospace">basic_string_view(basic_string_view(str).substr=
(pos, count));</font></div><div><font face=3D"courier new, monospace"><br><=
/font></div><div><font face=3D"arial, sans-serif">This way, creating a subs=
tring to pass to a function will be trivial and clear. Of course, an equiva=
lent but more invasive suggestion would be to change </font><font face=3D"c=
ourier new, monospace">std::basic_string::substr</font><font face=3D"arial,=
sans-serif"> to return a </font><font face=3D"courier new, monospace">basi=
c_string_view</font><font face=3D"arial, sans-serif">. At first glance, I t=
hink that wouldn't be a bad idea, since a </font><font face=3D"courier =
new, monospace">basic_string_view </font><font face=3D"arial, sans-serif">i=
s=C2=A0convertible=C2=A0to a </font><font face=3D"courier new, monospace">b=
asic_string</font><font face=3D"arial, sans-serif">. Such a change may in f=
act "automagically" make some code already out there more efficie=
nt. But there may be more nuance than that, which I am missing.</font></div=
><div><font face=3D"arial, sans-serif"><br></font></div></div></blockquote>=
<div><br></div><div>string str =3D "hello world";<br></div><div>a=
uto s =3D=C2=A0 str.substr(6, 5); // "world" (I think)<br><br></d=
iv><div>at this point in the code, I think I *own* the characters in s.<br>=
</div><div>Don't change that.<br><br><br></div><blockquote class=3D"gma=
il_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-lef=
t:1ex"><div dir=3D"ltr"><div><font face=3D"arial, sans-serif"></font></div>=
<div><font face=3D"arial, sans-serif">Thoughts?</font></div></div><span cla=
ss=3D"HOEnZb"><font color=3D"#888888">
<p></p>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</font></span></blockquote></div><br></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" 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 />
--047d7b3a82900010e3052341f710--
.
Author: Evan Teran <evan.teran@gmail.com>
Date: Thu, 29 Oct 2015 11:06:26 -0700 (PDT)
Raw View
------=_Part_5409_1821698786.1446141986202
Content-Type: multipart/alternative;
boundary="----=_Part_5410_1544043736.1446141986210"
------=_Part_5410_1544043736.1446141986210
Content-Type: text/plain; charset=UTF-8
@Tony, right, that's exactly the case that I came up with (I think our
posts passed in the air) for why we shouldn't change basic_string::substr
On Thursday, October 29, 2015 at 1:51:51 PM UTC-4, Tony V E wrote:
>
>
>
> On Thu, Oct 29, 2015 at 1:20 PM, Evan Teran <evan....@gmail.com
> <javascript:>> wrote:
>
>> So, my thoughts on string_view is that it can be tremendously useful for
>> dealing with sub-strings without copying. I already have code which I think
>> will benefit greatly from this.
>>
>> That being said, I was surprised to see that the basic_string_view
>> constructor has no direct means of being created to view a sub-string
>> directly. We have this:
>>
>> template <class A>
>> basic_string_view(const basic_string<Ch, Tr, A> &str);
>>
>> I think that it would be nice to have this as well:
>>
>> template <class A>
>> basic_string_view(const basic_string<Ch, Tr, A> &str, size_type pos,
>> size_type count);
>>
>
> Looks completely reasonable.
>
>
>>
>> I would define this as:
>>
>> Creates a basic_string_view as if by basic_string_view(basic_string_view(str).substr(pos,
>> count));
>>
>> This way, creating a substring to pass to a function will be trivial and
>> clear. Of course, an equivalent but more invasive suggestion would be to
>> change std::basic_string::substr to return a basic_string_view. At first
>> glance, I think that wouldn't be a bad idea, since a basic_string_view is convertible to
>> a basic_string. Such a change may in fact "automagically" make some code
>> already out there more efficient. But there may be more nuance than that,
>> which I am missing.
>>
>>
> string str = "hello world";
> auto s = str.substr(6, 5); // "world" (I think)
>
> at this point in the code, I think I *own* the characters in s.
> Don't change that.
>
>
> Thoughts?
>>
>> --
>>
>> ---
>> 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-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> Visit this group at
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>
>
--
---
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_5410_1544043736.1446141986210
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">@Tony, right, that's exactly the case that I came up w=
ith (I think our posts passed in the air) for why we shouldn't change <=
font face=3D"courier new, monospace">basic_string::substr</font><br><br>On =
Thursday, October 29, 2015 at 1:51:51 PM UTC-4, Tony V E wrote:<blockquote =
class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1p=
x #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><br><div><br><div class=
=3D"gmail_quote">On Thu, Oct 29, 2015 at 1:20 PM, Evan Teran <span dir=3D"l=
tr"><<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
eDzIz4I-EwAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:&=
#39;;return true;" onclick=3D"this.href=3D'javascript:';return true=
;">evan....@gmail.com</a>></span> wrote:<br><blockquote class=3D"gmail_q=
uote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1e=
x"><div dir=3D"ltr">So, my thoughts on <font face=3D"courier new, monospace=
">string_view </font>is that it can be tremendously useful for dealing with=
sub-strings without copying. I already have code which I think will benefi=
t greatly from this.<div><br></div><div>That being said, I was surprised to=
see that the <font face=3D"courier new, monospace">basic_string_view</font=
> constructor has no direct means of being created to view a sub-string dir=
ectly. We have this:</div><div><br></div><div><font face=3D"courier new, mo=
nospace">template <class A></font></div><div><font face=3D"courier ne=
w, monospace">basic_string_view(const basic_string<Ch, Tr, A> &st=
r);</font></div><div><br></div><div>I think that it would be nice to have t=
his as well:</div><div><br></div><div><div><font face=3D"courier new, monos=
pace">template <class A></font></div><div><font face=3D"courier new, =
monospace">basic_string_view(const basic_string<Ch, Tr, A> &str, =
size_type pos, size_type count);</font></div></div></div></blockquote><div>=
<br></div><div>Looks completely reasonable.<br>=C2=A0<br></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><font face=3D"arial, sans-serif"><=
br></font></div><div><font face=3D"arial, sans-serif">I would define this a=
s:</font></div><div><font face=3D"arial, sans-serif"><br></font></div><div>=
<font face=3D"arial, sans-serif">Creates a </font><font face=3D"courier new=
, monospace">basic_string_view</font><font face=3D"arial, sans-serif"> as i=
f by </font><font face=3D"courier new, monospace">basic_string_view(basic_<=
wbr>string_view(str).substr(pos, count));</font></div><div><font face=3D"co=
urier new, monospace"><br></font></div><div><font face=3D"arial, sans-serif=
">This way, creating a substring to pass to a function will be trivial and =
clear. Of course, an equivalent but more invasive suggestion would be to ch=
ange </font><font face=3D"courier new, monospace">std::basic_string::substr=
</font><font face=3D"arial, sans-serif"> to return a </font><font face=3D"c=
ourier new, monospace">basic_string_view</font><font face=3D"arial, sans-se=
rif">. At first glance, I think that wouldn't be a bad idea, since a </=
font><font face=3D"courier new, monospace">basic_string_view </font><font f=
ace=3D"arial, sans-serif">is=C2=A0convertible=C2=A0to a </font><font face=
=3D"courier new, monospace">basic_string</font><font face=3D"arial, sans-se=
rif">. Such a change may in fact "automagically" make some code a=
lready out there more efficient. But there may be more nuance than that, wh=
ich I am missing.</font></div><div><font face=3D"arial, sans-serif"><br></f=
ont></div></div></blockquote><div><br></div><div>string str =3D "hello=
world";<br></div><div>auto s =3D=C2=A0 str.substr(6, 5); // "wor=
ld" (I think)<br><br></div><div>at this point in the code, I think I *=
own* the characters in s.<br></div><div>Don't change that.<br><br><br><=
/div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-le=
ft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><font face=3D"ari=
al, sans-serif"></font></div><div><font face=3D"arial, sans-serif">Thoughts=
?</font></div></div><span><font color=3D"#888888">
<p></p>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
eDzIz4I-EwAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:&=
#39;;return true;" onclick=3D"this.href=3D'javascript:';return true=
;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"eDzIz4I-EwAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'=
;javascript:';return true;">std-pr...@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=
=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';ret=
urn true;" onclick=3D"this.href=3D'http://groups.google.com/a/isocpp.or=
g/group/std-proposals/';return true;">http://groups.google.com/a/<wbr>i=
socpp.org/group/std-<wbr>proposals/</a>.<br>
</font></span></blockquote></div><br></div></div>
</blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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_5410_1544043736.1446141986210--
------=_Part_5409_1821698786.1446141986202--
.
Author: Zhihao Yuan <zy@miator.net>
Date: Thu, 29 Oct 2015 14:04:35 -0500
Raw View
On Thu, Oct 29, 2015 at 12:51 PM, Tony V E <tvaneerd@gmail.com> wrote:
>> I think that it would be nice to have this as well:
>>
>> template <class A>
>> basic_string_view(const basic_string<Ch, Tr, A> &str, size_type pos,
>> size_type count);
>
>
> Looks completely reasonable.
Yes. Please write an issue or a short paper.
--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://bit.ly/blog4bsd
--
---
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/.
.
Author: Evan Teran <evan.teran@gmail.com>
Date: Thu, 29 Oct 2015 13:24:10 -0700 (PDT)
Raw View
------=_Part_37_1247670481.1446150250958
Content-Type: multipart/alternative;
boundary="----=_Part_38_488366460.1446150250958"
------=_Part_38_488366460.1446150250958
Content-Type: text/plain; charset=UTF-8
Issue sent via email. I know this is a very small suggestion, but it would
be awesome if it actually got accepted :-)
On Thursday, October 29, 2015 at 3:06:50 PM UTC-4, Zhihao Yuan wrote:
>
> On Thu, Oct 29, 2015 at 12:51 PM, Tony V E <tvan...@gmail.com
> <javascript:>> wrote:
> >> I think that it would be nice to have this as well:
> >>
> >> template <class A>
> >> basic_string_view(const basic_string<Ch, Tr, A> &str, size_type pos,
> >> size_type count);
> >
> >
> > Looks completely reasonable.
>
> Yes. Please write an issue or a short paper.
>
> --
> Zhihao Yuan, ID lichray
> The best way to predict the future is to invent it.
> ___________________________________________________
> 4BSD -- http://bit.ly/blog4bsd
>
--
---
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_38_488366460.1446150250958
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><br></div>Issue sent via email. I know this is a very=
small suggestion, but it would be awesome if it actually got accepted :-)<=
br><br>On Thursday, October 29, 2015 at 3:06:50 PM UTC-4, Zhihao Yuan wrote=
:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bo=
rder-left: 1px #ccc solid;padding-left: 1ex;">On Thu, Oct 29, 2015 at 12:51=
PM, Tony V E <<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-=
mailto=3D"i-AbZppCEwAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'ja=
vascript:';return true;" onclick=3D"this.href=3D'javascript:';r=
eturn true;">tvan...@gmail.com</a>> wrote:
<br>>> I think that it would be nice to have this as well:
<br>>>
<br>>> template <class A>
<br>>> basic_string_view(const basic_string<Ch, Tr, A> &str=
, size_type pos,
<br>>> size_type count);
<br>>
<br>>
<br>> Looks completely reasonable.
<br>
<br>Yes. =C2=A0Please write an issue or a short paper.
<br>
<br>--=20
<br>Zhihao Yuan, ID lichray
<br>The best way to predict the future is to invent it.
<br>______________________________<wbr>_____________________
<br>4BSD -- <a href=3D"http://bit.ly/blog4bsd" target=3D"_blank" rel=3D"nof=
ollow" onmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%3=
A%2F%2Fbit.ly%2Fblog4bsd\46sa\75D\46sntz\0751\46usg\75AFQjCNENWZA3DF1H_gEgI=
kwnCr7FAkiCyQ';return true;" onclick=3D"this.href=3D'http://www.goo=
gle.com/url?q\75http%3A%2F%2Fbit.ly%2Fblog4bsd\46sa\75D\46sntz\0751\46usg\7=
5AFQjCNENWZA3DF1H_gEgIkwnCr7FAkiCyQ';return true;">http://bit.ly/blog4b=
sd</a>
<br></blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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_38_488366460.1446150250958--
------=_Part_37_1247670481.1446150250958--
.
Author: Olaf van der Spek <olafvdspek@gmail.com>
Date: Thu, 5 Nov 2015 08:00:46 -0800 (PST)
Raw View
------=_Part_197_1317871538.1446739246523
Content-Type: multipart/alternative;
boundary="----=_Part_198_1599689481.1446739246523"
------=_Part_198_1599689481.1446739246523
Content-Type: text/plain; charset=UTF-8
Wouldn't it be better to have a standalone function that does 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_198_1599689481.1446739246523
Content-Type: text/html; charset=UTF-8
<div dir="ltr">Wouldn't it be better to have a standalone function that does this?</div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href="mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />
------=_Part_198_1599689481.1446739246523--
------=_Part_197_1317871538.1446739246523--
.
Author: "'Jeffrey Yasskin' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Thu, 5 Nov 2015 09:12:34 -0800
Raw View
On Thu, Nov 5, 2015 at 8:00 AM, Olaf van der Spek <olafvdspek@gmail.com> wrote:
> Wouldn't it be better to have a standalone function that does this?
I believe you can already do it with string_view(string).substr(start,
end). I didn't think we needed any more magic numerical arguments when
I proposed string_view, so I didn't include the other constructors.
This may be less compelling now that the confusing .compare()
overloads are included.
--
---
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/.
.
Author: Olaf van der Spek <olafvdspek@gmail.com>
Date: Thu, 5 Nov 2015 18:50:23 +0100
Raw View
2015-11-05 18:12 GMT+01:00 'Jeffrey Yasskin' via ISO C++ Standard -
Future Proposals <std-proposals@isocpp.org>:
> On Thu, Nov 5, 2015 at 8:00 AM, Olaf van der Spek <olafvdspek@gmail.com> wrote:
>> Wouldn't it be better to have a standalone function that does this?
>
> I believe you can already do it with string_view(string).substr(start,
> end).
You can, but IMO a free function is better and shorter.
substr(string, start, len) // last par isn't end ;)
--
---
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/.
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Thu, 5 Nov 2015 10:34:55 -0800 (PST)
Raw View
------=_Part_1413_1676242808.1446748495509
Content-Type: multipart/alternative;
boundary="----=_Part_1414_1724139856.1446748495509"
------=_Part_1414_1724139856.1446748495509
Content-Type: text/plain; charset=UTF-8
On Thursday, November 5, 2015 at 12:50:25 PM UTC-5, Olaf van der Spek wrote:
>
> 2015-11-05 18:12 GMT+01:00 'Jeffrey Yasskin' via ISO C++ Standard -
> Future Proposals <std-pr...@isocpp.org <javascript:>>:
> > On Thu, Nov 5, 2015 at 8:00 AM, Olaf van der Spek <olafv...@gmail.com
> <javascript:>> wrote:
> >> Wouldn't it be better to have a standalone function that does this?
> >
> > I believe you can already do it with string_view(string).substr(start,
> > end).
>
> You can, but IMO a free function is better and shorter.
>
> substr(string, start, len) // last par isn't end ;)
>
Such a function should also allow `string` to be a `string_view`. For
orthogonality's sake.
--
---
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_1414_1724139856.1446748495509
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<br><br>On Thursday, November 5, 2015 at 12:50:25 PM UTC-5, Olaf van der Sp=
ek wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: =
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">2015-11-05 18:12 GMT+=
01:00 'Jeffrey Yasskin' via ISO C++ Standard -
<br>Future Proposals <<a href=3D"javascript:" target=3D"_blank" gdf-obfu=
scated-mailto=3D"RHBP6X5kFQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D=
'javascript:';return true;" onclick=3D"this.href=3D'javascript:=
';return true;">std-pr...@isocpp.org</a>>:
<br>> On Thu, Nov 5, 2015 at 8:00 AM, Olaf van der Spek <<a href=3D"j=
avascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"RHBP6X5kFQAJ" rel=3D=
"nofollow" onmousedown=3D"this.href=3D'javascript:';return true;" o=
nclick=3D"this.href=3D'javascript:';return true;">olafv...@gmail.co=
m</a>> wrote:
<br>>> Wouldn't it be better to have a standalone function that d=
oes this?
<br>>
<br>> I believe you can already do it with string_view(string).substr(<w=
br>start,
<br>> end).
<br>
<br>You can, but IMO a free function is better and shorter.
<br>
<br>substr(string, start, len) // last par isn't end ;)
<br></blockquote><div><br>Such a function should also allow `string` to be =
a `string_view`. For orthogonality's sake. <br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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_1414_1724139856.1446748495509--
------=_Part_1413_1676242808.1446748495509--
.
Author: Evan Teran <evan.teran@gmail.com>
Date: Thu, 5 Nov 2015 10:41:58 -0800 (PST)
Raw View
------=_Part_794_376786263.1446748918642
Content-Type: multipart/alternative;
boundary="----=_Part_795_608100008.1446748918642"
------=_Part_795_608100008.1446748918642
Content-Type: text/plain; charset=UTF-8
The free function you propose is a pretty good solution. However, one large
benefit (in my mind at least) of free functions is the overload
opportunities and ADL to customize it for user types. However, is usage of
basic_string_view in combination with custom string types really very
expected?
If so, then that benefit would not be particularly large.
On Thursday, November 5, 2015 at 12:50:25 PM UTC-5, Olaf van der Spek wrote:
>
> 2015-11-05 18:12 GMT+01:00 'Jeffrey Yasskin' via ISO C++ Standard -
> Future Proposals <std-pr...@isocpp.org <javascript:>>:
> > On Thu, Nov 5, 2015 at 8:00 AM, Olaf van der Spek <olafv...@gmail.com
> <javascript:>> wrote:
> >> Wouldn't it be better to have a standalone function that does this?
> >
> > I believe you can already do it with string_view(string).substr(start,
> > end).
>
> You can, but IMO a free function is better and shorter.
>
> substr(string, start, len) // last par isn't end ;)
>
--
---
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_795_608100008.1446748918642
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The free function you propose is a pretty good solution. H=
owever, one large benefit (in my mind at least) of free functions is the ov=
erload opportunities and ADL to customize it for user types. However, is us=
age of basic_string_view in combination with custom string types really ver=
y expected?<div><br></div><div>If so, then that benefit would not be partic=
ularly large.<br><br>On Thursday, November 5, 2015 at 12:50:25 PM UTC-5, Ol=
af van der Spek wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;=
margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">2015-11-=
05 18:12 GMT+01:00 'Jeffrey Yasskin' via ISO C++ Standard -
<br>Future Proposals <<a href=3D"javascript:" target=3D"_blank" gdf-obfu=
scated-mailto=3D"RHBP6X5kFQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D=
'javascript:';return true;" onclick=3D"this.href=3D'javascript:=
';return true;">std-pr...@isocpp.org</a>>:
<br>> On Thu, Nov 5, 2015 at 8:00 AM, Olaf van der Spek <<a href=3D"j=
avascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"RHBP6X5kFQAJ" rel=3D=
"nofollow" onmousedown=3D"this.href=3D'javascript:';return true;" o=
nclick=3D"this.href=3D'javascript:';return true;">olafv...@gmail.co=
m</a>> wrote:
<br>>> Wouldn't it be better to have a standalone function that d=
oes this?
<br>>
<br>> I believe you can already do it with string_view(string).substr(<w=
br>start,
<br>> end).
<br>
<br>You can, but IMO a free function is better and shorter.
<br>
<br>substr(string, start, len) // last par isn't end ;)
<br></blockquote></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" 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_795_608100008.1446748918642--
------=_Part_794_376786263.1446748918642--
.
Author: Olaf van der Spek <olafvdspek@gmail.com>
Date: Thu, 5 Nov 2015 20:00:57 +0100
Raw View
2015-11-05 19:34 GMT+01:00 Nicol Bolas <jmckesson@gmail.com>:
> Such a function should also allow `string` to be a `string_view`. For
> orthogonality's sake.
Eh, of course, that type is actually supposed to be string_view and NOT string.
--
Olaf
--
---
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/.
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Thu, 5 Nov 2015 11:01:10 -0800 (PST)
Raw View
------=_Part_1400_1202044122.1446750070565
Content-Type: multipart/alternative;
boundary="----=_Part_1401_1566163695.1446750070566"
------=_Part_1401_1566163695.1446750070566
Content-Type: text/plain; charset=UTF-8
On Thursday, November 5, 2015 at 1:41:59 PM UTC-5, Evan Teran wrote:
>
> The free function you propose is a pretty good solution. However, one
> large benefit (in my mind at least) of free functions is the overload
> opportunities and ADL to customize it for user types. However, is usage of
> basic_string_view in combination with custom string types really very
> expected?
>
> If so, then that benefit would not be particularly large.
>
Well, the whole point of string_view is that you can easily support any
contiguously allocated string type, while providing the same interface as
for std::string. So I would say being able to use basic_string_view with
custom string types is a crucial use case.
But it's one easily solved with this:
template<typename T>
requires(/*T be convertible to some instantiation of basic_string_view*/)
auto substr(const T t&, size_t pos, size_t len);
That way, all the user has to provide is the conversion to the
basic_string_view type of their choice.
--
---
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_1401_1566163695.1446750070566
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Thursday, November 5, 2015 at 1:41:59 PM UTC-5,=
Evan Teran wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"=
ltr">The free function you propose is a pretty good solution. However, one =
large benefit (in my mind at least) of free functions is the overload oppor=
tunities and ADL to customize it for user types. However, is usage of basic=
_string_view in combination with custom string types really very expected?<=
div><br></div><div>If so, then that benefit would not be particularly large=
..<br></div></div></blockquote><div><br>Well, the whole point of string_view=
is that you can easily support any=20
contiguously allocated string type, while providing the same interface=20
as for std::string. So I would say being able to use basic_string_view=20
with custom string types is a crucial use case.<br><br>But it's one eas=
ily solved with this:<br><br><div class=3D"prettyprint" style=3D"background=
-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style:=
solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">template</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">typename</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 requires</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #800;" class=3D"styled-by-prettify">/*T be =
convertible to some instantiation of basic_string_view*/</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> substr</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">const</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> T t</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">&,</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> size_t pos</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> s=
ize_t len</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)=
;</span></div></code></div><br>That way, all the user has to provide is the=
conversion to the basic_string_view type of their choice.</div><br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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_1401_1566163695.1446750070566--
------=_Part_1400_1202044122.1446750070565--
.