lexical_cast throws when used with empty vector (1.48.0)

Boost 1.48.0's lexical_cast throws bad_lexical_cast when used with an empty vector. This is observable in the following program: #include <boost/lexical_cast.hpp> #include <cassert> #include <iostream> #include <iterator> #include <string> #include <vector> std::ostream & operator<<(std::ostream & out, const std::vector<long> & v) { std::ostream_iterator<long> it(out); std::copy(v.begin(), v.end(), it); assert(out); return out; } int main() { std::vector<long> v; //v.push_back(1); std::cout << boost::lexical_cast<std::string>(v); } If the commented line is uncommented (making the vector nonempty), the program runs without an exception. Is this the intended behavior? -- Braden McDaniel e-mail/Jabber IM: braden@endoframe.com http://endoframe.com
participants (1)
-
Braden Northington McDaniel