220 30020 <CAFdMc-2Fgm3A2JjbERdCeFqDDFFTHhWFLPEr6Jw4uPp2dw1Pbg@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: "dgutson ." <danielgutson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: join/split for string & string_view
Date: Sun, 25 Dec 2016 13:20:48 -0300
Lines: 371
Approved: news@gmane.org
Message-ID: <CAFdMc-2Fgm3A2JjbERdCeFqDDFFTHhWFLPEr6Jw4uPp2dw1Pbg@mail.gmail.com>
References: <f609c0d3-c9ba-4a64-a99f-c2e64091b4e2@isocpp.org>
 <d8544b44-9ed4-403d-a980-6dda516933f6@isocpp.org> <172d08f0-a3da-4b9e-bfdd-985fb1f527c8@isocpp.org>
 <CAFdMc-07FWpV07b3WSz0U=uDNHXM19xgBTH=Cpt=Kvty4886FQ@mail.gmail.com> <CAFdMc-1sKQUs_ziOQwEZsOTLRDLrhjVSzLK_Jku27-XwkscQ+g@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=94eb2c0b1dde88c4c605447e007e
X-Trace: blaine.gmane.org 1482682860 26385 195.159.176.226 (25 Dec 2016 16:21:00 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 25 Dec 2016 16:21:00 +0000 (UTC)
To: std-proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDE3NBMV6UFBBYPD77BAKGQEXMCAUDA@isocpp.org Sun Dec 25 17:20:55 2016
Return-path: <std-proposals+bncBDE3NBMV6UFBBYPD77BAKGQEXMCAUDA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ua0-f198.google.com ([209.85.217.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDE3NBMV6UFBBYPD77BAKGQEXMCAUDA@isocpp.org>)
	id 1cLBXR-0005Dt-Jo
	for gclcip-std-proposals@m.gmane.org; Sun, 25 Dec 2016 17:20:45 +0100
Original-Received: by mail-ua0-f198.google.com with SMTP id i68sf128489562uad.3
        for <gclcip-std-proposals@m.gmane.org>; Sun, 25 Dec 2016 08:20:50 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version: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=7rHhc7n2gUfTDTm7V56mjcXuQE18mYCcglwiNgE/sQE=;
        b=v46JZHKvxthrMm7NybScQVHpMVGUbb8yq5ek4sKClC8dvHaSMEvmn7u4Z2WvofwlEg
         JtK+CcnX6IVhqw1BCqDiDoF2vi4hCedTl0+D/7Dzq1i1Eyf1gz6NMZWQt7zOw/p4DeQl
         Zp+vUtse1vNmwEM45TUG/E16XVOTRbMjVL3wQbDsbzIx4NjsFHRiSQi/LyraWqVqABJl
         BYbFLxaos0p3mqtVx++8RTuV3I+1xmZBm4kr/NQkr/jd7lK+YdYTFtIFY8z1qA1h689x
         ZOz/MciMKvKuguYksR/dOf9pt4hYw8D19JCwb2/f7dqPDRi5rDzC+F7fS1T338LtIzNW
         GiSQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version: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=7rHhc7n2gUfTDTm7V56mjcXuQE18mYCcglwiNgE/sQE=;
        b=L8UsY4gmxlH4dTgtAP12yPkiZMWvL7NRiTOXRaIh4DeM22pZvPeWcXYgF7KSMZYisU
         hQ25LeNkzfBT19bCD/WojZxrwShtefkAPP7hqDHWjwq7S5MwtM/pCdjyyZgLOhNPjm8I
         l5bXFwpg5qs0ns3unjRAkrZSdo16TAbKgurpfZQg4h1bb1/rxDykbaDPH8V+dt2P8gMu
         vRmteccv6A3QwxYAJTNExIxkCCKVMbgGhDQ77DvVS98RPxGN7zfH2AuI5EGfHC3FD2Vi
         dFZkmC8iWHgH8/0S5NOaKfg5cw3/AZctkg8wK2bX5Zvv4xeEFO/LPTMflIVGLCulv2Sa
         PJVQ==
X-Gm-Message-State: AIkVDXKyzlg1DPtNgLlXOlCaCezn23S5fhSrmBey0Ly0J+Y09w2W3OnFaw2z4Vfy6Nl9qw==
X-Received: by 10.159.53.7 with SMTP id o7mr11021019uao.26.1482682850284;
        Sun, 25 Dec 2016 08:20:50 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.36.124.208 with SMTP id a199ls6312937itd.5.gmail; Sun, 25 Dec
 2016 08:20:49 -0800 (PST)
X-Received: by 10.36.55.137 with SMTP id r131mr23262932itr.86.1482682849412;
        Sun, 25 Dec 2016 08:20:49 -0800 (PST)
Original-Received: from mail-it0-x22f.google.com (mail-it0-x22f.google.com. [2607:f8b0:4001:c0b::22f])
        by mx.google.com with ESMTPS id n67si8222535ith.5.2016.12.25.08.20.49
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Sun, 25 Dec 2016 08:20:49 -0800 (PST)
Received-SPF: pass (google.com: domain of danielgutson@gmail.com designates 2607:f8b0:4001:c0b::22f as permitted sender) client-ip=2607:f8b0:4001:c0b::22f;
Original-Received: by mail-it0-x22f.google.com with SMTP id o141so116352764itc.0
        for <std-proposals@isocpp.org>; Sun, 25 Dec 2016 08:20:49 -0800 (PST)
X-Received: by 10.36.252.65 with SMTP id b62mr21343426ith.38.1482682849076;
 Sun, 25 Dec 2016 08:20:49 -0800 (PST)
Original-Received: by 10.36.79.210 with HTTP; Sun, 25 Dec 2016 08:20:48 -0800 (PST)
Original-Received: by 10.36.79.210 with HTTP; Sun, 25 Dec 2016 08:20:48 -0800 (PST)
In-Reply-To: <CAFdMc-1sKQUs_ziOQwEZsOTLRDLrhjVSzLK_Jku27-XwkscQ+g@mail.gmail.com>
X-Original-Sender: danielgutson@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of
 danielgutson@gmail.com designates 2607:f8b0:4001:c0b::22f as permitted
 sender) smtp.mailfrom=danielgutson@gmail.com;       dmarc=pass (p=NONE
 dis=NONE) header.from=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:30020
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/30020>

--94eb2c0b1dde88c4c605447e007e
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

s/allocators/iterators/

El 25/12/2016 13:20, "dgutson ." <danielgutson@gmail.com> escribi=C3=B3:

>
>
> El 25/12/2016 13:17, "dgutson ." <danielgutson@gmail.com> escribi=C3=B3:
>
>
>
> El 25/12/2016 12:41, "Nicol Bolas" <jmckesson@gmail.com> escribi=C3=B3:
>
> On Sunday, December 25, 2016 at 5:32:44 AM UTC-5, lnal...@gmail.com wrote=
:
>>
>> Hello,
>>
>>
>> Most of modern language (D, Python, Java, C#, Go, Rust) got a split
>> method on their string type, so I think it really make sense to have
>> something similar in C++.
>>
>
> All of those languages also only have a single string type. C++ has
> *hundreds*. Even the *standard library* has 2, and that doens't even
> count `const char*`.
>
> Having a `split` function that can *only* be used with the standard
> library string types is pathetic. Especially when it could be made to be
> used with any string type (that provides a conversion to `string_view`)
> with ease.
>
> If you want to suggest that `basic_string` and `string_view` should have
> member versions that call the non-member algorithms, fine. But the
> non-member function is where the actual work happens.
>
>
>> All of them returns a 'vector' and I think is the main waited result.
>>
>
> No.
>
> While we should not be ignorant of what other languages are doing, we als=
o
> should not pretend that the design of other languages is a priori correct
> for C++. We should do what is best for C++.
>
> And one principle of C++ is that we do not make people pay for features
> they don't need to use. Forcing the return of a `vector` makes people pay
> for memory allocations that they may not use.
>
> I think it should not be required to mastering all subtilities of the STL
>> to do something a simple as that.
>>
>
> Master the subtleties of what? Of using a range? That should be an early
> lesson for C++ programmers; it's hardly deep metaprogramming magic.
>
> If you're going to be able to work in a language, you *need* to know its
> idioms. And ranges are very important idioms in C++. We shouldn't cater t=
o
> the demographic of people who learn just the syntax of a language and the=
n
> pretend that they know it.
>
> I think it should be possible to write :
>> auto MyResult=3D "my,csv,line"s.split(",");
>> myvar=3DMyResult[1];
>> for(auto sv : MyResult)
>>
>>
> Here is what that code would look like under the guidelines I (and others=
)
> outlined previously:
>
> vector MyResult(split("my,csv,line", ","));
> myvar =3D MyResult[1];
> for(auto sv : MyResult)
>
> See how simple that is? This only allocates memory in `vector`'s
> constructor (so you're not needlessly allocating a `basic_string`, just f=
or
> a string literal).
>
> Plus, if you just want the iteration, without the need for random access:
>
> for(auto sv : split("my,csv,line", ","))
>
> This performs *zero* memory allocations. Why *shouldn't* this be the
> default? In C++, the default ought to be fast, where possible.
>
>
> I think there should also be a callback-oriented version by providing a
> callable template argument (e.g. lambda, std::function, function ptr, etc=
)
> which requires no memory allocation.
>
>
>
> BTW, this should work with any container that provides allocators,
> containing any type equal-comparable:
>
> vector<int> v;
> split(v, 1, [](int x){});
>
>
>
>
> Perhaps having multiple (like for stoi,l,ll) could be an option
>>
>
> No. A single function returning a range, as outlined above, can cover all
> of these cases effectively.
>
> --
> 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/is
> ocpp.org/d/msgid/std-proposals/172d08f0-a3da-4b9e-bfdd-985fb
> 1f527c8%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/172d08f0-a3=
da-4b9e-bfdd-985fb1f527c8%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>
> .
>
>
>
>

--=20
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 e=
mail 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/CAFdMc-2Fgm3A2JjbERdCeFqDDFFTHhWFLPEr6Jw4uPp2dw1=
Pbg%40mail.gmail.com.

--94eb2c0b1dde88c4c605447e007e
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">s/allocators/iterators/</div><div class=3D"gmail_extra"><=
br><div class=3D"gmail_quote">El 25/12/2016 13:20, &quot;dgutson .&quot; &l=
t;<a href=3D"mailto:danielgutson@gmail.com">danielgutson@gmail.com</a>&gt; =
escribi=C3=B3:<br type=3D"attribution"><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div =
dir=3D"auto"><div><br><div class=3D"gmail_extra"><br><div class=3D"gmail_qu=
ote">El 25/12/2016 13:17, &quot;dgutson .&quot; &lt;<a href=3D"mailto:danie=
lgutson@gmail.com" target=3D"_blank">danielgutson@gmail.com</a>&gt; escribi=
=C3=B3:<br type=3D"attribution"><blockquote class=3D"m_8621554246912952581q=
uote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1e=
x"><div dir=3D"auto"><div class=3D"m_8621554246912952581elided-text"><div><=
br><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">El 25/12/2016 =
12:41, &quot;Nicol Bolas&quot; &lt;<a href=3D"mailto:jmckesson@gmail.com" t=
arget=3D"_blank">jmckesson@gmail.com</a>&gt; escribi=C3=B3:<br type=3D"attr=
ibution"><blockquote class=3D"m_8621554246912952581m_4043976793822217728quo=
te" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"=
><div dir=3D"ltr"><div class=3D"m_8621554246912952581m_4043976793822217728q=
uoted-text">On Sunday, December 25, 2016 at 5:32:44 AM UTC-5, <a href=3D"ma=
ilto:lnal...@gmail.com" target=3D"_blank">lnal...@gmail.com</a> wrote:<bloc=
kquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-lef=
t:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><p>Hello,</p><p><br>Mos=
t of modern language (D, Python, Java, C#, Go, Rust) got a split=20
method on their string type, so I think it really make sense to have someth=
ing=20
similar in C++.<br></p></div></blockquote></div><div><br>All of those langu=
ages also only have a single string type. C++ has <i>hundreds</i>. Even the=
 <i>standard library</i> has 2, and that doens&#39;t even count `const char=
*`.<br><br>Having a `split` function that can <i>only</i> be used with the =
standard library string types is pathetic. Especially when it could be made=
 to be used with any string type (that provides a conversion to `string_vie=
w`) with ease.<br><br>If you want to suggest that `basic_string` and `strin=
g_view` should have member versions that call the non-member algorithms, fi=
ne. But the non-member function is where the actual work happens.<br>=C2=A0=
</div><div class=3D"m_8621554246912952581m_4043976793822217728quoted-text">=
<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;borde=
r-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><p>All of them ret=
urns a &#39;vector&#39; and I think is the main waited=20
result.</p></div></blockquote></div><div><br>No.<br><br>While we should not=
 be ignorant of what other languages are doing, we also should not pretend =
that the design of other languages is a priori correct for C++. We should d=
o what is best for C++.<br><br>And one principle of C++ is that we do not m=
ake people pay for features they don&#39;t need to use. Forcing the return =
of a `vector` makes people pay for memory allocations that they may not use=
..<br><br></div><div class=3D"m_8621554246912952581m_4043976793822217728quot=
ed-text"><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"><p>I thin=
k it should=20
not be required to mastering all subtilities of the STL to do something a s=
imple=20
as that.</p></div></blockquote></div><div><br>Master the subtleties of what=
? Of using a range? That should be an early lesson for C++ programmers; it&=
#39;s hardly deep metaprogramming magic.<br><br>If you&#39;re going to be a=
ble to work in a language, you <i>need</i> to know its idioms. And ranges a=
re very important idioms in C++. We shouldn&#39;t cater to the demographic =
of people who learn just the syntax of a language and then pretend that the=
y know it.<br><br></div><div class=3D"m_8621554246912952581m_40439767938222=
17728quoted-text"><blockquote class=3D"gmail_quote" style=3D"margin:0;margi=
n-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">
<p>I think it should be possible to write :</p>
<div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,18=
7);border-style:solid;border-width:1px;word-wrap:break-word"><code><div><sp=
an style=3D"color:#008">auto</span><span style=3D"color:#000"> </span><span=
 style=3D"color:#606">MyResult</span><span style=3D"color:#660">=3D</span><=
span style=3D"color:#000"> </span><span style=3D"color:#080">&quot;my,csv,l=
ine&quot;</span><span style=3D"color:#000">s</span><span style=3D"color:#66=
0">.</span><span style=3D"color:#000">split</span><span style=3D"color:#660=
">(</span><span style=3D"color:#080">&quot;,&quot;</span><span style=3D"col=
or:#660">);</span><span style=3D"color:#000"><br>myvar</span><span style=3D=
"color:#660">=3D</span><span style=3D"color:#606">MyResult</span><span styl=
e=3D"color:#660">[</span><span style=3D"color:#066">1</span><span style=3D"=
color:#660">];</span><span style=3D"color:#000"> <br></span><span style=3D"=
color:#008">for</span><span style=3D"color:#660">(</span><span style=3D"col=
or:#008">auto</span><span style=3D"color:#000"> sv </span><span style=3D"co=
lor:#660">:</span><span style=3D"color:#000"> </span><span style=3D"color:#=
606">MyResult</span><span style=3D"color:#660">)</span><span style=3D"color=
:#000"> <br></span></div></code></div><p></p></div></blockquote></div><div>=
<br>Here is what that code would look like under the guidelines I (and othe=
rs) outlined previously:<br><br><div style=3D"background-color:rgb(250,250,=
250);border-color:rgb(187,187,187);border-style:solid;border-width:1px" cla=
ss=3D"m_8621554246912952581m_4043976793822217728m_6587239836056522751pretty=
print"><code class=3D"m_8621554246912952581m_4043976793822217728m_658723983=
6056522751prettyprint"><div class=3D"m_8621554246912952581m_404397679382221=
7728m_6587239836056522751subprettyprint"><span style=3D"color:#000" class=
=3D"m_8621554246912952581m_4043976793822217728m_6587239836056522751styled-b=
y-prettify">vector </span><span style=3D"color:#606" class=3D"m_86215542469=
12952581m_4043976793822217728m_6587239836056522751styled-by-prettify">MyRes=
ult</span><span style=3D"color:#660" class=3D"m_8621554246912952581m_404397=
6793822217728m_6587239836056522751styled-by-prettify">(</span><span style=
=3D"color:#000" class=3D"m_8621554246912952581m_4043976793822217728m_658723=
9836056522751styled-by-prettify">split</span><span style=3D"color:#660" cla=
ss=3D"m_8621554246912952581m_4043976793822217728m_6587239836056522751styled=
-by-prettify">(</span><span style=3D"color:#080" class=3D"m_862155424691295=
2581m_4043976793822217728m_6587239836056522751styled-by-prettify">&quot;my,=
csv,line&quot;</span><span style=3D"color:#660" class=3D"m_8621554246912952=
581m_4043976793822217728m_6587239836056522751styled-by-prettify">,</span><s=
pan style=3D"color:#000" class=3D"m_8621554246912952581m_404397679382221772=
8m_6587239836056522751styled-by-prettify"> </span><span style=3D"color:#080=
" class=3D"m_8621554246912952581m_4043976793822217728m_6587239836056522751s=
tyled-by-prettify">&quot;,&quot;</span><span style=3D"color:#660" class=3D"=
m_8621554246912952581m_4043976793822217728m_6587239836056522751styled-by-pr=
ettify">));</span><span style=3D"color:#000" class=3D"m_8621554246912952581=
m_4043976793822217728m_6587239836056522751styled-by-prettify"><br>myvar </s=
pan><span style=3D"color:#660" class=3D"m_8621554246912952581m_404397679382=
2217728m_6587239836056522751styled-by-prettify">=3D</span><span style=3D"co=
lor:#000" class=3D"m_8621554246912952581m_4043976793822217728m_658723983605=
6522751styled-by-prettify"> </span><span style=3D"color:#606" class=3D"m_86=
21554246912952581m_4043976793822217728m_6587239836056522751styled-by-pretti=
fy">MyResult</span><span style=3D"color:#660" class=3D"m_862155424691295258=
1m_4043976793822217728m_6587239836056522751styled-by-prettify">[</span><spa=
n style=3D"color:#066" class=3D"m_8621554246912952581m_4043976793822217728m=
_6587239836056522751styled-by-prettify">1</span><span style=3D"color:#660" =
class=3D"m_8621554246912952581m_4043976793822217728m_6587239836056522751sty=
led-by-prettify">];</span><span style=3D"color:#000" class=3D"m_86215542469=
12952581m_4043976793822217728m_6587239836056522751styled-by-prettify"><br><=
/span><span style=3D"color:#008" class=3D"m_8621554246912952581m_4043976793=
822217728m_6587239836056522751styled-by-prettify">for</span><span style=3D"=
color:#660" class=3D"m_8621554246912952581m_4043976793822217728m_6587239836=
056522751styled-by-prettify">(</span><span style=3D"color:#008" class=3D"m_=
8621554246912952581m_4043976793822217728m_6587239836056522751styled-by-pret=
tify">auto</span><span style=3D"color:#000" class=3D"m_8621554246912952581m=
_4043976793822217728m_6587239836056522751styled-by-prettify"> sv </span><sp=
an style=3D"color:#660" class=3D"m_8621554246912952581m_4043976793822217728=
m_6587239836056522751styled-by-prettify">:</span><span style=3D"color:#000"=
 class=3D"m_8621554246912952581m_4043976793822217728m_6587239836056522751st=
yled-by-prettify"> </span><span style=3D"color:#606" class=3D"m_86215542469=
12952581m_4043976793822217728m_6587239836056522751styled-by-prettify">MyRes=
ult</span><span style=3D"color:#660" class=3D"m_8621554246912952581m_404397=
6793822217728m_6587239836056522751styled-by-prettify">)</span></div></code>=
</div><br>See how simple that is? This only allocates memory in `vector`&#3=
9;s constructor (so you&#39;re not needlessly allocating a `basic_string`, =
just for a string literal).<br><br>Plus, if you just want the iteration, wi=
thout the need for random access:<br><br><div style=3D"background-color:rgb=
(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-width=
:1px" class=3D"m_8621554246912952581m_4043976793822217728m_6587239836056522=
751prettyprint"><code class=3D"m_8621554246912952581m_4043976793822217728m_=
6587239836056522751prettyprint"><div class=3D"m_8621554246912952581m_404397=
6793822217728m_6587239836056522751subprettyprint"><span style=3D"color:#008=
" class=3D"m_8621554246912952581m_4043976793822217728m_6587239836056522751s=
tyled-by-prettify">for</span><span style=3D"color:#660" class=3D"m_86215542=
46912952581m_4043976793822217728m_6587239836056522751styled-by-prettify">(<=
/span><span style=3D"color:#008" class=3D"m_8621554246912952581m_4043976793=
822217728m_6587239836056522751styled-by-prettify">auto</span><span style=3D=
"color:#000" class=3D"m_8621554246912952581m_4043976793822217728m_658723983=
6056522751styled-by-prettify"> sv </span><span style=3D"color:#660" class=
=3D"m_8621554246912952581m_4043976793822217728m_6587239836056522751styled-b=
y-prettify">:</span><span style=3D"color:#000" class=3D"m_86215542469129525=
81m_4043976793822217728m_6587239836056522751styled-by-prettify"> split</spa=
n><span style=3D"color:#660" class=3D"m_8621554246912952581m_40439767938222=
17728m_6587239836056522751styled-by-prettify">(</span><span style=3D"color:=
#080" class=3D"m_8621554246912952581m_4043976793822217728m_6587239836056522=
751styled-by-prettify">&quot;my,csv,line&quot;</span><span style=3D"color:#=
660" class=3D"m_8621554246912952581m_4043976793822217728m_65872398360565227=
51styled-by-prettify">,</span><span style=3D"color:#000" class=3D"m_8621554=
246912952581m_4043976793822217728m_6587239836056522751styled-by-prettify"> =
</span><span style=3D"color:#080" class=3D"m_8621554246912952581m_404397679=
3822217728m_6587239836056522751styled-by-prettify">&quot;,&quot;</span><spa=
n style=3D"color:#660" class=3D"m_8621554246912952581m_4043976793822217728m=
_6587239836056522751styled-by-prettify">))</span></div></code></div><br>Thi=
s performs <i>zero</i> memory allocations. Why <i>shouldn&#39;t</i> this be=
 the default? In C++, the default ought to be fast, where possible.<br></di=
v></div></blockquote></div></div></div><div dir=3D"auto"><br></div></div><d=
iv dir=3D"auto">I think there should also be a callback-oriented version by=
 providing a callable template argument (e.g. lambda, std::function, functi=
on ptr, etc) which requires no memory allocation.</div></div></blockquote><=
/div></div></div><div dir=3D"auto"><br></div><div dir=3D"auto"><br></div><d=
iv dir=3D"auto">BTW, this should work with any container that provides allo=
cators, containing any type equal-comparable:</div><div dir=3D"auto"><br></=
div><div dir=3D"auto">vector&lt;int&gt; v;</div><div dir=3D"auto">split(v, =
1, [](int x){});</div><div dir=3D"auto"><div class=3D"gmail_extra"><div cla=
ss=3D"gmail_quote"><blockquote class=3D"m_8621554246912952581quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=
=3D"auto"><div class=3D"m_8621554246912952581quoted-text"><div dir=3D"auto"=
><br></div><div dir=3D"auto"><br></div><div dir=3D"auto"><div class=3D"gmai=
l_extra"><div class=3D"gmail_quote"><blockquote class=3D"m_8621554246912952=
581m_4043976793822217728quote" style=3D"margin:0 0 0 .8ex;border-left:1px #=
ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><br></div><div class=3D"m=
_8621554246912952581m_4043976793822217728quoted-text"><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">
<p></p><p>Perhaps having multiple (like for stoi,l,ll) could be an option</=
p></div></blockquote></div><div><br>No. A single function returning a range=
, as outlined above, can cover all of these cases effectively.<br></div></d=
iv><div class=3D"m_8621554246912952581m_4043976793822217728quoted-text">

<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" target=3D"_=
blank">std-proposals+unsubscribe@isoc<wbr>pp.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></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/172d08f0-a3da-4b9e-bfdd-985fb1f527c8%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/std-proposals<wbr>/172d=
08f0-a3da-4b9e-bfdd-985fb<wbr>1f527c8%40isocpp.org</a>.<br>
</blockquote></div><br></div></div></div></div>
</blockquote></div><br></div></div></div>
</blockquote></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/CAFdMc-2Fgm3A2JjbERdCeFqDDFFTHhWFLPEr=
6Jw4uPp2dw1Pbg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFdMc-2Fgm3A2Jjb=
ERdCeFqDDFFTHhWFLPEr6Jw4uPp2dw1Pbg%40mail.gmail.com</a>.<br />

--94eb2c0b1dde88c4c605447e007e--

.
