220 9097 <CAA7U3HOS7bpuM6rs1256zzyiQeHeTs4vUXMK9f5V31=BDFkptQ@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Olaf van der Spek <olafvdspek@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: String to T conversions - getting it right
 this time
Date: Wed, 5 Feb 2014 15:08:04 +0100
Lines: 57
Approved: news@gmane.org
Message-ID: <CAA7U3HOS7bpuM6rs1256zzyiQeHeTs4vUXMK9f5V31=BDFkptQ@mail.gmail.com>
References: <097fb6c8-56f9-433e-a2f0-8c0f69609bf0@isocpp.org>
	<CAA7U3HOY2CgSbOwBUbgyynNWCWKku=bDM0f_qetGApTP2cwkpA@mail.gmail.com>
	<lcok30$ohu$1@ger.gmane.org>
	<5061438.KRSokrkgRP@tjmaciei-mobl4>
	<lcoo1r$dbm$1@ger.gmane.org>
	<a560d387-3247-4eb5-95bc-dee7294bd0d5@isocpp.org>
	<lcp3il$tb5$1@ger.gmane.org>
	<CAA7U3HMoE3-R5L0r-gQMOzCQ4cvztNtqEe_N5csNexZ0fyzddQ@mail.gmail.com>
	<lcpbn6$pun$1@ger.gmane.org>
	<a614dbf8-4a1f-4fa3-92a2-8df63af8db3b@isocpp.org>
	<lcroci$ndi$1@ger.gmane.org>
	<866adea3-6322-4c6a-96f8-ea76a5d7ea7c@isocpp.org>
	<lcs0jv$ln9$1@ger.gmane.org>
	<03d172fa-2886-4d24-8943-ad6481b330b2@isocpp.org>
	<lcs4rd$jt$1@ger.gmane.org>
	<ba1466c4-58f0-4936-8ed5-0f0f3b4bbf19@isocpp.org>
	<CAGg_6+PYboM_qDcupvaJbHym++Ovhw3ZGUca-_+h3v0Ep-RbPg@mail.gmail.com>
	<58810bd8-32aa-471d-bf2c-1d5580d48c31@isocpp.org>
	<48d8fd32-568d-4f06-86c5-e7ab64f19632@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: ger.gmane.org 1391609282 5685 80.91.229.3 (5 Feb 2014 14:08:02 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 5 Feb 2014 14:08:02 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC5NB45SSABBBRMLZGLQKGQENISWXFQ@isocpp.org Wed Feb 05 15:08:09 2014
Return-path: <std-proposals+bncBC5NB45SSABBBRMLZGLQKGQENISWXFQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yk0-f199.google.com ([209.85.160.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC5NB45SSABBBRMLZGLQKGQENISWXFQ@isocpp.org>)
	id 1WB395-0002sJ-4n
	for gclcip-std-proposals@m.gmane.org; Wed, 05 Feb 2014 15:08:07 +0100
Original-Received: by mail-yk0-f199.google.com with SMTP id 142sf1944935ykq.2
        for <gclcip-std-proposals@m.gmane.org>; Wed, 05 Feb 2014 06:08:06 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:date
         :message-id:subject:from:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe:content-type;
        bh=Y/uf5UBYmn/WoJgefA/IBKdr/SIYQ2TvnJk5J6adjxE=;
        b=f+8z3zi3FxsgPd513kiJm6hM6oOb1LaFz4JlCb/j/gNCBoSq3Vr4FGfI2kGlRIhqJF
         pMiwMjTU8T13aK5ZYmF07KbbO4/SmbrurNbPZaSp0w4O4bh4iYRA0Hxrb0bwdJVaHQWy
         VYb+Ey8CQ2eGONZ9GWhSvaDdvBHB++dJjG+YuWTBLt6Un1tHTDcEhQA59gzgJYNdD3qO
         /qE2EBSRXgYjk0+KUIi/4MG4hCnLMGWertLi/WpWC7JARu28YyhHDBdByezX5fbx7LHR
         U2d9NobgCkV6dUwUPHb7ZOL0KlkjJJonndcwFuds/ogGFTsmziYHJ/b+p6/C/h0QEJTY
         uPDg==
X-Gm-Message-State: ALoCoQm8gCENqlz2eIurFmIjjPm/5yoz96JblM//7vWebrvkwU9CnDhNhe1PJSNIKWmjamTMUnsd
X-Received: by 10.58.4.166 with SMTP id l6mr4576941vel.3.1391609286231;
        Wed, 05 Feb 2014 06:08:06 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.94.41 with SMTP id f38ls122811qge.55.gmail; Wed, 05 Feb
 2014 06:08:05 -0800 (PST)
X-Received: by 10.224.74.129 with SMTP id u1mr1940820qaj.49.1391609285393;
        Wed, 05 Feb 2014 06:08:05 -0800 (PST)
Original-Received: from mail-qa0-x229.google.com (mail-qa0-x229.google.com [2607:f8b0:400d:c00::229])
        by mx.google.com with ESMTPS id p10si7022536qag.118.2014.02.05.06.08.05
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Wed, 05 Feb 2014 06:08:05 -0800 (PST)
Received-SPF: pass (google.com: domain of olafvdspek@gmail.com designates 2607:f8b0:400d:c00::229 as permitted sender) client-ip=2607:f8b0:400d:c00::229;
Original-Received: by mail-qa0-f41.google.com with SMTP id w8so573108qac.14
        for <std-proposals@isocpp.org>; Wed, 05 Feb 2014 06:08:05 -0800 (PST)
X-Received: by 10.224.74.129 with SMTP id u1mr1940777qaj.49.1391609285084;
 Wed, 05 Feb 2014 06:08:05 -0800 (PST)
Original-Received: by 10.229.138.6 with HTTP; Wed, 5 Feb 2014 06:08:04 -0800 (PST)
In-Reply-To: <48d8fd32-568d-4f06-86c5-e7ab64f19632@isocpp.org>
X-Original-Sender: olafvdspek@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of olafvdspek@gmail.com designates 2607:f8b0:400d:c00::229 as
 permitted sender) smtp.mail=olafvdspek@gmail.com;       dkim=pass
 header.i=@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: <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: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:9097
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/9097>

On Wed, Feb 5, 2014 at 7:02 AM, Matthew Fioravante
<fmatthew5876@gmail.com> wrote:
> After reading Matthew's posts (the other matthew, not me!). I like his ideas
> better. The below is very elegant.
>
> auto result = parse<int>("1234");
> if(!result) {
>   //handle error
>   //Can do switch(result.error()) if we want
> }
> use(result.value());

int result;
if (auto err = parse(result, "1234")) {
   //handle error
   //Can do switch(err) if we want
 }
 use(result);

;)

> We could make value() throw on error like std::expected, giving us a C style
> return code interface and C++ style exception interface all in one. If the
> user explicitly checks the error status before calling value(), its easy for
> the compiler to optimize out the conditional and the throwing logic

Are you sure it's easy? Got a reference?

> What radix do I use?

Have a base/radix parameter defaulting to 10.

> Do I allow 0x and 0 (octal) prefixes?

I'd allow 0x (when radix = 0), I'd never allow 0.

> Do I allow + prefix?

Sure, why not?

> Locales?
> Commas or just digits?

Both handled by a locale-aware variant.

> First, I think we would need to decide on a complete set of options. The
> next big question is what is the best interface which will allow the user to
> specify them easily and what are the most sensible defaults?

-- 

--- 
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/.

.
