|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r83642 - trunk/boost
From: antoshkka_at_[hidden]
Date: 2013-03-30 03:20:23
Author: apolukhin
Date: 2013-03-30 03:20:22 EDT (Sat, 30 Mar 2013)
New Revision: 83642
URL: http://svn.boost.org/trac/boost/changeset/83642
Log:
Fix streams and buffers usage (refs #8267 and refs #7704). Now conversions the use STL streams shall work faster
Text files modified:
trunk/boost/lexical_cast.hpp | 20 +++++++++-----------
1 files changed, 9 insertions(+), 11 deletions(-)
Modified: trunk/boost/lexical_cast.hpp
==============================================================================
--- trunk/boost/lexical_cast.hpp (original)
+++ trunk/boost/lexical_cast.hpp 2013-03-30 03:20:22 EDT (Sat, 30 Mar 2013)
@@ -1526,13 +1526,12 @@
#if defined(BOOST_NO_STRINGSTREAM)
typedef std::ostrstream out_stream_t;
- typedef parser_buf<std::strstreambuf, char> unlocked_but_t;
#elif defined(BOOST_NO_STD_LOCALE)
typedef std::ostringstream out_stream_t;
- typedef parser_buf<std::stringbuf, char> unlocked_but_t;
+ typedef parser_buf<std::streambuf, char> buffer_t;
#else
typedef std::basic_ostringstream<CharT, Traits> out_stream_t;
- typedef parser_buf<std::basic_stringbuf<CharT, Traits>, CharT> unlocked_but_t;
+ typedef parser_buf<std::basic_streambuf<CharT, Traits>, CharT> buffer_t;
#endif
typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c<
RequiresStringbuffer,
@@ -1615,8 +1614,9 @@
BOOST_STATIC_ASSERT((boost::is_same<char, CharT>::value));
#endif
bool const result = !(out_stream << input).fail();
- const unlocked_but_t* const p
- = static_cast<unlocked_but_t*>(out_stream.rdbuf()) ;
+ const buffer_t* const p = static_cast<buffer_t*>(
+ static_cast<std::basic_streambuf<CharT, Traits>*>(out_stream.rdbuf())
+ );
start = p->pbase();
finish = p->pptr();
return result;
@@ -1984,15 +1984,13 @@
std::istrstream stream(start, finish - start);
#else
+ buffer_t buf;
+ buf.setbuf(start, finish - start);
#if defined(BOOST_NO_STD_LOCALE)
- std::istringstream stream;
+ std::istream stream(&buf);
#else
- std::basic_istringstream<CharT, Traits> stream;
+ std::basic_istream<CharT, Traits> stream(&buf);
#endif // BOOST_NO_STD_LOCALE
-
- unlocked_but_t buf;
- buf.setbuf(start, finish - start);
- dynamic_cast<std::basic_ios<CharT, Traits>&>(stream).rdbuf(&buf);
#endif // BOOST_NO_STRINGSTREAM
stream.unsetf(std::ios::skipws);
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk