220 18092 <7a01ca3b-ad4a-49c1-b1cc-ce2b9fa5ff84@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Matthew Fioravante <fmatthew5876@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Parsing Numbers
Date: Wed, 20 May 2015 20:18:42 -0700 (PDT)
Lines: 231
Approved: news@gmane.org
Message-ID: <7a01ca3b-ad4a-49c1-b1cc-ce2b9fa5ff84@isocpp.org>
References: <eb5c19d6-074f-4ee4-8e2d-6d92349eb4be@isocpp.org>
 <555CDDEF.8000002@gmx.net>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_4836_1788312111.1432178322075"
X-Trace: ger.gmane.org 1432178326 21948 80.91.229.3 (21 May 2015 03:18:46 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 21 May 2015 03:18:46 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDELF54RTIGRBE456WVAKGQEKDU6Z4Y@isocpp.org Thu May 21 05:18:46 2015
Return-path: <std-proposals+bncBDELF54RTIGRBE456WVAKGQEKDU6Z4Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ig0-f197.google.com ([209.85.213.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDELF54RTIGRBE456WVAKGQEKDU6Z4Y@isocpp.org>)
	id 1YvH0O-0008Ni-IE
	for gclcip-std-proposals@m.gmane.org; Thu, 21 May 2015 05:18:44 +0200
Original-Received: by igbri1 with SMTP id ri1sf112544799igb.2
        for <gclcip-std-proposals@m.gmane.org>; Wed, 20 May 2015 20:18: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:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=ai9s7VXcdayxpYO3zEyd5SR8wnNiLNGS9HyWEVIKRUw=;
        b=SKq3laXgwk/yIrFYRjNZJ7qwW2vpeO7JlSiL4dpHEgsOfgPt3+QLY07qUlA8lrRD5X
         76V+KBLwrTS0/kR70el/KDLM52+OdUqFQBwv3wP192ByZheET4rk3pEMLT0ak8cv2UK5
         OfE31e7kLpX64QaTxjBdMx8Vze7tPr4LtDx6/hvZ8B7UNJbIorIK2XfBhPYZK5pacuDr
         +DTZYrcNmPofs+nqUlNy3ONPObSYKtOy3VK0L1l0UcMho1YEqLTciJS2rdbjHigYS9DA
         pnRvjs+8mK3VQGEj7UYQFwt9+/+C07kh9Fo9TWXymmnn/44Us6KqCrzuHS07qrAdAqZY
         MtjQ==
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:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=ai9s7VXcdayxpYO3zEyd5SR8wnNiLNGS9HyWEVIKRUw=;
        b=aGUYSQAlqKAFRXx/7qHiEvQOqDyJQgabyofo6EPzc2mziweO9RUSo60EOb6qUuaE/g
         ApAqDjg1mrcsdmOWJ18FhILwYrets//34TKt3TrFi8Bdk0mJZpi9IPJaKYMVX7PBGKun
         tUltQbae85l7xo0/rJXcPe6VvN0eeiUSo/mv+p6EbD+Z4EJcI9meqaq/N6fcQGzni0r0
         UNFXcmjQ+Iu5afVSmJ0RRRsdHDLV0R1GtLdrm3f+jVHkSsyqws7pRcLen7zVOQ3pe80o
         8dQj6n9pzA0QqwIyhOgfb0r2o4wRddk5bY6sD/+d7+1hnxjyMG//8gEqaL3dNsJaDjdx
         W3zw==
X-Gm-Message-State: ALoCoQlWYv81o7UYjhE7hwC5K5Sz6JqaqKzOa6DkO/2Ne5stsuIqSxZI5POGQWwdvDgYAYdTk7gm
X-Received: by 10.182.55.105 with SMTP id r9mr824648obp.3.1432178323622;
        Wed, 20 May 2015 20:18:43 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.30.119 with SMTP id c110ls1207455qgc.91.gmail; Wed, 20 May
 2015 20:18:42 -0700 (PDT)
X-Received: by 10.140.98.138 with SMTP id o10mr4774qge.33.1432178322902;
        Wed, 20 May 2015 20:18:42 -0700 (PDT)
In-Reply-To: <555CDDEF.8000002@gmx.net>
X-Original-Sender: fmatthew5876@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: <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:18092
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/18092>

------=_Part_4836_1788312111.1432178322075
Content-Type: multipart/alternative; 
	boundary="----=_Part_4837_1268253146.1432178322075"

------=_Part_4837_1268253146.1432178322075
Content-Type: text/plain; charset=UTF-8



On Wednesday, May 20, 2015 at 3:18:24 PM UTC-4, Jens Maurer wrote:
>
> My suggestion: 
>
> const char * ret = parse(T& v, const char * first, const char * last, int 
> base, error_code&); 
>

What is the value add of using char* pairs and a char* return vs 
string_view? Symmetry with iterator algorithms?

string_view parse(T& v, string_view s, int base, error_code&);

//If you have char* pointers
char* cb;
char* ce;
error_code ec;
int value;
auto tail = parse(value, {cb,ce}, 10, ec);

 

>
> [ret, last[ is the unparsed part of the string.  If ret == first, v is not 
> overwritten and we have an error, otherwise v contains the parsed value. 
> (Feel free to switch the base vs. error_code& parameters to allow a 
> defaulted base.) 
>
>
You could also add an overload:

template <typename T> inline const char* parse(T& v, const char* b, const 
char* e, error-code& ec) { return parse(v,b,e,10,ec); }

 

>
> This allows some symmetry with similar output operations: 
>
> char * p = output(char * first, char * last, T v);  


> which outputs "v" into the space provided by [first, last[, 
> returning the remaining space as [p, last[. 
>
> (This doesn't work with string_view, because it's read-only.) 
>

This kind of API looks like it could be another use case for mstring_view. 
array_view<char> would also work.

-- 

--- 
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_4837_1268253146.1432178322075
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Wednesday, May 20, 2015 at 3:18:24 PM UTC-4, Je=
ns Maurer wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">My suggestion:
<br>
<br>const char * ret =3D parse(T&amp; v, const char * first, const char * l=
ast, int base, error_code&amp;);
<br></blockquote><div><br></div><div>What is the value add of using char* p=
airs and a char* return vs string_view? Symmetry with iterator algorithms?<=
/div><div><br></div><div><div class=3D"prettyprint" style=3D"border: 1px so=
lid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 2=
50, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span =
style=3D"color: #000;" class=3D"styled-by-prettify">string_view parse</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">&amp;</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> v</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> string_view s</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">base</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> error_code</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">&amp;);</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">//If you have char* pointers=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">char</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> cb</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">char</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">*</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> ce</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>err=
or_code ec</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> value</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> tail </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> parse</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">value</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">cb</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">ce</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">},</span><font color=3D"#006666"><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;=
" class=3D"styled-by-prettify">10</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> ec</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">);</span></font></div></code></div><br></div><div>&nbsp;<br></div><=
blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bord=
er-left: 1px #ccc solid;padding-left: 1ex;">
<br>[ret, last[ is the unparsed part of the string. &nbsp;If ret =3D=3D fir=
st, v is not
<br>overwritten and we have an error, otherwise v contains the parsed value=
..
<br>(Feel free to switch the base vs. error_code&amp; parameters to allow a=
 defaulted base.)
<br>
<br></blockquote><div><br></div><div>You could also add an overload:</div><=
div><br></div><div><div class=3D"prettyprint" style=3D"border: 1px solid rg=
b(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 25=
0);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #008;" class=3D"styled-by-prettify">template</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">typename</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">inline</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">cons=
t</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">char</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> parse</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">(</span><font color=3D"#000088"><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&amp;</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> v</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">const</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>char</span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> b</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D=
"color: #000;" 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"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">char</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">*</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> e</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> error</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">-</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">code</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> ec</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">r=
eturn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> pars=
e</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">v</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">b</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">e</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">,</span><span style=3D"color: #066;" class=3D"styled-by-prettif=
y">10</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">ec</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">}</span></font></div></code></div><br=
>&nbsp;</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<br>This allows some symmetry with similar output operations:
<br>
<br>char * p =3D output(char * first, char * last, T v); &nbsp;</blockquote=
><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bo=
rder-left: 1px #ccc solid;padding-left: 1ex;">
<br>which outputs "v" into the space provided by [first, last[,
<br>returning the remaining space as [p, last[.
<br>
<br>(This doesn't work with string_view, because it's read-only.)
<br></blockquote><div><br></div><div>This kind of API looks like it could b=
e another use case for mstring_view. array_view&lt;char&gt; would also work=
..</div><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&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_4837_1268253146.1432178322075--
------=_Part_4836_1788312111.1432178322075--

.
