Opened 10 years ago
Closed 10 years ago
#8267 closed Bugs (fixed)
lexical_cast uses stream buffers incorrectly
Reported by: | John Maddock | Owned by: | Antony Polukhin |
---|---|---|---|
Milestone: | Boost 1.54.0 | Component: | lexical_cast |
Version: | Boost Development Trunk | Severity: | Showstopper |
Keywords: | Cc: |
Description
As noted in http://llvm.org/bugs/show_bug.cgi?id=15446 lexical_cast manipulates stringstream's internal buffer in a non-std conforming way causing it to fail on libc++.
If it helps any Boost.Regex has a stream buffer class that (probably) does what you want - see parser_buf in boost/regex/v4/cpp_regex_traits.hpp.
Change History (10)
comment:1 by , 10 years ago
Status: | new → assigned |
---|
comment:2 by , 10 years ago
I'm happy to move to boost/detail, but looking around I see the iostreams lib has the same functionality, just tried this:
#include <boost/iostreams/stream_buffer.hpp> #include <boost/iostreams/device/array.hpp> int main() { namespace io = boost::iostreams; const char* buf = "12345.6789"; io::stream_buffer<io::array_source> sb(buf, buf + std::strlen(buf)); std::istream is(&sb); double d; is >> d; std::cout << d << std::endl; assert(is.rdbuf()->in_avail() == 0); return 0; }
Is that a better bet?
comment:3 by , 10 years ago
comment:4 by , 10 years ago
Milestone: | To Be Determined → Boost 1.54.0 |
---|
boost/regex/v4/cpp_regex_traits.hpp version does not fit 100%, copy-pasted it, slightly modified and committed it to lexical_cast.hpp.
Iostreams library is huge, also did not fit 100%.
comment:5 by , 10 years ago
The change is causing quite a few breakages in Multiprecision, quite a few lexical_cast tests are failing too: http://www.boost.org/development/tests/trunk/developer/conversion.html
comment:7 by , 10 years ago
comment:9 by , 10 years ago
comment:10 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
parser_buf looks good, I'd like to use it, but I do not want to add dependency to Boost.Regex. Can you move it to boost/utility or boost/detail? I think this class can be used by lots of people (I've saw some projects that make something similar to provide stack allocated buffer)