[Boost-bugs] [Boost C++ Libraries] #1638: allow lexical_cast to handle based number strings

Subject: [Boost-bugs] [Boost C++ Libraries] #1638: allow lexical_cast to handle based number strings
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-02-16 18:43:37


#1638: allow lexical_cast to handle based number strings
---------------------------------------------+------------------------------
 Reporter: Steven Robbins <smr_at_[hidden]> | Type: Feature Requests
   Status: new | Milestone: Boost 1.36.0
Component: None | Version: Boost 1.34.1
 Severity: Problem | Keywords:
---------------------------------------------+------------------------------
 This report comes from Debian user "Wesley J. Landaker"
 <wjl_at_[hidden]>
 See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=412931


 Please allow lexical_cast to handle based number strings. Currently,
 it only supports decimal strings, but it should be able to handle octal
 and hexadecimal strings if they have correct prefix notations.

 Background:
 This happens because lexical_cast constructs a stringstream, which by
 default has the ios_base::dec flag set. If this flag is unset, it will
 still read decimal strings, but will also automatically determine the
 base by looking at the prefix, so will read decimal strings if the
 number starts with 0-9, octal if it starts with 0, and hex if it starts
 with 0x.

 Fix:
 After constructing the stringstream, simply call
 stringstring::unsetf(std::ios_base::basefield). Because decimal numbers
 are still handled correctly, this is totally backwards compatible.

--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/1638>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.


This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:57 UTC