From 214689840924611506
X-Google-Thread: f78e5,e4aa14519cca09ff
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII
Path: g2news1.google.com!news4.google.com!news.glorb.com!news.alt.net!comp-std-cpp-robomod!not-for-mail
From: "msalters" <Michiel.Salters@logicacmg.com>
Newsgroups: comp.std.c++
Subject: Re: My nitpicks on n1774
Date: 9 May 2005 17:40:12 GMT
Organization: http://groups.google.com
Lines: 38
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <1115628192.099176.167260@f14g2000cwb.googlegroups.com>
References: <1gvl3nc.1btw8bq15u28exN%thedl0-usenet1@yahoo.com>
   <1114785595.237226.56270@g14g2000cwa.googlegroups.com>
   <87vf63z31d.fsf@Astalo.kon.iki.fi>
   <42788af6$0$297$4d4ebb8e@businessnews.de.uu.net>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
Delivered-To: std-c++@ucar.edu
X-Trace: posting.google.com 1115628196 5395 127.0.0.1 (9 May 2005 08:43:16 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 9 May 2005 08:43:16 +0000 (UTC)
User-Agent: G2/0.2
Complaints-To: groups-abuse@google.com
Injection-Info: f14g2000cwb.googlegroups.com; posting-host=212.123.206.71;
   posting-account=G8Vn6AwAAAAe3s4qFj7nFOuhEuzTNEir
X-Virus-Scanned: amavisd-new at ucar.edu
X-MIME-Autoconverted: from quoted-printable to 8bit by mailman.ucar.edu id j498hJKE028299
X-Virus-Scanned: by amavisd-new at cs.mu.OZ.AU
X-Virus-Scanned: by amavisd-new at cs.mu.OZ.AU
Xref: g2news1.google.com comp.std.c++:4678


"Daniel Kr�gler ne Spangenberg wrote:

> >[lib.integer.members] #8-#12: There could also be a constructor
> >that takes a range of chars delimited by two bidirectional
> >iterators.  Perhaps even remove the conversion from std::string
> >altogether.  integer(char const*) should still be kept because it
> >is so convenient with string literals.

> Why should your proposed char iterators be bidirectional?

I asssume because it's slightly easier to parse a number in reverse;
the basic algorithm is (using reverse_iterators)
integer base = 1;
for( ri = rbegin; ri != rend ; ++ri )
{
  value = base * (*ri);
  base *= 10;
}
Of course, the forward equivalent is
for( i = begin; i != end ; ++i )
{
  value = value * 10 + *i;
}
but I'm not sure if the base*=10 can be optimized better than
value*=10. Both are basically 2 bitshift operations and an
addition, but 10^N has N trailing zeroes that can be ignored.

Regards,
Michiel Salters.


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



