Subject: Re: [Boost-bugs] [Boost C++ Libraries] #7704: lexical_cast to filesystem::path fails for string::length > 22
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-12-01 18:45:32
#7704: lexical_cast to filesystem::path fails for string::length > 22
-----------------------------------------------------+----------------------
Reporter: Braden McDaniel <braden@â¦> | Owner: apolukhin
Type: Bugs | Status: new
Milestone: To Be Determined | Component: lexical_cast
Version: Boost 1.52.0 | Severity: Problem
Resolution: | Keywords:
-----------------------------------------------------+----------------------
Comment (by apolukhin):
Please, try this one:
{{{
#include <sstream>
#include <boost/filesystem/path.hpp>
#include <boost/lexical_cast.hpp>
template< class BufferType >
class stl_buf_unlocker: public BufferType{
public:
typedef BufferType base_class;
using base_class::pptr;
using base_class::pbase;
using base_class::setg;
using base_class::setp;
};
typedef stl_buf_unlocker<std::basic_stringbuf<char> > unlocked_but_t;
int main()
{
char data[] = "aaaaaaaaaaaaaaaaaaaaaaa";
char* start = data;
char* finish = start + sizeof(data);
std::basic_istringstream<char> stream;
static_cast<unlocked_but_t*>(stream.rdbuf())->setg(start, start,
finish);
stream.unsetf(std::ios::skipws);
std::string output;
// boost::filesystem::path output;
const bool b1 = (stream >> output);
const bool b2 = (stream.get() == std::char_traits<char>::eof());
BOOST_ASSERT(b1);
BOOST_ASSERT(b2);
return 0;
}
}}}
If it does not trigger asserts, then comment `std::string output;` and
uncomment `boost::filesystem::path output;` and try it once more.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/7704#comment:6> 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:50:11 UTC